-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Alerting: Correct filtering for NoData and Error states in Alert list panel #61290
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -161,13 +161,20 @@ function filterRules(props: PanelProps<UnifiedAlertListOptions>, rules: PromRule | |
| ); | ||
| } | ||
|
|
||
| filteredRules = filteredRules.filter((rule) => { | ||
| return ( | ||
| (options.stateFilter.firing && rule.rule.state === PromAlertingRuleState.Firing) || | ||
| (options.stateFilter.pending && rule.rule.state === PromAlertingRuleState.Pending) || | ||
| (options.stateFilter.normal && rule.rule.state === PromAlertingRuleState.Inactive) | ||
| ); | ||
| }); | ||
| // skip filtering by the alert rule's state if we've selected "nodata" or "error" as a filter condition. | ||
| // the alert rule state is not reflected if we have any instances matching that state | ||
| // this means that an instance might be "nodata" or "error" but the alert rule it belongs to will be "normal" | ||
| const isInstanceStateFilter = options.stateFilter.noData || options.stateFilter.error; | ||
|
|
||
| if (!isInstanceStateFilter) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if the user selected There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will only show the "firing" alert rules when in "default grouping" but for "custom grouping" it will show nodata, error and firing. I'll need to figure out how to also make it work for the "default grouping" 🤔 |
||
| filteredRules = filteredRules.filter((rule) => { | ||
| return ( | ||
| (options.stateFilter.firing && rule.rule.state === PromAlertingRuleState.Firing) || | ||
| (options.stateFilter.pending && rule.rule.state === PromAlertingRuleState.Pending) || | ||
| (options.stateFilter.normal && rule.rule.state === PromAlertingRuleState.Inactive) | ||
| ); | ||
| }); | ||
| } | ||
|
|
||
| if (options.alertInstanceLabelFilter) { | ||
| const replacedLabelFilter = replaceVariables(options.alertInstanceLabelFilter); | ||
|
|
||
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.
👏