![i understand i understand](https://i.ytimg.com/vi/dWLboD2nDMk/maxresdefault.jpg)
#I understand series#
It selects raw samples for the counter time series on the time range (t-d.Prometheus calculates rate(counter) at timestamp t in the following way: Increase(counter) will return (v5 - v1) / (t5 - t1) * 5, so the rate of increase over ~4 seconds, extrapolated to 5 seconds.ĭue to the samples not being exactly spaced, both rate and increase will often return floating point values for integer counters (which makes obvious sense for rate, but not so much for increase). it actually computes the rate of increase over ~4s rather than 5s. If you query rate(counter) OTOH, Prometheus will pick all the samples in the range (5 samples, covering approximately 4 seconds on average, say, ,, , ) and (assuming your counter doesn't reset within the interval) will return (v5 - v1) / (t5 - t1). That's because what Prometheus does is it takes all the samples in the 1 second range (which would be a single sample in the vast majority of cases), tries to compute a rate and fails. So if you have a bunch of samples that are (more or less) 1 second apart and you use Prometheus' rate(counter), you'll get no output. Now what happens in the real world is that your samples are not collected exactly every second on the second and rule evaluation doesn't happen exactly on the second either. Increase(counter) is exactly rate(counter) * 5 (and increase(counter) is exactly rate(counter) * 2).
#I understand code#
(This is the reason why you won't see an increase the first time a counter appears with a value of 1 - because your code just created and incremented it.) Except the ICH at second 1 is 0, not 1, because no one knows when your counter was zero: maybe it incremented right there, maybe it got incremented yesterday, and stayed at 1 since then. In an ideal world (where your samples' timestamps are exactly on the second and your rule evaluation happens exactly on the second) rate(counter) would return exactly your ICH value and rate(counter) would return the average of that ICH and the previous 4. *In my terms these values means the extrapolated values to cover every second.ĭo I understand it well or am I far from that? Increase(counter): First 2 seconds gave us an increment of 3 total,soĢ.seconds will get the value of 3 and so on. Increase(counter): In my term this will match with the ICH and the rate for 1s, just because the total range and rate's base granularity match. "increase(v range-vector) : calculates the increase in the time series in the range vector."įor me this means it wont distribute the average among the seconds, but instead will show the single increment for the given range(with extrapolation).
![i understand i understand](https://images.macmillan.com/folio-assets/macmillan_us_frontbookcovers_1000H/9781250266903.jpg)
And the sum of these increase will match the actual counter. So the higher the timerange the smoother result we will get. The same as for but we calculate the average from total increment of 5sec. Rate(counter): will get the average from the increment in 5 sec and distribute it among the seconds So in the first 2 second we got an increment of total 3 which means the average is 1.5/sec. Rate(counter): will get the average from the increment in 2 sec and distribute it among the seconds Rate(counter): will match ICH because average will be calculated from one value only. With a layman's terms this means that we will get the increase for every second and the value for the given second will be the average increment in the given range? "rate(v range-vector) : calculates the per-second average rate of increase of the time series in the range vector."
![i understand i understand](http://www.nigelwdavies.com/wp-content/uploads/2018/10/understand-image.jpg)
We want to run some query on this dataset. Second counter_value increase calculated by hand(call it ICH from now) We have the following timeseries for that: (Please note that for the sake of the simplest examples possible I have used the one second for scraping interval, timerange - even if its not possible in practice)ĭespite we scrape a counter in each second and the counter's values is 30 right now. I have read the Prometheus documentation carefully, but its still a bit unclear to me, so I am here to get confirmation about my understanding.