@@ -13,38 +13,6 @@ Monitoring module allows to inject user defined metrics and monitor the process
13135 . [ System monitoring and server-side backends installation and configuration] ( #system-monitoring-server-side-backends-installation-and-configuration )
1414
1515## Installation
16- ### RPM (CentOS 7 only)
17- + Install CERN certificates
18- ~~~
19- yum -y install CERN-CA-certs
20- ~~~
21-
22- + Add ` alisw ` repo ** (as root)**
23- ~~~
24- cat > /etc/yum.repos.d/alisw-el7.repo <<EOF
25- [alisw-el7]
26- name=ALICE Software - EL7
27- baseurl=https://ali-ci.cern.ch/repo/RPMS/el7.x86_64/
28- enabled=1
29- gpgcheck=0
30- EOF
31- ~~~
32-
33- + Install Monitoring RPM package ** (as root)**
34- ~~~
35- yum -y install alisw-Monitoring+v1.5.4-1.x86_64
36- ~~~
37-
38- + Configure Modules
39- ~~~
40- export MODULEPATH=/opt/alisw/el7/modulefiles:$MODULEPATH
41- ~~~
42-
43- + Load enviroment
44- ~~~
45- eval `modulecmd bash load Monitoring/v1.5.4-1`
46- ~~~
47- The installation directory is: ` /opt/alisw/el7/Monitoring/v1.5.4-1 `
4816
4917### aliBuild
5018<strong >[ Click here if you don't have aliBuild installed] ( https://alice-doc.github.io/alice-analysis-tutorial/building/ ) </strong >
@@ -76,13 +44,13 @@ Manual installation of the O<sup>2</sup> Monitoring module.
7644
7745#### Monitoring module compilation
7846
79- ~~~
47+ ```
8048git clone https://github.com/AliceO2Group/Monitoring.git
8149cd Monitoring; mkdir build; cd build
8250cmake .. -DCMAKE_INSTALL_PREFIX=<installdir>
8351make -j
8452make install
85- ~~~
53+ ```
8654
8755## Getting started
8856### Monitoring instance
@@ -94,6 +62,7 @@ The library is accessible from `o2::monitoring` namespace.
9462using namespace o2 ::monitoring;
9563std::unique_ptr<Monitoring > monitoring = MonitoringFactory::Get("backend[ -protocol] ://host: port [ /verbosity] [ ?query] ");
9664```
65+
9766See table below to find out how to create `URI` for each backend:
9867
9968| Backend name | Transport | URI backend[-protocol] | URI query | Default verbosity |
@@ -117,12 +86,10 @@ Where metric constructor receives following parameters:
11786 - ` std::string& name `
11887 - ` [time_point<system_clock> timestamp] `
11988
120- For example:
121- ``` cpp
122- monitoring->send ({10, "myMetricInt"});
123- ```
12489
125- Regarding `DerivedMetricMode` see [Calculating derived metrics](#calculating-derived-metrics).
90+ The ` DerivedMetricMode ` is described in [ Calculating derived metrics] ( #calculating-derived-metrics ) section.
91+
92+ See how it works in the example: [ examples/1-Basic.cxx] ( examples/1-Basic.cxx )
12693
12794### Debug metrics
12895Debug metrics can be send by a similar method to above's ` send ` :
@@ -142,25 +109,23 @@ Two additional methods can be chained the to `send(Metric&& metric)` in order to
142109 + `addTags(std::vector<Tag>&& tags)`
143110 + `setTimestamp(std::chrono::time_point<std::chrono::system_clock>& timestamp)`
144111
145- For example:
146- ``` cpp
147- monitoring->send (Metric{10, "myMetric"}.addTags({{"tag1", "value1"}, {"tag2", "value2"}}));
148- monitoring->send(Metric{10, "myCrazyMetric"}.setTimestamp(timestamp));
149- ```
112+ See how it works in the example: [examples/2-TaggedMetrics.cxx](examples/2-TaggedMetrics.cxx), [examples/3-UserDefinedTimestamp.cxx](examples/3-UserDefinedTimestamp.cxx).
150113
151114## Features and additional information
152115
153- ### Grouped values
154- It's also possible to send multiple, grouped values in a single metric (`Flume` and `InfluxDB` backends are supproted, others fallback into sending values in seperate metrics)
116+ ### Sending more than one metric
117+ In order to send more than one metric in a packet group them into vector:
155118```cpp
156- void sendGroupped (std::string name, std:: vector<Metric>&& metrics)
119+ monitoring->send (std::vector<Metric>&& metrics);
157120```
158121
159- For example:
122+ It's also possible to send multiple, grouped values (only ` Flume ` and ` InfluxDB ` backends are supported); For example ` cpu ` metric can be composed of ` cpuUser ` , ` cpuSystem ` values.
160123``` cpp
161- monitoring-> sendGroupped ("measurementName", {{20, "myMetricIntMultiple"}, {20.30, "myMetricFloatMultple"}});
124+ void sendGroupped (std::string name, std::vector< Metric >&& metrics)
162125```
163126
127+ See how it works in the example: [examples/8-Multiple.cxx](examples/8-Multiple.cxx)
128+
164129### Buffering metrics
165130In order to avoid sending each metric separately, metrics can be temporary stored in the buffer and flushed at the most convenient moment.
166131This feature can be operated with following two methods:
@@ -172,15 +137,7 @@ monitoring->flushBuffer();
172137
173138` enableBuffering ` takes maximum buffer size as its parameter. The buffer gets full all values are flushed automatically.
174139
175- For example:
176- ``` cpp
177- monitoring->enableBuffering (5);
178- for (int i = 1; i < 10; i++) {
179- monitoring->send({10, "myMetricInt"});
180- }
181- monitoring->send({20, "myMetricInt2"});
182- monitoring->flushBuffer();
183- ```
140+ See how it works in the example: [ examples/10-Buffering.cxx] ( examples/10-Buffering.cxx ) .
184141
185142### Metrics
186143Metrics consist of 4 parameters: name, value, timestamp and tags.
@@ -205,6 +162,8 @@ The module can calculate derived metrics. To do so, use optional `DerivedMetricM
205162
206163Derived metrics are generated each time as new value is passed to the module. Their names are suffixed with derived mode name.
207164
165+ See how it works in the example: [ examples/4-RateDerivedMetric.cxx] ( examples/4-RateDerivedMetric.cxx ) .
166+
208167### Global tags
209168Glabal tags are tags that are added to each metric. The following tags are set to global by library itself:
210169- ` hostname `
@@ -221,14 +180,13 @@ The following metrics are generated every interval:
221180+ **involuntaryContextSwitches** - involuntary context switches over time interval
222181+ **memoryUsagePercentage** - ratio of the process's resident set size to the physical memory on the machine, expressed as a percentage (Linux only)
223182
224- ## Code snippets
225- Code snippets are available in [ examples] ( examples/ ) directory.
226-
227- + Sending metric - [ examples/1-Basic.cxx] ( examples/1-Basic.cxx )
228- + Sending metric with custom taggs - [ examples/2-TaggedMetrics.cxx] ( examples/2-TaggedMetrics.cxx )
229- + Sending metric with user defined timestamp - [ examples/3-UserDefinedTimestamp.cxx] ( examples/3-UserDefinedTimestamp.cxx )
230- + Calculating derived metrics - [ examples/4-RateDerivedMetric.cxx] ( examples/4-RateDerivedMetric.cxx )
231- + Sending multiple values in a single metric - [ examples/8-Multiple.cxx] ( examples/8-Multiple.cxx )
183+ ### Automatic metric updates
184+ When global, higher level metrics are created it's necessary to provide values every interval of time (even though values does not change). This can be done using `AutoPushMetric`. The
185+ ```cpp
186+ Metric& metric = monitoring->getAutoPushMetric("exampleMetric");
187+ metric = 10;
188+ ```
189+ See how it works in the example: [ examples/11-AutoUpdate.cxx] ( examples/11-AutoUpdate.cxx ) .
232190
233191## System monitoring, server-side backends installation and configuration
234192This guide explains manual installation. For ` ansible ` deployment see [ AliceO2Group/system-configuration] ( https://gitlab.cern.ch/AliceO2Group/system-configuration/tree/master/ansible ) gitlab repo.
0 commit comments