Skip to content

NullPointerException if bean_regexp has optional group #254

@spingel

Description

@spingel

Steps

  1. Configure a metric value using a bean_regexp with an optional capturing group

Example configuration:

                - include:
                    domain: app
                    bean_regex: app:name=app.bean(,type=.*)?
                    attribute:
                      Value:
                        metric_type: gauge
                        alias: app.metric

When the bean name does not include the optional capturing group (e.g. app:name=app.bean), this configuration results in an NPE and failure to report the metric value.

Work-around

Use a optional non-capturing group, e.g. bean_regex: app:name=app.bean(?:,type=.*)?

Logs

Logs from running datadog-agent -l debug jmx list everything

2019-11-18 16:44:27 UTC | CORE | INFO | (pkg/jmxfetch/jmxfetch.go:200 in func1) | 2019-11-18 16:44:27,032 | ERROR | Instance | Error while trying to match attributeInf
o configuration with the Attribute: app:name=app.bean : javax.mana
gement.MBeanAttributeInfo[description=Attribute exposed for management, name=Value, type=java.lang.Object, read-only, descriptor={}]
2019-11-18 16:44:27 UTC | CORE | INFO | (pkg/jmxfetch/jmxfetch.go:200 in func1) | java.lang.NullPointerException
2019-11-18 16:44:27 UTC | CORE | INFO | (pkg/jmxfetch/jmxfetch.go:200 in func1) |       at java.lang.String.replace(String.java:2240)
2019-11-18 16:44:27 UTC | CORE | INFO | (pkg/jmxfetch/jmxfetch.go:200 in func1) |       at org.datadog.jmxfetch.JmxAttribute.replaceByAlias(JmxAttribute.java:570)
2019-11-18 16:44:27 UTC | CORE | INFO | (pkg/jmxfetch/jmxfetch.go:200 in func1) |       at org.datadog.jmxfetch.JmxAttribute.addAdditionalTags(JmxAttribute.java:119)
2019-11-18 16:44:27 UTC | CORE | INFO | (pkg/jmxfetch/jmxfetch.go:200 in func1) |       at org.datadog.jmxfetch.JmxAttribute.setMatchingConf(JmxAttribute.java:445)
2019-11-18 16:44:27 UTC | CORE | INFO | (pkg/jmxfetch/jmxfetch.go:200 in func1) |       at org.datadog.jmxfetch.Instance.getMatchingAttributes(Instance.java:572)
2019-11-18 16:44:27 UTC | CORE | INFO | (pkg/jmxfetch/jmxfetch.go:200 in func1) |       at org.datadog.jmxfetch.Instance.init(Instance.java:370)
2019-11-18 16:44:27 UTC | CORE | INFO | (pkg/jmxfetch/jmxfetch.go:200 in func1) |       at org.datadog.jmxfetch.InstanceInitializingTask.call(InstanceInitializingTask.java:15)
2019-11-18 16:44:27 UTC | CORE | INFO | (pkg/jmxfetch/jmxfetch.go:200 in func1) |       at org.datadog.jmxfetch.InstanceInitializingTask.call(InstanceInitializingTask.java:3)
2019-11-18 16:44:27 UTC | CORE | INFO | (pkg/jmxfetch/jmxfetch.go:200 in func1) |       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
2019-11-18 16:44:27 UTC | CORE | INFO | (pkg/jmxfetch/jmxfetch.go:200 in func1) |       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
2019-11-18 16:44:27 UTC | CORE | INFO | (pkg/jmxfetch/jmxfetch.go:200 in func1) |       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
2019-11-18 16:44:27 UTC | CORE | INFO | (pkg/jmxfetch/jmxfetch.go:200 in func1) |       at java.lang.Thread.run(Thread.java:748)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions