Finding total events in a application deployed in kubernetes

20 views
Skip to first unread message

Manish G

unread,
Aug 31, 2020, 11:48:39 AM8/31/20
to Prometheus Users
Hi All,

I have an application deployed in kubernetes, wherein pods come and go. I have configured a counter metrics in the application for keeping track of events application receives.

What is the best way to find total number of events application has received over a period of say, 3 days?

increase(myMetrics[3d]) would give me increase over the period, but it would result in number of metrics as pods is one of the label and application is running on multiple pods which die and spin off continuously.

I can apply sum over this (sum(increase(myMetrics[3d]))), but I am not sure about it as sum only adds up data points at a given timestamp, not over a range of time as far as I understand sum function.

Any input would be helpful to make progress.

With regards




Brian Candler

unread,
Aug 31, 2020, 12:59:17 PM8/31/20
to Prometheus Users
myMetrics[3d] is a "range vector" - it's two dimensional, across both series and time.

increase(myMetrics[3d]) is an "instant vector" - it's one dimensional, across series only (it returns one value for each series)

sum(...) works across an instant vector - it adds all the values across series, to give a single scalar result.

So your proposed query is fine.

Do note that increase(...) is syntactic sugar for rate(...) multiplied by the time window, and therefore can give non-integer results, not exact counts.  It does however take care of counter resets.
Reply all
Reply to author
Forward
0 new messages