jmx_exporter icon indicating copy to clipboard operation
jmx_exporter copied to clipboard

[host:]<port>:<yaml configuration file> regexp limitation/error - Malformed arguments

Open Tzaphkiel opened this issue 3 years ago • 1 comments

Description

Trying to bind the JMXExporter javaagent to a specific interface (in the case there are many, 0.0.0.0 might not bind the agent the proper or public interface). Trying to specify a host with a name or domain containing a - or _ character is not recognized as a valid entry.

  • Error:
    Usage: -javaagent:/path/to/JavaAgent.jar=[host:]<port>:<yaml configuration file> Malformed arguments - myhostname.d-mit01.tadnet.net:7000:/opt/jmxExporter/hbase_config.yaml

Example:

  • use this online tester (or another equivalent) : https://regexr.com/
  • current expression: ^(?:((?:[\w.]+)|(?:\[.+])):)?(\d{1,5}):(.+)
  • text used to test
    7000:/opt/jmxExporter/hbase_config.yaml
    myhost.domain.com:7000:/opt/jmxExporter/hbase_config.yaml
    myhostname.d-mit01.tadnet.net:7000:/opt/jmxExporter/hbase_config.yaml
    myhostname.d_mit01.tadnet.net:7000:/opt/jmxExporter/hbase_config.yaml
    192.168.19.21:7000:/opt/jmxExporter/hbase_config.yaml
    http://myhostname.d-mit01.tadnet.net:7000:/opt/jmxExporter/hbase_config.yaml
    
  • use : multiline flag
  • use : result list with : $1\n$2\n$3\n\n

Proposed fix

The regex should support the following characters as well in the host expression _ & -.

  • Corrected expression: ^(?:((?:[\w._-]+)|(?:\[.+])):)?(\d{1,5}):(.+)

⇒ source ref

Tzaphkiel avatar May 06 '21 09:05 Tzaphkiel

Actually reviewing the above and the current expression, I do not know what the second (or part) of the host regexp is trying to achieve... it could be that it should be |(?:\[.]*) instead and thus that would actually work.

Tzaphkiel avatar May 06 '21 09:05 Tzaphkiel

I've added a JUnit test to the latest code and can't reproduce the issue.

dhoard avatar Jun 24 '23 03:06 dhoard