You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| timestamp | time_point<system_clock> | no | current time |
68
67
| verbosity | Enum (Debug/Info/Prod) | no | Verbosity::Info |
69
-
| tags |vector<unsignedint>| no | host and process names |
68
+
| tags | map | no | host and process names |
70
69
71
-
A metric can be constructed by providing required parameters (value and name):
70
+
A metric can be constructed by providing required parameters (value and metric name, value name is set to `value`):
72
71
```cpp
73
72
Metric{10, "name"}
74
73
```
75
-
76
-
#### Verbosity
77
-
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)`.
78
-
To overwrite verbosity on per metric basis use third, optional parameter to metric constructor:
74
+
#### Values
75
+
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:
79
76
```cpp
80
-
Metric{10, "name", Verbosity::Prod}
77
+
Metric{10, "name"}
78
+
Metric{"name"}.addValue(10, "value")
81
79
```
82
80
83
-
Metrics need to match backends verbosity in order to be sent, eg. backend with `/info` verbosity will accept `Info` and `Prod` metrics only.
84
-
85
81
#### Tags
86
82
Each metric can be tagged with any number of [predefined tags](include/Monitoring/Tags.h).
87
83
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 how it works in the example: [examples/1-Basic.cxx](examples/1-Basic.cxx).
98
100
99
101
## Advanced features
100
102
101
-
### Sending more than one metric
102
-
In order to send more than one metric in a packet group them into vector:
103
-
```cpp
104
-
monitoring->send(std::vector<Metric>&& metrics);
105
-
```
106
-
107
-
It's also possible to send multiple, grouped values (`InfluxDB` backends are supported); For example `cpu` metric can be composed of `cpuUser`, `cpuSystem` values.
103
+
### Metric verbosity
104
+
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)`.
105
+
To overwrite verbosity on per metric basis use third, optional parameter to metric constructor:
See how it works in the example: [examples/10-Buffering.cxx](examples/10-Buffering.cxx).
126
124
127
-
### Calculating derived metrics
128
-
The module can calculate derived metrics. To do so, use optional `DerivedMetricMode mode` parameter of `send` method:
125
+
### Calculating derived values
126
+
This feature can calculate derived values. To do so, use optional `DerivedMetricMode mode` parameter of `send` method:
129
127
```
130
128
send(Metric&& metric, [DerivedMetricMode mode])
131
129
```
132
130
133
-
Three modes are available:
134
-
+`DerivedMetricMode::NONE` - no action,
135
-
+`DerivedMetricMode::RATE` - rate between two following metrics,
136
-
+`DerivedMetricMode::AVERAGE` - average value of all metrics stored in cache.
131
+
Two modes are available:
132
+
+ `DerivedMetricMode::RATE` - rate between two following values,
133
+
+ `DerivedMetricMode::INCREMENT` - sum of all passed values.
137
134
138
-
Derived metrics are generated each time as new value is passed to the module. Their names are suffixed with derived mode name.
135
+
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.
139
136
140
137
See how it works in the example: [examples/4-RateDerivedMetric.cxx](examples/4-RateDerivedMetric.cxx).
141
138
142
139
### Global tags
143
-
Global tags are added to each metric. Two tags: `hostname` and `name` (process name) are set as global by the library.
140
+
Global tags are added to each metric sent using given monitoring instance. Two tags: `hostname` and `name` (process name) are set as global by default.
144
141
145
142
You can add your own global tag by calling `addGlobalTag(std::string_view key, std::string_view value)` or `addGlobalTag(tags::Key, tags::Value)`.
146
143
147
144
### Process monitoring
145
+
146
+
This feature provides basic performance status of the process. Note that is runs in separate thread (without mutex).
147
+
148
148
```cpp
149
149
enableProcessMonitoring([interval in seconds]);
150
150
```
@@ -153,16 +153,14 @@ The following metrics are generated every interval:
153
153
+**involuntaryContextSwitches** - involuntary context switches over time interval
154
154
+**memoryUsagePercentage** - ratio of the process's resident set size to the physical memory on the machine, expressed as a percentage (Linux only)
155
155
156
-
### Automatic metric updates
157
-
Sometimes it's necessary to provide value every exact interval of time (even though value does not change). This can be done using `AutoPushMetric`.
0 commit comments