Hello All,
I believe many of the would have come across the below issue Prometheus increase function. Let me explain with an example:
Prometheus Metric:
"api_exit_status_total" is a Counter with distinct label set.
api_exit_status_total{api="", method="",exit_status="",.....}
Alert Expression:
increase(api_exit_status_total{api="",exit_status="failure"}[1h]) > 0
You can even consider we are doing sum by region, api etc.,
Issue being observed:
Due to some reasons or due to counter reset, we don't have any time series data for the above metrics for some 10 mins or 1hr.
Now, when the counter gets increased due to some transactions, since the we don't have the time series data in the past the increase function return 0 even if the counter is at some x value.
There are workarounds to use OR on() vector(0) at the end of the alert expression but this doesn't work for metrics with distinct label set.
Could you please let me know if you have come across such issue and possible workaround please.
Thanks,
Amar