Repository navigation
Metric events - what is the algorithm of summary metrics? #21556
|
Hi! Quote from the page Metric events: What is the algorithm for "sliding time window"? I tried to analyze the source code and found the "entry point" in file \vector-master\src\sinks\prometheus\collector.rs where quantiles are calculated. But I don't have enough experience to understand how and where the "samples" array is formed. Please tell me the complete sampling algorithm. |
Replies: 5 comments 8 replies
|
Hey! When converting a Prometheus distribution into an internal Vector "Summary" metric, there are no samples. There are just the summary statistics: count, sum, min, max, and quantiles. See https://github.com/prometheus/docs/blob/main/content/docs/instrumenting/exposition_formats.md#histograms-and-summaries for details on how Prometheus serializes histograms. |
|
Hey! Did I understand correctly from the answer that the above-mentioned documentation Vector "Metric events" contains an error, and there is no "sliding time window", and the statistics are calculated for the entire available period? If I understood correctly, then in my opinion this is incorrect, and quantiles for export to Prometheus must be calculated in the vector for a configurable time interval or for a specified number of values. I will provide a translation of an excerpt from the article: Usually for metrics we sample data, that is, from the entire set we select only some elements in order to calculate percentiles and other properties from them. How to select a finite number of elements from an infinite series of data? You will have to sacrifice something, there are different algorithms for this. We store, for example, up to 100 elements, and when we need to write a new one, we decide which element to throw out:
Otherwise, it turns out that Max always increases (and never decreases), Min always decreases (and never increases), and the quantiles themselves are always averaged over the entire available range. And one of the purposes of this type of metrics is a visual representation of the query execution time, which should change quickly (for example, over the last 5 minutes, but not for the entire available history). |
|
Please tell me, why do we need to know the "average temperature in the hospital"? Main thoughts:
That is, when calculating the summary metrics, there must be one more parameter - a sliding time window, as it is implemented in the same Prmetheus client. Otherwise it doesn't make any practical sense. |
|
hello. I too use log-to-metric and I believe the histogram needs a sliding time window. I wanted to get a latency histogram for a specific api from nginx logs, which can be implemented via bucket, but also via summary type. I want to use the summary type to reduce the load on the metrics system, and simply see the p95 stats for each pod. So I initially tried to use the summary type in vector, but after realizing that it gives stats for the entire time period, I ended up using the method via bucket, which is semantically more correct, but also has the problem of creating too many series in some cases. Perhaps people who use the summary type would like to get stats over a period of time, and a feature toggle would be a good way to give them a choice. |
|
For With
The I verified this locally with For latency percentiles over the last five minutes, histograms queried over a time range are an option today. Please open a feature request for a configurable sliding window for summaries. |
For
log_to_metric→prometheus_exporter, there is no sliding observation window in Vector 0.60.0. An active series keeps accumulating observations.With
distributions_as_summaries: true, the path is:log_to_metricemits one distribution sample for each valid input value, with a count of 1.flush_period_secsexpires inactive series as a whole. It does not remove old observations from a series that keeps receiving updates.The
from_samplesfunction you found calculates statistics fro…