Skip to content

Commit e2abd9a

Browse files
author
Michal Tichák
committed
fixup! [core] add docs for metrics
1 parent f56354a commit e2abd9a

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

docs/metrics.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,19 +151,22 @@ by appending strings to the name of original field:
151151

152152
### Aggregation
153153

154-
In order to save network bandwidth and RAM usage we are aggregating all metrics.
155-
This aggregation is done by grouping metrics per second intervals based on timestamps
156-
rounded to seconds, measurement name and tags. This aggregating is the same of both
157-
types of metrics. This means that if you send metrics with
158-
same measurement name and tags, but different timestamps (unix in nanoseconds)
159-
but difference under one second all of them will be aggregated into
160-
one bucket, where timestamp is rounded down at seconds.
161-
If either measurement or tags are different, than the metrics
162-
wont' be grouped but every one of these metrics will be separate. If metric
163-
is missing one of the tags compared to the other metrics it won't be aggregated
164-
with the others. Following example describes aggregating different metrics.
165-
Metrics in influxdb line format will be used to demonstrate aggregation
166-
of simple Counter metrics.
154+
To reduce network bandwidth and RAM usage, we aggregate all metrics.
155+
This is done by grouping them into one-second intervals based on:
156+
157+
- Timestamps rounded down to the nearest second
158+
- Measurement name
159+
- Tags
160+
161+
This aggregation method applies to all metric types.
162+
163+
If multiple metrics share the same measurement name and tags but have timestamps
164+
less than one second apart, they will be grouped into a single bucket, using the
165+
timestamp rounded down to the nearest second.
166+
167+
However, if the measurement name or tags differ—even slightly—the metrics
168+
will not be grouped and will remain separate. Also, if a metric is missing
169+
a tag present in the others, it won't be aggregated with them.
167170

168171
```
169172
notaggregated,tag1=val1 fields1=1i 1000000123
@@ -203,7 +206,7 @@ In order to send metrics from unlimited amount of goroutines, we need to have
203206
robust and thread-safe mechanism. It is implemented in [common/monitoring/monitoring.go](../common/monitoring/monitoring.go)
204207
as event loop (`eventLoop`) that reads data from two buffered channels (`metricsChannel` and `metricsHistosChannel`)
205208
with one goroutine. Apart from reading messages from these two channels event loop also handles
206-
scraping requests from `http.Server` endpoint. As the http endpoint is called
209+
scraping requests from `http.Server` endpoint. As the http endpoint is called by a
207210
different goroutine than the one processing event loop, we use another two channels:
208211
`metricsRequestedChannel` which is used by the endpoint to request current metrics.
209212
Transformed metrics are sent via `metricsExportedToRequest` back to the endpoint.

0 commit comments

Comments
 (0)