Ganglia
Since Camel 2.15
Only producer is supported
Provides a mechanism to send a value (the message body) as a metric to the Ganglia monitoring system. Uses the gmetric4j library. Can be used in conjunction with standard Ganglia and JMXetric for monitoring metrics from the OS, JVM and business processes through a single platform.
You should have a Ganglia gmond agent running on the machine where your JVM runs. The gmond sends a heartbeat to the Ganglia infrastructure, camel-ganglia can’t send the heartbeat itself currently.
On most Linux systems (Debian, Ubuntu, Fedora and RHEL/CentOS with EPEL) you can just install the Ganglia agent package and it runs automatically using multicast configuration. You can configure it to use regular UDP unicast if you prefer.
Configuring Options
Camel components are configured on two separate levels:
-
component level
-
endpoint level
Configuring Component Options
The component level is the highest level which holds general and common configurations that are inherited by the endpoints. For example a component may have security settings, credentials for authentication, urls for network connection and so forth.
Some components only have a few options, and others may have many. Because components typically have pre configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.
Configuring components can be done with the Component DSL, in a configuration file (application.properties|yaml), or directly with Java code.
Configuring Endpoint Options
Where you find yourself configuring the most is on endpoints, as endpoints often have many options, which allows you to configure what you need the endpoint to do. The options are also categorized into whether the endpoint is used as consumer (from) or as a producer (to), or used for both.
Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL as a type safe way of configuring endpoints.
A good practice when configuring options is to use Property Placeholders, which allows to not hardcode urls, port numbers, sensitive information, and other settings. In other words placeholders allows to externalize the configuration from your code, and gives more flexibility and reuse.
The following two sections lists all the options, firstly for the component followed by the endpoint.
Component Options
The Ganglia component supports 15 options, which are listed below.
Name | Description | Default | Type |
---|---|---|---|
dmax (producer) |
Minumum time in seconds before Ganglia will purge the metric value if it expires. Set to 0 and the value will remain in Ganglia indefinitely until a gmond agent restart. |
int |
|
groupName (producer) |
The group that the metric belongs to. |
java |
String |
lazyStartProducer (producer) |
Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. |
boolean |
|
metricName (producer) |
The name to use for the metric. |
metric |
String |
mode (producer) |
Send the UDP metric packets using MULTICAST or UNICAST. Enum values:
|
MULTICAST |
UDPAddressingMode |
prefix (producer) |
Prefix the metric name with this string and an underscore. |
String |
|
slope (producer) |
The slope. Enum values:
|
BOTH |
GMetricSlope |
spoofHostname (producer) |
Spoofing information IP:hostname. |
String |
|
tmax (producer) |
Maximum time in seconds that the value can be considered current. After this, Ganglia considers the value to have expired. |
60 |
int |
ttl (producer) |
If using multicast, set the TTL of the packets. |
5 |
int |
type (producer) |
The type of value. Enum values:
|
STRING |
GMetricType |
units (producer) |
Any unit of measurement that qualifies the metric, e.g. widgets, litres, bytes. Do not include a prefix such as k (kilo) or m (milli), other tools may scale the units later. The value should be unscaled. |
String |
|
wireFormat31x (producer) |
Use the wire format of Ganglia 3.1.0 and later versions. Set this to false to use Ganglia 3.0.x or earlier. |
true |
boolean |
autowiredEnabled (advanced) |
Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. |
true |
boolean |
configuration (advanced) |
To use the shared configuration. |
GangliaConfiguration |
Endpoint Options
The Ganglia endpoint is configured using URI syntax:
ganglia:host:port
with the following path and query parameters:
Path Parameters (2 parameters)
Name | Description | Default | Type |
---|---|---|---|
host (producer) |
Host name for Ganglia server. |
239.2.11.71 |
String |
port (producer) |
Port for Ganglia server. |
8649 |
int |
Query Parameters (13 parameters)
Name | Description | Default | Type |
---|---|---|---|
dmax (producer) |
Minumum time in seconds before Ganglia will purge the metric value if it expires. Set to 0 and the value will remain in Ganglia indefinitely until a gmond agent restart. |
int |
|
groupName (producer) |
The group that the metric belongs to. |
java |
String |
lazyStartProducer (producer) |
Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. |
boolean |
|
metricName (producer) |
The name to use for the metric. |
metric |
String |
mode (producer) |
Send the UDP metric packets using MULTICAST or UNICAST. Enum values:
|
MULTICAST |
UDPAddressingMode |
prefix (producer) |
Prefix the metric name with this string and an underscore. |
String |
|
slope (producer) |
The slope. Enum values:
|
BOTH |
GMetricSlope |
spoofHostname (producer) |
Spoofing information IP:hostname. |
String |
|
tmax (producer) |
Maximum time in seconds that the value can be considered current. After this, Ganglia considers the value to have expired. |
60 |
int |
ttl (producer) |
If using multicast, set the TTL of the packets. |
5 |
int |
type (producer) |
The type of value. Enum values:
|
STRING |
GMetricType |
units (producer) |
Any unit of measurement that qualifies the metric, e.g. widgets, litres, bytes. Do not include a prefix such as k (kilo) or m (milli), other tools may scale the units later. The value should be unscaled. |
String |
|
wireFormat31x (producer) |
Use the wire format of Ganglia 3.1.0 and later versions. Set this to false to use Ganglia 3.0.x or earlier. |
true |
boolean |
Message body
Any value (such as a string or numeric type) in the body is sent to the Ganglia system.
Return value / response
Ganglia sends metrics using unidirectional UDP or multicast. There is no response or change to the message body.
Examples
Sending a String metric
The message body will be converted to a String and sent as a metric value. Unlike numeric metrics, String values can’t be charted but Ganglia makes them available for reporting. The os_version string at the top of every Ganglia host page is an example of a String metric.
from("direct:string.for.ganglia")
.setHeader(GangliaConstants.METRIC_NAME, simple("my_string_metric"))
.setHeader(GangliaConstants.METRIC_TYPE, GMetricType.STRING)
.to("direct:ganglia.tx");
from("direct:ganglia.tx")
.to("ganglia:239.2.11.71:8649?mode=MULTICAST&prefix=test");
Sending a numeric metric
from("direct:value.for.ganglia")
.setHeader(GangliaConstants.METRIC_NAME, simple("widgets_in_stock"))
.setHeader(GangliaConstants.METRIC_TYPE, GMetricType.UINT32)
.setHeader(GangliaConstants.METRIC_UNITS, simple("widgets"))
.to("direct:ganglia.tx");
from("direct:ganglia.tx")
.to("ganglia:239.2.11.71:8649?mode=MULTICAST&prefix=test");
Spring Boot Auto-Configuration
When using ganglia with Spring Boot make sure to use the following Maven dependency to have support for auto configuration:
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-ganglia-starter</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
The component supports 16 options, which are listed below.
Name | Description | Default | Type |
---|---|---|---|
camel.component.ganglia.autowired-enabled |
Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. |
true |
Boolean |
camel.component.ganglia.configuration |
To use the shared configuration. The option is a org.apache.camel.component.ganglia.GangliaConfiguration type. |
GangliaConfiguration |
|
camel.component.ganglia.dmax |
Minumum time in seconds before Ganglia will purge the metric value if it expires. Set to 0 and the value will remain in Ganglia indefinitely until a gmond agent restart. |
0 |
Integer |
camel.component.ganglia.enabled |
Whether to enable auto configuration of the ganglia component. This is enabled by default. |
Boolean |
|
camel.component.ganglia.group-name |
The group that the metric belongs to. |
java |
String |
camel.component.ganglia.lazy-start-producer |
Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. |
false |
Boolean |
camel.component.ganglia.metric-name |
The name to use for the metric. |
metric |
String |
camel.component.ganglia.mode |
Send the UDP metric packets using MULTICAST or UNICAST |
GMetric$UDPAddressingMode |
|
camel.component.ganglia.prefix |
Prefix the metric name with this string and an underscore. |
String |
|
camel.component.ganglia.slope |
The slope |
GMetricSlope |
|
camel.component.ganglia.spoof-hostname |
Spoofing information IP:hostname |
String |
|
camel.component.ganglia.tmax |
Maximum time in seconds that the value can be considered current. After this, Ganglia considers the value to have expired. |
60 |
Integer |
camel.component.ganglia.ttl |
If using multicast, set the TTL of the packets |
5 |
Integer |
camel.component.ganglia.type |
The type of value |
GMetricType |
|
camel.component.ganglia.units |
Any unit of measurement that qualifies the metric, e.g. widgets, litres, bytes. Do not include a prefix such as k (kilo) or m (milli), other tools may scale the units later. The value should be unscaled. |
String |
|
camel.component.ganglia.wire-format31x |
Use the wire format of Ganglia 3.1.0 and later versions. Set this to false to use Ganglia 3.0.x or earlier. |
true |
Boolean |