cortex icon indicating copy to clipboard operation
cortex copied to clipboard

Config updates cause alerting rules to forget firing state

Open leth opened this issue 9 years ago • 6 comments

If a config set is updated, all the rules it declares will forget their firing state, even if the rules are unchanged.

leth avatar Jul 07 '17 11:07 leth

We also see this when alertmanager configs change.

jml avatar Jul 07 '17 15:07 jml

This was the underlying cause for our alert tests being stuck in pending states. Our GitOps flow was pushing unnecessary, but unchanged, config updates to cortex. This causes the state of alert rules to be reset for the tenant.

Digging into this to see if this was something we could resolve within the cortex code base, it lead very quickly to the Prometheus code for the NewAlertingRule function. There does not seem to be with a somewhat cursory examination, a way to update an existing rule. Seeing as the Prometheus approach to config updates is to replace existing with new instances, it would seem rather drastic to propose a change in the Prometheus library code. Instead rather any effort should be around refactoring the logic used in the ruler to use a custom alert struct, based on Prom, but updatable perhaps.

khaines avatar Apr 03 '18 03:04 khaines

Thanks for digging into this! Yes this issue is in part due to there being no easy way to do this in the underlying Prometheus APIs.

Prometheus has an open issue for persisting alert state across restarts, so a proposed change in behaviour might not be that outlandish!

leth avatar Apr 03 '18 08:04 leth

An interesting development: there's an open PR to persist alerting state across restarts

leth avatar Apr 09 '18 12:04 leth

Note that restarting the ruler process itself also causes the ActiveAt state to be lost.

bboreham avatar Jun 11 '18 16:06 bboreham

Note the function to let us copy state from an old alert to a new one is exposed now, so we can fix the headline issue. Requires #929.

bboreham avatar Feb 28 '19 10:02 bboreham