-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
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:
Line 9 in 01700b2
| extraMetrics: |
But the output will skip the MBean anyway
See also:
- Support for exposing attributes as labels #996
- metricCustomizers / attributesAsLabels doesn't work with string attributes #1146
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.ymldocker-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
- Start a docker-compose
- Copy a wizard_token from the docker logs
- Open http://127.0.0.1:8080/
- Add the wizard_token from the logs: http://127.0.0.1:8080/?wizard_token=pk191NZmHm8GGTOfpdVy
- Start creating a new instance
- Set a domain:
- Set a password and tokens
- admin
- admin
- Wait a few seconds
- Install visualVM https://visualvm.github.io/
- Install a visualVM plugin: Menu / Tools / Plugins / Available Plugins / VisualVM MBean
- Connect from the VisualVM tool to the remote host: 127.0.0.1:9010
- 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 |
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 infoWe 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
