Prometheus: how to sum metric after pod killed?

Viewed 309

I am trying to apply a simple sum operation to get all accounts created over time.

Last weekend I have deleted and created new pods and my metrics are screwed when I try to run as type "instant". If I change type to range, I can see values but I see a break in my graph:

  • Until 2021-06-11: 260k
  • 2021-06-14: 7k

In 2021-06-14 should be 267k.

The query is kinda simple:

sum(keycloak_admin_event_CREATE)

Any idea why it's not summing?

1 Answers

Try wrapping the series selector into last_over_time() function:

sum(last_over_time(keycloak_admin_event_CREATE[7d]))

The [7d] means that the outer sum will take into account the last value for all the time series during the last 7 days.

Related