I have a counter
type metric named request_count
, which has labels route
and status_code
. I need to trigger an alert when the growth rate within the same minute compared to one week ago exceeds 1.5. The expression I’m using is:
sum by (route, status_code) (increase_pure(request_count{route=~".+", status_code=~".+"}[1m])) / sum by (route, status_code) (increase_pure(request_count{route=~".+", status_code=~".+"}[1m] offset 1w)) > 1.5
The issue I’m facing is that for some route
or status_code
values, there were no previous data points. Therefore, I wanted to provide default values for these labels when they do not exist. I modified the expression as follows:
sum by (route, status_code) (increase_pure(request_count{route=~".+", status_code=~".+"}[1m])) / (sum by (route, status_code) (increase_pure(request_count{route=~".+", status_code=~".+"}[1m] offset 1w)) or vector(1))
However, the modification did not trigger alerts for route or status_code when they did not exist in the past. Does anyone have a solution for this?