prometheus / jmx_exporter

A process for exposing JMX Beans via HTTP for Prometheus consumption
Apache License 2.0
2.98k stars 1.19k forks source link

Metric name "_info" suffix gets trimmed #982

Open iagotomas opened 3 weeks ago

iagotomas commented 3 weeks ago

Hi, trying to implement a ruleset for some service, running jmx_exporter 1.0.1 as standalone I'm facing a weird issue which I'm not sure I understand. I have the following rule for which the "_info" suffix in the name gets dropped. If I employ another suffix or add additional characters to the suffix "_info" it remains.

rules:
  #metrics:name=jvmInfo.runtime.{runtime}.vendor.{vendor}.version.{version},type=gauges
  - pattern: 'metrics<name=jvmInfo\.runtime\.(.+)\.vendor\.(.+)\.version\.(.*), type=gauges><>Value'
    labels:
      runtime: $1
      vendor: $2
      version: $3
    type: UNTYPED
    name: jvm_runtime_info
    help: "JVM info"

Resulting metric name: jvm_runtime{runtime="OpenJDK_Runtime_Environment",vendor="Amazon.com_Inc.",version="17.0.7+7-LTS"} 1.0

Why does "_info" get removed from the name?

dhoard commented 2 weeks ago

The relevant code is here...

https://github.com/prometheus/jmx_exporter/blob/b3823bca97c7fc2166cac7d2d12e95963b352e4b/collector/src/main/java/io/prometheus/jmx/MatchedRule.java#L73

@fstab, do you remember the specifics around why we sanitize the name?