Skip to content

Jolokia2 paniced from nil reponse #11410

@PapaPiya

Description

@PapaPiya

Relevant telegraf.conf

[[inputs.jolokia2_agent]]
  interval="10s"
  urls = ["http://localhost:8081/jolokia","http://localhost:7777/jolokia"]

  [[inputs.jolokia2_agent.metric]]
    name  = "java_garbage_collector"
    mbean = "java.lang:name=*,type=GarbageCollector"
    paths = ["CollectionTime","CollectionCount"]

  [[inputs.jolokia2_agent.metric]]
    name  = "java_last_garbage_collection"
    mbean = "java.lang:name=*,type=GarbageCollector"
    paths = ["LastGcInfo/duration","LastGcInfo/GcThreadCount"]

[[outputs.file]]
  files = ["stdout"]

Logs from Telegraf

panic: There should be a map here for java.lang:name=*,type=GarbageCollector!


goroutine 57 [running]:
github.com/influxdata/telegraf/plugins/inputs/jolokia2/common.(*pointBuilder).Build(0xc000f4acc1?, {0xc000f4acc1, 0x26}, {0x0, 0x0})
        /Users/papapiya/go/src/github.com/influxdata/telegraf/plugins/inputs/jolokia2/common/point_builder.go:38 +0x31f
github.com/influxdata/telegraf/plugins/inputs/jolokia2/common.(*Gatherer).generatePoints(0xc000034300?, {{0xc000f4ac31, 0x1c}, {0xc000f4acc1, 0x26}, {0xc0006292e0, 0x2, 0x2}, {0x0, 0x0}, ...}, ...)
        /Users/papapiya/go/src/github.com/influxdata/telegraf/plugins/inputs/jolokia2/common/gatherer.go:97 +0x528
github.com/influxdata/telegraf/plugins/inputs/jolokia2/common.(*Gatherer).gatherResponses(0xc0007f8180, {0xc000034300, 0x5, 0x8}, 0x0?, {0x9e44170, 0xc0006296e0})
        /Users/papapiya/go/src/github.com/influxdata/telegraf/plugins/inputs/jolokia2/common/gatherer.go:57 +0x4f8
github.com/influxdata/telegraf/plugins/inputs/jolokia2/common.(*Gatherer).Gather(0xc0007f8180, 0xc0006081c0, {0x9e44170, 0xc0006296e0})
        /Users/papapiya/go/src/github.com/influxdata/telegraf/plugins/inputs/jolokia2/common/gatherer.go:42 +0x24c
github.com/influxdata/telegraf/plugins/inputs/jolokia2/jolokia2_agent.(*JolokiaAgent).Gather.func1(0xc0006081c0)
        /Users/papapiya/go/src/github.com/influxdata/telegraf/plugins/inputs/jolokia2/jolokia2_agent/jolokia2_agent.go:67 +0x97
created by github.com/influxdata/telegraf/plugins/inputs/jolokia2/jolokia2_agent.(*JolokiaAgent).Gather
        /Users/papapiya/go/src/github.com/influxdata/telegraf/plugins/inputs/jolokia2/jolokia2_agent/jolokia2_agent.go:64 +0x1ec

System info

Telegraf 1.23.0, Darwin 17.5.0

Docker

No response

Steps to reproduce

1.Use relevant config to start telegraf: ./telegraf --config telegraf.conf
2.It comes panic info in stdout and stop.
3.Jolokia request and response list here:

  • request:
[
    {
        "attribute": [
            "CollectionCount",
            "CollectionTime"
        ],
        "mbean": "java.lang:name=*,type=GarbageCollector",
        "type": "read"
    },
    {
        "attribute": "LastGcInfo",
        "mbean": "java.lang:name=*,type=GarbageCollector",
        "path": "duration",
        "type": "read"
    },
    {
        "attribute": "LastGcInfo",
        "mbean": "java.lang:name=*,type=GarbageCollector",
        "path": "GcThreadCount",
        "type": "read"
    }
]
  • response
[
    {
        "request": {
            "attribute": [
                "CollectionCount",
                "CollectionTime"
            ],
            "mbean": "java.lang:name=*,type=GarbageCollector",
            "type": "read"
        },
        "status": 200,
        "timestamp": 1656469537,
        "value": {
            "java.lang:name=ConcurrentMarkSweep,type=GarbageCollector": {
                "CollectionCount": 3,
                "CollectionTime": 683
            },
            "java.lang:name=ParNew,type=GarbageCollector": {
                "CollectionCount": 443,
                "CollectionTime": 29926
            }
        }
    },
    {
        "request": {
            "attribute": "LastGcInfo",
            "mbean": "java.lang:name=*,type=GarbageCollector",
            "path": "duration",
            "type": "read"
        },
        "status": 200,
        "timestamp": 1656469537,
        "value": null
    },
    {
        "request": {
            "attribute": "LastGcInfo",
            "mbean": "java.lang:name=*,type=GarbageCollector",
            "path": "GcThreadCount",
            "type": "read"
        },
        "status": 200,
        "timestamp": 1656469537,
        "value": null
    }
]

Expected behavior

When jolokia response with null value, the telegraf process not panic and exit.

Actual behavior

Telegraf paniced with null response value.

Additional info

When mbean contains "*" and paths contains subpath like "LastGcInfo/duration", the jolokia response with null value

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugunexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions