just4est / jmxtrans

Automatically exported from code.google.com/p/jmxtrans
0 stars 0 forks source link

fix monitoring multiple MBeans from a single ObjectName query #13

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
In a lot of applications, MBeans are created dynamically for each instances 
(e.g. web app in Tomcat, queues in ActiveMQ).

To make them monitorable in Graphite (or other output write) we need: 
1. be able to query all of these MBeans with an ObjectName query
2. identify uniquely the managed resources using their ObjectNames.

There is a defect in jmxtrans in JmxUtils: it does not specify exactly the 
managed resources before writing to the ouput writer.
If the query is an ObjectName query with a * wildcard, all the queries will use 
the same name making it impossible to display all the resources.

To fix this, I have patched JmxUtils.
If the mbeanServer.queryNames() operations returns more than a single 
ObjectName, we set the query result alias to the resource ObjectName (escaping 
characters that are misinterpreted by graphite).

With this fix, I am able to manage HornetQ Topics with a single wildcard query:

"obj" : "org.hornetq:module=JMS,type=Topic,*",
"attr" : [ 
   "MessagesAdded",
   "MessageCount"
]

and still be able to monitor every topic individually (and dynamically) in 
Graphite with a display like that:

hornetq
  localhost
    org_hornetq:module=JMS_type=Topic_name=_topic1_
      MessagesCount
      MessagesAdded
    org_hornetq:module=JMS_type=Topic_name=_topic2_
      MessagesCount
      MessagesAdded
    org_hornetq:module=JMS_type=Topic_name=_topic3_
      MessagesCount
      MessagesAdded

This patch is very important for us since in our app, JMS topics and queues are 
created dynamically and we don't want to have to explicitely configure them in 
the jmxtrans configuration.

Original issue reported on code.google.com by jmes...@gmail.com on 14 Oct 2011 at 8:38

Attachments:

GoogleCodeExporter commented 8 years ago
Have you tried using typeNames? I believe that should resolve this issue for 
you. It allows you to select out the unique parts of the queries so that the 
fields are generated in a unique way.

I'm sorry it isn't better documented, but it is a hard concept to explain...

http://code.google.com/p/jmxtrans/wiki/Queries

and another example of it documented:

http://code.google.com/p/jmxtrans/wiki/KeyOutWriter

Original comment by latch...@gmail.com on 14 Oct 2011 at 4:44

GoogleCodeExporter commented 8 years ago
Thanks for the pointers on typeNames. I did not notice it when I looked at the 
examples.
It's exactly what I needed.

cheers,
jeff

Original comment by jmes...@gmail.com on 17 Oct 2011 at 3:34

GoogleCodeExporter commented 8 years ago

Original comment by latch...@gmail.com on 17 Oct 2011 at 4:20