Description
As discussed in June 20th Java SIG meeting, we have two distinct ways to capture JMX metrics:
- with instrumentation agent through the JMX insight feature
- with contrib through the JMX gatherer (in this repository)
As a consequence, we have:
- JMX gatherer is using groovy scripts for metrics definition
- JMX insight is using YAML files for metrics definition
- both JMX insight and JMX gatherer allow to provide custom user-provided configuration using respectively a groovy script and a yaml file
- JMX gatherer provides ready-to-use metrics configuration for some target systems (tomcat, kafka, cassandra, ...)
- JMX insight provides ready-to-use metrics configuration for a few of the target systems supported by JMX gatherer.
In addition to the duplication of code, the metrics definition themselves are duplicated in two different incompatible formats (YAML and Groovy scripts), which makes the maintenance even harder and further complicates their evolution. For example trying to change definitions in instrumentation like in opentelemetry-java-instrumentation#11621 becomes more complicated than it should.
JMX gatherer allows to capture JMX metrics from outside of the JVM and is used in the collector-contrib repository. Usages of it can be found by searching for usages of otel.jmx.service.url
on GH.
JMX gatherer is used in the opentelemetry-collector-contrib repository by the jmxreceiver
Proposal
- reuse YAML-based implementation of JMX insight (instrumentation) for JMX gatherer implementation
- replace target system metrics definition with YAML equivalents
- drop support for user-provided groovy scripts, they would have to be replaced by YAML equivalent
- for now keep the metrics definitions identical to their current state to preserve compatibility
- aligning any metrics definition differences (if there is any) would be handled through follow-up updates to the YAML definitions.
Removing the user-provided groovy script support is the only breaking change here, the rationale is:
- it is still possible (and easier) to capture custom metrics with YAML, so the feature is preserved
- maintenance of YAML files is expected to be simpler and allows to keep insight/gatherer in sync
- usage of
otel.jmx.groovy.script
inopentelemetry-collector-contrib
was removed 2 years ago for security reasons (opentelemetry-collector-contrib#6750 and opentelemetry-collector-contrib#9721) - searching for references to
otel.jmx.groovy.script
on GH returns mostly point to old forks of theopentelemetry-collector-contrib
, so we can infer this feature is probably rarely used
All of this assumes that there are no limitations of the YAML metrics definition to represent the current groovy script definitions. In case of unsolvable incompatibilities we will have to decide on a case-by-case basis.
Implementation steps
The current path to implement this brings a few breaking changes so we decided to create a new "JMX Scraper" component that will provide an alternative to "JMX Gatherer" for an easier migration.
- bootstrap a new JMX Scraper module: [WIP] JMX scraper #1445
- allow reusing JMX Insights with remote connections Allow JMX Insight reuse for remote connections opentelemetry-java-instrumentation#12178 (part of instrumentation 2.9.0 release).
- implement & test SSL connection: server certificate + SSL RMI registry
- test SSL connection: client certificate
- implement and test for a single target system
tomcat
with definitions that matchtomcat.groovy
Reuse JMX Insights in Scraper + Tomcat support #1485 - publish and document JMX Scraper "MVP" for feedback and test publish jmx scraper artifact #1586
- maybe add ability to aggregate some mbean metrics to replicate Fix Tomcat metric definitions to aggregate multiple MBeans. #1366 in contrib, however this might also be covered by better metrics definition that use MBean key/values.
- implement and test other target systems
- activemq Integration test activemq #1497
- cassandra Cassandra support and integration test added. #1515
- hadoop JMX Scraper: YAML file and integration test hadoop #1675
- hbase JMX Scraper - YAML config and integration test for HBase #1538
- jetty Add jetty.yaml to JMX scraper #1517
- jvm Reuse JMX Insights in Scraper + Tomcat support #1485
- kafka-consumer JMX Scraper: Kafka server, producer and consumer YAMLs and integration tests added #1670
- kafka-producer JMX Scraper: Kafka server, producer and consumer YAMLs and integration tests added #1670
- kafka JMX Scraper: Kafka server, producer and consumer YAMLs and integration tests added #1670
- solr [jmx-scraper] add support for Solr #1595
- tomcat Reuse JMX Insights in Scraper + Tomcat support #1485
- wildfly add wildfly.yaml to JMX scraper #1531
- document usage and configuration jmx scraper with sdk autoconfig #1651
- make otel collector jmx receiver able to use it jmx receiver: migration plan to use jmx-scraper opentelemetry-collector-contrib#37469
- refactor assertions to provide easy debugging of test failures
- refactor configure to use autoconfiguration (support for env variables, yaml config, ...) jmx scraper with sdk autoconfig #1651