Package org.jmxtrans.agent
Class DiscoveryQuery
java.lang.Object
org.jmxtrans.agent.Query
org.jmxtrans.agent.DiscoveryQuery
- All Implemented Interfaces:
Collector
public class DiscoveryQuery extends Query
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]
NOTE : It can take a few minutes for Zabbix to enable newly created discovery
rules and item prototypes.- Author:
- Steve McDuff
-
Field Summary
Fields inherited from class org.jmxtrans.agent.Query
attributes, key, objectName, position, resultAlias, resultNameStrategy -
Constructor Summary
Constructors Constructor Description DiscoveryQuery(String objectName, List<String> attributes, String key, Integer position, String type, String resultAlias, ResultNameStrategy resultNameStrategy, Integer collectInterval) -
Method Summary
Modifier and Type Method Description voidcollectAndExport(MBeanServer mbeanServer, OutputWriter outputWriter)StringformatDiscoveryValue(String keyProperty)Methods inherited from class org.jmxtrans.agent.Query
getAttributes, getCollectIntervalOverrideOrNull, getKey, getObjectName, getPosition, getResultAlias, getType, toString
-
Constructor Details
-
DiscoveryQuery
-
-
Method Details
-
collectAndExport
- Specified by:
collectAndExportin interfaceCollector- Overrides:
collectAndExportin classQuery
-
formatDiscoveryValue
-