Denis
Denis

Reputation: 3707

How to calculate absent_over_time with label dimensional?

I have a counter, for example, user_actions with label user_id. I want to get alert, when user_actions is disappeared for any user_id.

Literally, I need absent_over_time(user_actions[60m]), but taking into account user_id label.

Upvotes: 3

Views: 2065

Answers (1)

valyala
valyala

Reputation: 18066

I couldn't come up with PromQL solution for this task, but it can be implemented with lag() function from MetricsQL. For instance, the following query would return all the user_actions time series that have no data points during the last 5 minutes (see 5*60 in the query). The query stops noticing such time series after 60 minutes (see 60m in square brackets):

lag(user_actions[60m]) > 5*60

See more details about lag() function in MetricsQL docs.

Upvotes: 2

Related Questions