Monitoring
3.3.4
O2 Monitoring library
|
Monitoring module injects user custom metrics and monitors the process. It supports multiple backends, protocols and data formats.
Click here if you don't have aliBuild installed
Monitoring
and its dependencies via aliBuild
alice
directory) Get
an instance from MonitoringFactory
by passing backend's URI(s) as a parameter (comma separated if more than one). The factory is accessible from o2::monitoring
namespace.
See the table below to find URI
s for supported backends:
Backend name | Transport | URI backend[-protocol] | URI query | Default verbosity |
---|---|---|---|---|
No-op | - | no-op | - | - |
InfluxDB | UDP | influxdb-udp | - | info |
InfluxDB | Unix socket | influxdb-unix | - | info |
InfluxDB | StdOut | influxdb-stdout | - | info |
InfluxDB | Kafka | influxdb-kafka | Kafka topic | info |
InfluxDB 2.x | HTTP | influxdbv2 | org=ORG&bucket=BUCKET&token=TOKEN | info |
ApMon | UDP | apmon | - | info |
StdOut | - | stdout , infologger | [Prefix] | debug |
A metric consist of 5 parameters:
Parameter name | Type | Required | Default |
---|---|---|---|
name | string | yes | - |
values | map<string, int/double/string/uint64_t> | no/1 | - |
timestamp | time_point<system_clock> | no | current time |
verbosity | Enum (Debug/Info/Prod) | no | Verbosity::Info |
tags | map | no | host and process names |
A metric can be constructed by providing required parameters (value and metric name, value name is set to value
):
By default metric can be created with zero or one value (in such case value name is set to value
). Any additional value may be added using .addValue
method, therefore the following two metrics are identical:
Each metric can be tagged with any number of predefined tags. In order to do so use addTag(tags::Key, tags::Value)
or addTag(tags::Key, unsigned short)
methods. The latter method allows assigning numeric value to a tag.
See the example: examples/2-TaggedMetrics.cxx.
Pass metric object to send
method as l-value reference:
See how it works in the example: examples/1-Basic.cxx.
There are 3 verbosity levels (the same as for backends): Debug, Info, Prod. By default it is set to Verbosity::Info
. The default value can be overwritten using: Metric::setDefaultVerbosity(verbosity)
. To overwrite verbosity on per metric basis use third, optional parameter to metric constructor:
Metrics need to match backends verbosity in order to be sent, eg. backend with /info
verbosity will accept Info
and Prod
metrics only.
In order to avoid sending each metric separately, metrics can be temporary stored in the buffer and flushed at the most convenient moment. This feature can be controlled with following two methods:
enableBuffering
takes maximum buffer size as its parameter. The buffer gets full all values are flushed automatically.
See how it works in the example: examples/10-Buffering.cxx.
This feature can calculate derived values. To do so, use optional DerivedMetricMode mode
parameter of send
method:
Two modes are available:
DerivedMetricMode::RATE
- rate between two following values,DerivedMetricMode::INCREMENT
- sum of all passed values.The derived value is generated only from the first value of the metric and it is added to the same metric with the value name suffixed with _rate
, _increment
accordingly.
See how it works in the example: examples/4-RateDerivedMetric.cxx.
Global tags are added to each metric sent using given monitoring instance. hostname
is set as global by default.
You can add your own global tag by calling addGlobalTag(std::string_view key, std::string_view value)
or addGlobalTag(tags::Key, tags::Value)
.
This feature provides basic performance status of the process. Note that is runs in separate thread (without mutex).
Following metrics are generated every time interval: CPU measurements:
Memory measurements: (Linux only)
Additional metrics are generated at the end of process execution: CPU measurements:
Memory measurements: (Linux only)
### StdOut backend output format
The prefix ([METRIC]
) can be changed using query component.
Overwrite metric verbosity using regex expression:
This guide explains manual installation. For ansible
deployment see AliceO2Group/system-configuration gitlab repo.