Metric events - what is the algorithm of summary metrics? #21556
Replies: 3 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. |
Beta Was this translation helpful? Give feedback.
-
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). |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
Hi!
Quote from the page Metric events:
Similar to a histogram, a summary samples observations (usually things like request durations and response sizes). While it also provides a total count of observations and a sum of all observed values, it calculates configurable quantiles over a sliding time window.
What is the algorithm for "sliding time window"?
By a certain number of metrics? Or for a certain time period? Or some other algorithm?
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.
Beta Was this translation helpful? Give feedback.
All reactions