Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restores for state at seconds(now-forDuration) #4479

Merged
merged 2 commits into from
Oct 14, 2021

Conversation

owen-d
Copy link
Member

@owen-d owen-d commented Oct 14, 2021

This fixes a bug where we were incorrectly restoring for state. Loki will try to synthesize a historical ALERTS_FOR_STATE upon first evaluation (i.e. after restart) by evaluating the rule at both now-for_duration and now, which should allow it to recover after restarts, etc. This PR fixes a bug where the returned sample value in this time series was the millisecond timestamp of now, rather than the unix seconds representation of now-for_duration. I tested this locally with the following rule, which now successfully tries to alert before the 10m duration is up.

groups:
  - name: should_fire
    interval: 10s
    rules:
      - alert: absent_err
        expr: 'absent_over_time({job="foo"}[1m])'
        for: 10m

@owen-d owen-d requested a review from a team as a code owner October 14, 2021 20:40
Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@owen-d owen-d merged commit 3fb8f3d into grafana:main Oct 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants