Skip to content

metricCustomizers / attributesAsLabels doesn't work with string attributes #1146

@polarnik

Description

@polarnik

Description

We can select an MBean with string and numeric attributes and define a config section attributesAsLabels for all string attributes, but jmx_prometheus_javaagent will ignore all string attributes

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=Hub,name=HubIntegration"]
metricCustomizers:
  - mbeanFilter:
      domain: jetbrains.youtrack
      properties:
        type: Hub
        name: HubIntegration
    attributesAsLabels:
      - HubIntegrationStatus
      - PermissionCacheStatus
      - PermissionCacheStatus
      - RunningJob
      - EventSyncStatusStatus

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

The output doesn't have any new labels, it has only numeric attributes and one label 'name':

# HELP jetbrains_youtrack_Hub_HubEventsFailed hubEventsFailed jetbrains.youtrack:name=HubIntegration,type=Hub,attribute=HubEventsFailed
# TYPE jetbrains_youtrack_Hub_HubEventsFailed untyped
jetbrains_youtrack_Hub_HubEventsFailed{name="HubIntegration"} 0.0
# HELP jetbrains_youtrack_Hub_HubEventsIgnored hubEventsIgnored jetbrains.youtrack:name=HubIntegration,type=Hub,attribute=HubEventsIgnored
# TYPE jetbrains_youtrack_Hub_HubEventsIgnored untyped
jetbrains_youtrack_Hub_HubEventsIgnored{name="HubIntegration"} 1.0
# HELP jetbrains_youtrack_Hub_HubEventsPending hubEventsPending jetbrains.youtrack:name=HubIntegration,type=Hub,attribute=HubEventsPending
# TYPE jetbrains_youtrack_Hub_HubEventsPending untyped
jetbrains_youtrack_Hub_HubEventsPending{name="HubIntegration"} 0.0
# HELP jetbrains_youtrack_Hub_HubEventsProcessed hubEventsProcessed jetbrains.youtrack:name=HubIntegration,type=Hub,attribute=HubEventsProcessed
# TYPE jetbrains_youtrack_Hub_HubEventsProcessed untyped
jetbrains_youtrack_Hub_HubEventsProcessed{name="HubIntegration"} 0.0
# HELP jetbrains_youtrack_Hub_HubEventsReceived hubEventsReceived jetbrains.youtrack:name=HubIntegration,type=Hub,attribute=HubEventsReceived
# TYPE jetbrains_youtrack_Hub_HubEventsReceived untyped
jetbrains_youtrack_Hub_HubEventsReceived{name="HubIntegration"} 1.0

Image

Image

Expected result

String attributes:
- HubIntegrationStatus
- PermissionCacheStatus
- PermissionCacheStatus
- RunningJob
- EventSyncStatusStatus
will be converted to labels

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions