Monitoring Petals ESB with Prometheus

compared with
Version 5 by Pierre Souquet
on Sep 27, 2018 17:24.

Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (22)

View Page History
* Prometheus can make extensive use of *labels* through queries to determine *metrics* sources. Think about your needs when designing your labels, more explanations on [the official documentation|https://prometheus.io/docs/concepts/data_model/] or [this blog post.|https://pierrevincent.github.io/2017/12/prometheus-blog-series-part-1-metrics-and-labels/]
* Metrics can be typed (conceptually, as gauge, counter or histogram) for Prometheus to know how to handle them. More details on the [official documentation|https://prometheus.io/docs/concepts/metric_types/].
* Metrics format: {code}<metric name>{<label name>=<label value>, ...}{code}

Rule samples :
The following samples are produced monitoring a Petals ESB single container topology hosting 3 components (SOAP, REST and Camel).
Raw metrics can be hard to exploit, as the exporter automatically creates metrics:
Raw metrics sample:
{code}
# metric: java.lang<type=OperatingSystem><>SystemCpuLoad
java_lang_OperatingSystem_SystemCpuLoad 0.10240228944418933

# metric: java.lang<type=OperatingSystem><>ProcessCpuLoad
java_lang_OperatingSystem_ProcessCpuLoad 3.158981547513337E-4

# metrics: org.ow2.petals<type=custom, name=monitoring_petals-(se-camel | bc-soap | bc-rest)><>MessageExchangeProcessorThreadPoolQueuedRequestsMax)
org_ow2_petals_custom_MessageExchangeProcessorThreadPoolQueuedRequestsMax{name="monitoring_petals-se-camel",} 0.0
org_ow2_petals_custom_MessageExchangeProcessorThreadPoolQueuedRequestsMax{name="monitoring_petals-bc-soap",} 0.0
org_ow2_petals_custom_MessageExchangeProcessorThreadPoolQueuedRequestsMax{name="monitoring_petals-bc-rest",} 0.0
{code}

In this case, we cannot know later in Prometheus where the metrics originated or which Petals ESB container is concerned. By adding a few generic rules, we can add label and control the metric names:

Generic rules samples :
{code}
rules:
- pattern: 'java.lang<type=Runtime, key=java.runtime.name><>SystemProperties: 'java.lang<type=(.*)><>(.*): (.*)'
name: aaaa_test "$2"
value: 1 "$3"
labels:
runtime: type: "$1"
target: "system"
container: "petals_sample_0"

- pattern: '(.*)<(.*)><(.*)>(.*)'
- pattern: 'org.ow2.petals<type=custom, name=monitoring_(.+)><>(.+): (.+)'
name: "$2"
value: "$3"
labels:
type: "monitoring"
container: "petals_sample_0"
component: "$1"

- pattern: 'org.ow2.petals<type=custom, name=runtime_configuration_(.+)><>(.+): (.+)'
name: "$2"
value: "$3"
labels:
type: "runtime_config"
container: "petals_sample_0"
component: "$1"
{code}

Metrics parsed by generic rules :
{code}
ProcessCpuLoad{container="petals_sample_0",target="system",type="OperatingSystem",} 2.5760609293017057E-4
SystemCpuLoad{container="petals_sample_0",target="system",type="OperatingSystem",} 0.10177234194298118

MessageExchangeProcessorThreadPoolQueuedRequestsMax{component="petals-bc-soap",container="petals_sample_0",type="monitoring",} 0.0
MessageExchangeProcessorThreadPoolQueuedRequestsMax{component="petals-se-camel",container="petals_sample_0",type="monitoring",} 0.0
MessageExchangeProcessorThreadPoolQueuedRequestsMax{component="petals-bc-rest",container="petals_sample_0",type="monitoring",} 0.0
{code}

And you can go further by adding rules for specific MBeans:
{code}
- pattern: 'java.lang<type=OperatingSystem><>SystemCpuLoad: (.*)'
name: aaaa_petals_test CpuLoad
value: 1 "$1"
labels:
mouais: "$1 $2 $3 $3" type: "OperatingSystem"
target: "system"
container: "petals_sample_0"

- pattern: '(\w+)<type=(\w+), name=(\w+)><>Value: (\w+)' 'java.lang<type=OperatingSystem><>ProcessCpuLoad: (.*)'
name: $1_$2_$3 CpuLoad
value: 1 "$1"
help: "$1 metric $2 $3"
labels:
value: "$3: $4" tpye: OperatingSystem
target: "process"
container: "petals_sample_0"

- pattern: 'org.ow2.petals<type=custom, name=monitoring_(.+)><>MessageExchangeProcessorThreadPoolQueuedRequestsMax: (.+)'
name: "MEPTP_QueuedRequests_Max"
value: "$2"
help: "MessageExchangeProcessorThreadPoolQueuedRequestsMax"
labels:
type: "monitoring"
mbean: "MessageExchangeProcessorThreadPoolQueuedRequestsMax"
container: "petals_sample_0"
component: "$1"
{code}

Metrics parsed by advanced rules :
{code}
CpuLoad{container="petals_sample_0",target="system",type="OperatingSystem",} 0.10234667681404555
CpuLoad{container="petals_sample_0",target="process",tpye="OperatingSystem",} 2.655985589352835E-4

MEPTP_QueuedRequests_Max{component="petals-bc-soap",container="petals_sample_0",mbean="MessageExchangeProcessorThreadPoolQueuedRequestsMax",type="monitoring",} 0.0
MEPTP_QueuedRequests_Max{component="petals-se-camel",container="petals_sample_0",mbean="MessageExchangeProcessorThreadPoolQueuedRequestsMax",type="monitoring",} 0.0
MEPTP_QueuedRequests_Max{component="petals-bc-rest",container="petals_sample_0",mbean="MessageExchangeProcessorThreadPoolQueuedRequestsMax",type="monitoring",} 0.0
{code}

You can mix generic and specific patterns, but remember that they are applied in order, so *always put specific rules first !*