Collectors
Decanter collectors harvest the monitoring data, and send this data to the Decanter appenders.
Two kinds of collector are available:
-
Event Driven Collectors react to events and "broadcast" the data to the appenders.
-
Polled Collectors are periodically executed by the Decanter Scheduler. When executed, the collectors harvest the data and send to the appenders.
Log
The Decanter Log Collector is an event driven collector. It automatically reacts when a log occurs, and send the log details (level, logger name, message, etc) to the appenders.
The decanter-collector-log
feature installs the log collector:
karaf@root()> feature:install decanter-collector-log
The log collector doesn’t need any configuration, the installation of the decanter-collector-log feature is enough.
JMX
The Decanter JMX Collector is a polled collector, executed periodically by the Decanter Scheduler.
The JMX collector connects to a JMX MBeanServer (local or remote), and retrieves all attributes of each available MBeans. The JMX metrics (attribute values) are send to the appenders.
The decanter-collector-jmx
feature installs the JMX collector, and a default configuration file:
karaf@root()> feature:install decanter-collector-jmx
This feature brings a etc/org.apache.karaf.decanter.collector.jmx-local.cfg
configuration file containing:
# # Decanter Local JMX collector configuration # # Name/type of the JMX collection type=jmx-local # URL of the JMX MBeanServer. # local keyword means the local platform MBeanServer or you can specify to full JMX URL # like service:jmx:rmi:///jndi/rmi://hostname:port/karaf-instance url=local # Username to connect to the JMX MBeanServer #username=karaf # Password to connect to the JMX MBeanServer #password=karaf # Object name filter to use. Instead of harvesting all MBeans, you can select only # some MBeans matching the object name filter #object.name=org.apache.camel:context=*,type=routes,name=*
This file harvests the data of the local MBeanServer:
-
the
type
property is a name (of your choice) allowing you to easily identify the harvested data -
the
url
property is the MBeanServer to connect. "local" is reserved keyword to specify the local MBeanServer. Instead of "local", you can use the JMX service URL. For instance, for Karaf version 3.0.0, 3.0.1, 3.0.2, and 3.0.3, as the local MBeanServer is secured, you can specifyservice:jmx:rmi:///jndi/rmi://localhost:1099/karaf-root
. You can also polled any remote MBean server (Karaf based or not) providing the service URL. -
the
username
property contains the username to connect to the MBean server. It’s only required if the MBean server is secured. -
the
password
property contains the password to connect to the MBean server. It’s only required if the MBean server is secured. -
the
object.name
property is optional. If this property is not specified, the collector will retrieve the attributes of all MBeans. You can filter to consider only some MBeans. This property contains the ObjectName filter to retrieve the attributes only to some MBeans.
You can retrieve multiple MBean servers. For that, you just create a new configuration file using the file name format
etc/org.apache.karaf.decanter.collector.jmx-[ANYNAME].cfg
.
ActiveMQ (JMX)
The ActiveMQ JMX collector is just a special configuration of the JMX collector.
The decanter-collector-activemq
feature installs the default JMX collector, with the specific ActiveMQ JMX configuration:
karaf@root()> feature:install decanter-collector-activemq
This feature installs the same collector as the decanter-collector-jmx
, but also add the
etc/org.apache.karaf.decanter.collector.jmx-activemq.cfg
configuration file.
This file contains:
# # Decanter Local ActiveMQ JMX collector configuration # # Name/type of the JMX collection type=jmx-activemq # URL of the JMX MBeanServer. # local keyword means the local platform MBeanServer or you can specify to full JMX URL # like service:jmx:rmi:///jndi/rmi://hostname:port/karaf-instance url=local # Username to connect to the JMX MBeanServer #username=karaf # Password to connect to the JMX MBeanServer #password=karaf # Object name filter to use. Instead of harvesting all MBeans, you can select only # some MBeans matching the object name filter object.name=org.apache.activemq:*
This configuration actually contains a filter to retrieve only the ActiveMQ JMX MBeans.
Camel (JMX)
The Camel JMX collector is just a special configuration of the JMX collector.
The decanter-collector-camel
feature installs the default JMX collector, with the specific Camel JMX configuration:
karaf@root()> feature:install decanter-collector-camel
This feature installs the same collector as the decanter-collector-jmx
, but also add the
etc/org.apache.karaf.decanter.collector.jmx-camel.cfg
configuration file.
This file contains:
# # Decanter Local Camel JMX collector configuration # # Name/type of the JMX collection type=jmx-camel # URL of the JMX MBeanServer. # local keyword means the local platform MBeanServer or you can specify to full JMX URL # like service:jmx:rmi:///jndi/rmi://hostname:port/karaf-instance url=local # Username to connect to the JMX MBeanServer #username=karaf # Password to connect to the JMX MBeanServer #password=karaf # Object name filter to use. Instead of harvesting all MBeans, you can select only # some MBeans matching the object name filter object.name=org.apache.camel:context=*,type=routes,name=*
This configuration actually contains a filter to retrieve only the Camel Routes JMX MBeans.
Camel Tracer
The Camel Tracer provides a Camel Tracer Handler that you can set on a Camel Tracer.
If you enable the tracer on a Camel route, all tracer events (exchanges on each step of the route) are send to the appenders.
The decanter-collector-camel-tracer
feature provides the Camel Tracer Handler:
karaf@root()> feature:install decanter-collector-camel-tracer
Now, you can use the Decanter Camel Tracer Handler in a tracer that you can use in routes.
For instance, the following route definition shows how to enable tracer on a route, and use the Decanter Tracer Handler in the Camel Tracer:
<?xml version="1.0" encoding="UTF-8"?> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> <reference id="eventAdmin" interface="org.osgi.service.event.EventAdmin"/> <bean id="traceHandler" class="org.apache.karaf.decanter.collector.camel.DecanterTraceEventHandler"> <property name="eventAdmin" ref="eventAdmin"/> </bean> <bean id="tracer" class="org.apache.camel.processor.interceptor.Tracer"> <property name="traceHandler" ref="traceHandler"/> <property name="enabled" value="true"/> <property name="traceOutExchanges" value="true"/> <property name="logLevel" value="OFF"/> </bean> <camelContext trace="true" xmlns="http://camel.apache.org/schema/blueprint"> <route id="test"> <from uri="timer:fire?period=10000"/> <setBody><constant>Hello World</constant></setBody> <to uri="log:test"/> </route> </camelContext> </blueprint>
System
The system collector is a polled collector (periodically executed by the Decanter Scheduler).
This collector executes operating system commands (or scripts) and send the execution output to the appenders.
The decanter-collector-system
feature installs the system collector:
karaf@root()> feature:install decanter-collector-system
This feature installs a default etc/org.apache.karaf.decanter.collector.system.cfg
configuration file containing:
# # Decanter OperationSystem Collector configuration # # This collector executes system commands, retrieve the exec output/err # sent to the appenders # # The format is key=command # for instance: # df=df -h # free=free # You can also create a script containing command like: # # df -k / | awk -F " |%" '/dev/{print $8}' # # This script will get the available space on the / filesystem for instance. # and call the script: # df=/bin/script # # Another example of script to get the temperature: # # sensors|grep temp1|awk '{print $2}'|cut -b2,3,4,5 #
You can add the commands that you want to execute using the format:
name=command
The collector will execute each command described in this file, and send the execution output to the appenders.
For instance, if you want to periodically send the free space available on the / filesystem, you can add:
df=df -k / | awk -F " |%" '/dev/{print $8}'