prometheus / jmx_exporter

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

Support ObjectName patterns in excludeObjectNameAttributes #897

Open KestasG opened 12 months ago

KestasG commented 12 months ago

Working on local project encountered performance issues with bean scraping. While analyzing found out that there are lot of unused attributes being tested against rules and taking significant amount of time. It is impossible to list all objects in excludeObjectNameAttributes as there are thousands of them, so decided to add pattern support for it. This allowed to reduce scraping time from 3.9 sec to 1.9 sec.

dhoard commented 11 months ago

@KestasG thanks for the PR!

Can you provide an example exporter YAML configuration showing your usage? Can you implement an integration test?

KestasG commented 11 months ago

I've started with

excludeObjectNameAttributes:
  "xxx.stream-consumers:*":
    - "RateUnit"
    - "MeanRate"
    - "FifteenMinuteRate"
    - "OneMinuteRate"
    - "FiveMinuteRate"
    - "DurationUnit"  
  "kafka.consumer:type=consumer-fetch-manager-metrics,client-id=*":
    - "fetch-size-max"
    - "records-consumed-total"
    - "fetch-rate"
    - "records-perd-request-avg"
    - "bytes-consumed-total"
    - "records-lead-min"
    - "fetch-latency-avg"
    - "bytes-consumed-rate"
    - "fetch-throttle-time-avg"
    - "fetch-latency-max"
    - "fetch-throttle-time-max"
    - "records-consumed-rate"
    - "fetch-total"    

and later realized that simpler definition works as well:

excludeObjectNameAttributes:
  "*:*":
    - "RateUnit"
    - "MeanRate"
    - "FifteenMinuteRate"
    - "OneMinuteRate"
    - "FiveMinuteRate"
    - "DurationUnit"
  "kafka.consumer:type=consumer-fetch-manager-metrics,client-id=*":
    - "fetch-size-max"
    - "records-consumed-total"
    - "fetch-rate"
    - "records-perd-request-avg"
    - "bytes-consumed-total"
    - "records-lead-min"
    - "fetch-latency-avg"
    - "bytes-consumed-rate"
    - "fetch-throttle-time-avg"
    - "fetch-latency-max"
    - "fetch-throttle-time-max"
    - "records-consumed-rate"
    - "fetch-total"    

Will try to get the test next week.

dhoard commented 11 months ago

You should be able to base it on...

https://github.com/prometheus/jmx_exporter/blob/main/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/DisableAutoExcludeObjectNameAttributesTest.java

https://github.com/prometheus/jmx_exporter/tree/main/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/DisableAutoExcludeObjectNameAttributesTest

If you have any questions, ping me.

KestasG commented 11 months ago

Added integration test. While writing a test realized that it makes little sense to keep old implementation, checking object names by exact match, so removed it.

batk0 commented 2 months ago

Hello! I've stumbled on the same problem. What's the status of this? Can it be merged in near future?

dhoard commented 1 month ago

@KestasG can you rebase this PR?