Skip to content

metricCustomizers / extraMetrics skips MBeans with string-only attributes #1147

@polarnik

Description

@polarnik

Description

I have an MBean with two attributes, but both attributes are strings. I would like to customize a config file and convert two string attributes to labels with adding an extra-Metric via the option extraMetrics

Prometheus Exporter skips MBeans without numeric attributes. We can try to add a numeric attribute via the
metricCustomizers / extraMetrics
see an example:

But the output will skip the MBean anyway

See also:

Environment

  • Java 21
  • jmx-exporter (main) commit f024c74
  • youtrack docker container jetbrains/youtrack:2025.1.62967

Config

jmx_exporter.yml

startDelaySeconds: 10
lowercaseOutputName: false
lowercaseOutputLabelNames: false

includeObjectNames: ["jetbrains.youtrack:type=Maintenance,name=Global"]
metricCustomizers:
  - mbeanFilter:
      domain: jetbrains.youtrack
      properties:
        type: Maintenance
        name: Global
    attributesAsLabels:
      - Build
      - Version
    extraMetrics:
      - name: isActive
        value: true
        description: This is a boolean value indicating if the scenario is still active or is completed.

youtrack.jvmoptions

-XX:NativeMemoryTracking=summary
-XX:+PrintFlagsFinal
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9010
-Dcom.sun.management.jmxremote.rmi.port=9011
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=127.0.0.1

-javaagent:/opt/app/jmx_prometheus_javaagent-1.1.0-post.jar=youtrack:9404:/opt/app/jmx_exporter.yml

docker-compose

services:
  youtrack:
    image: jetbrains/youtrack:2025.1.62967
    hostname: youtrack
    restart: "no"
    ports:
      - '9404:9404'
      - '9010:9010'
      - '9011:9011'
      - "8080:8080"
    tmpfs:
      /tmp
    volumes:
      - ./volumes/youtrack_data:/opt/youtrack/data
      - ./volumes/youtrack_conf:/opt/youtrack/conf
      - ./volumes/youtrack_logs:/opt/youtrack/logs
      - ./volumes/youtrack_backups:/opt/youtrack/backups
      - ./volumes/youtrack_temp:/opt/youtrack/temp
      - "./configs/youtrack/youtrack.jvmoptions:/opt/youtrack/conf/youtrack.jvmoptions:ro"
      - "./configs/prometheus_jmx_exporter/jmx_exporter.yml:/opt/app/jmx_exporter.yml:ro"
      - "./tools/jmx_prometheus_javaagent-1.1.0-post.jar:/opt/app/jmx_prometheus_javaagent-1.1.0-post.jar:ro"

Steps

  1. Start a docker-compose
  2. Copy a wizard_token from the docker logs
  3. Open http://127.0.0.1:8080/
  4. Add the wizard_token from the logs: http://127.0.0.1:8080/?wizard_token=pk191NZmHm8GGTOfpdVy
  5. Start creating a new instance
  6. Set a domain:
  1. Set a password and tokens
  • admin
  • admin
  1. Wait a few seconds
  2. Install visualVM https://visualvm.github.io/
  3. Install a visualVM plugin: Menu / Tools / Plugins / Available Plugins / VisualVM MBean
  4. Connect from the VisualVM tool to the remote host: 127.0.0.1:9010
  5. Open an MBean with numeric and String attributes, for example jetbrains.youtrack:type=Hub,name=HubIntegration

Actual result

A test MBean is:

  • jetbrains.youtrack:type=Maintenance,name=Global

Attributes:

Attribute name Readable Type Value
Build true java.lang.String 62967
Version true java.lang.String 2025.1
Image Image

An output doesn't have the metric isActive

Expected result

The output will have the metric isActive

Workaround

We can create metrics for each string attribute via the config:

startDelaySeconds: 10
lowercaseOutputName: false
lowercaseOutputLabelNames: false

whitelistObjectNames:
  - "jetbrains.youtrack:type=Maintenance,name=Global"

rules:
  - pattern: 'jetbrains.youtrack<type=Maintenance, name=Global><>(\w+): (.+)'
    name: youtrack_version_info
    labels:
      $1: $2
    value: 1.0
    type: GAUGE
    help: Application version info

We will get a metric with name youtrack_version for the last version of jmx-exporter and a metric with name youtrack_version_info for the old version of jmx-exporter. See also:

And merge a few metrics into one via Grafana dashboard transformations

Image

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions