Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
polarnik opened this issue Mar 3, 2025 · 3 comments
Closed
Assignees

Comments

@polarnik
Copy link

polarnik commented Mar 3, 2025

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
@polarnik polarnik changed the title metricCustomizers / extraMetrics doesn't skips an MBean with string attributes only metricCustomizers / extraMetrics skips MBeans with string-only attributes Mar 3, 2025
@dhoard dhoard self-assigned this Mar 4, 2025
@dhoard
Copy link
Collaborator

dhoard commented Mar 4, 2025

@polarnik I'm actively working on a release blocking, so I won't be able to investigate in the short term.

@MaBiConti @karina-calma, would you expect String values to work?

@ameteo
Copy link

ameteo commented Mar 4, 2025

@polarnik I cannot reproduce your issue. With the configuration you provided, I can see the following metric in the output:

# HELP jetbrains_youtrack_Maintenance_isActive This is a boolean value indicating if the scenario is still active or is completed. jetbrains.youtrack:name=Global,type=Maintenance,attribute=isActive
# TYPE jetbrains_youtrack_Maintenance_isActive untyped
jetbrains_youtrack_Maintenance_isActive{Build="62967",Version="2025.1",name="Global"} 1.0

@polarnik
Copy link
Author

polarnik commented Mar 6, 2025

Yes, it's my mistake. I used version 1.1.0 because there was a typo in my docker-compose file. I mounted a jmx agent two times, a new version and a release version 1.1.0 into a same file.

@polarnik polarnik closed this as completed Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants