jmxtrans / jmxtrans-agent

Java Agent based JMX metrics exporter.
MIT License
178 stars 110 forks source link

Add support for Zabbix Discovery queries #104

Open dd00f opened 7 years ago

dd00f commented 7 years ago

DiscoveryQuery : Used to discover a list of JMX beans matching a specific naming pattern. Used with the Zabbix server.

For example, the following discovery rule :

<discoveryQuery 
   objectName="java.lang:type=GarbageCollector,name=*" 
   attributes="name,type" 
   resultAlias="discovery[garbageCollector]" 
   collectIntervalInSeconds="300"/>

<query objectName="java.lang:type=GarbageCollector,name=*"
   attributes="CollectionTime,CollectionCount"
   resultAlias="discovery[GarbageCollector.%name%.#attribute#]" />

May yield the following discovery output (formatted for readability) :

{"data":[
  {"{#NAME}":"PS Scavenge","{#TYPE}":"GarbageCollector"},
  {"{#NAME}":"PS MarkSweep","{#TYPE}":"GarbageCollector"}
]}

On the Zabbix side, create a "Discovery Rule" of type "Zabbix trapper" with a "Key" that matches the result alias. You can then create "Item prototypes" that use the values.

Sample Zabbix configuration that matches the example above :

Discovery rule : Name : Discover Garbage Collectors Key : discovery[garbageCollector]

Item Prototype Name : Object {#TYPE} named {#NAME} Key : discovery[{#TYPE}.{#NAME}.CollectionTime]

Item Prototype Name : Object {#TYPE} named {#NAME} Key : discovery[{#TYPE}.{#NAME}.CollectionCount]