-
Notifications
You must be signed in to change notification settings - Fork 11.7k
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
Alerting: Support hysteresis command expression #75189
Conversation
d64d02a
to
5e1b397
Compare
72aa808
to
24d23fd
Compare
public/app/features/alerting/unified/components/expressions/Expression.tsx
Outdated
Show resolved
Hide resolved
|
last commit : skip hysteresis values being validated when unchecking hysteresis. fix-hysteresis-validation.mp4 |
/deploy-to-hg |
# Conflicts: # pkg/expr/threshold_test.go
/deploy-to-hg |
After a conversation with @yuri-tceretian we agreed on hiding hsyteresis in panel expressions. |
# Conflicts: # pkg/tests/api/alerting/testing.go
/deploy-to-hg |
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job! Confirmed working as expected, there are parts I'm not 100% sure on the implementation but considering this is behind a feature flag it's not necessary to dwell on those details at this stage. 🚀
Backend: * Update the Grafana Alerting engine to provide feedback to HysteresisCommand. The feedback information is stored in state.Manager as a fingerprint of each state. The fingerprint is persisted to the database. Only fingerprints that belong to Pending and Alerting states are considered as "loaded" and provided back to the command. - add ResultFingerprint to state.State. It's different from other fingerprints we store in the state because it is calculated from the result labels. - add rule_fingerprint column to alert_instance - update alerting evaluator to accept AlertingResultsReader via context, and update scheduler to provide it. - add AlertingResultsFromRuleState that implements the new interface in eval package - update getExprRequest to patch the hysteresis command. * Only one "Recovery Threshold" query is allowed to be used in the alert rule and it must be the Condition. Frontend: * Add hysteresis option to Threshold in UI. It's called "Recovery Threshold" * Add test for getUnloadEvaluatorTypeFromCondition * Hide hysteresis in panel expressions * Refactor isInvalid and add test for it * Remove unnecesary React.memo * Add tests for updateEvaluatorConditions --------- Co-authored-by: Sonia Aguilar <soniaaguilarpeiron@gmail.com>
What is this feature?
This PR adds support for a new type of command introduced in #70998. The hysteresis command requires information about the results of the previous evaluation. This PR updates the state manager and scheduler to facilitate this information for the evaluation engine:
The structure AlertingResultsFromRuleState implements the logic that determines what metric\dimension\state is considered as "loaded":
Why do we need this feature?
To support hysteresis expression in alerting. This will help users reduce flapping on the alert rules when the metric value frequently crosses threshold boundaries.
Who is this feature for?
Alerting
Which issue(s) does this PR fix?:
Related #6202
Special notes for your reviewer:
recoveryThreshold
. if it is disabled the expr engine does not create HysteresisCommand struct and code in this PR does not do anything.UI screen recording
hysteresis_UI.mp4
When viewing the rule
Please check that: