MBeans returned as Longs instead of Attributes

27 views
Skip to first unread message

Alex Brekken

unread,
Feb 14, 2023, 6:26:17 PM2/14/23
to Prometheus Users
Hey all, I'm using the prometheus/jmx_exporter javaagent to expose some metrics for the MongoDB Kafka Connect connector. (https://www.mongodb.com/docs/kafka-connector/current/monitoring/#std-label-kafka-monitoring-sink-attributes)

 If I add the entire ObjectName to the whitelist (
"com.mongodb.kafka.connect:*"), I noticed that none of the 39 metrics are getting returned after it scrapes the MBeans.  I built the prometheus/jmx_exporter project locally and am debugging through the code, pointing the jmxUrl at my running instance of Kafka Connect.  When JMXScraper makes the call to the MBean server to get the AttributeList (https://github.com/prometheus/jmx_exporter/blob/main/collector/src/main/java/io/prometheus/jmx/JmxScraper.java#L153) instead of getting back a list of Attributes, it gets back a list of java.lang.Longs.  As a result, a few lines later (line 159) the bean never gets processed because it's not an instance of Attribute. 

Does this just mean that the MongoDB connector code is simply "doing it wrong" when it comes to exposing these MBeans?  Using JConsole I can view the MBeans and see the values, but I'm not sure that necessarily means much in this  context.  I'm happy to push on them if that's the right solution, but I wanted to check here first to make sure there isn't something I'm missing or misunderstanding.  Thanks for any help!

Alex

Doug Hoard

unread,
Jun 14, 2023, 1:02:53 PM6/14/23
to Prometheus Users
Per Javadoc (https://docs.oracle.com/en/java/javase/17/docs/api/java.management/javax/management/AttributeList.html)

"For compatibility reasons, it is possible, though highly discouraged, to add objects to an AttributeList that are not instances of Attribute"

... but the scraping code is expecting Attributes.

I would say this is not "technically invalid" but doesn't allow processing as written. It would require an exporter code change to process these values.


Reply all
Reply to author
Forward
0 new messages