Alerting: Add support for unknown rule state (#105052)

Add support for unknown rule state
This commit is contained in:
Konrad Lalik
2025-05-07 11:25:44 +02:00
committed by GitHub
parent 277d271476
commit e3d9c5d33e
6 changed files with 15 additions and 2 deletions

View File

@ -48,6 +48,10 @@ export const StateBadge = ({ state, health }: StateBadgeProps) => {
color = 'warning';
stateLabel = 'Recovering';
break;
case PromAlertingRuleState.Unknown:
color = 'info';
stateLabel = 'Unknown';
break;
}
// if the rule is in "error" health we don't really care about the state
@ -65,7 +69,7 @@ export const StateBadge = ({ state, health }: StateBadgeProps) => {
};
// the generic badge component
type BadgeColor = 'success' | 'error' | 'warning';
type BadgeColor = 'success' | 'error' | 'warning' | 'info';
interface BadgeProps {
color: BadgeColor;

View File

@ -36,6 +36,7 @@ export const RuleListStateView = ({ namespaces }: Props) => {
[PromAlertingRuleState.Pending, []],
[PromAlertingRuleState.Recovering, []],
[PromAlertingRuleState.Inactive, []],
[PromAlertingRuleState.Unknown, []],
]);
namespaces.forEach((namespace) =>
@ -75,6 +76,7 @@ const STATE_TITLES: Record<PromAlertingRuleState, string> = {
[PromAlertingRuleState.Pending]: 'Pending',
[PromAlertingRuleState.Inactive]: 'Normal',
[PromAlertingRuleState.Recovering]: 'Recovering',
[PromAlertingRuleState.Unknown]: 'Unknown',
};
const RulesByState = ({ state, rules }: { state: PromAlertingRuleState; rules: CombinedRule[] }) => {

View File

@ -34,6 +34,7 @@ export const StateView = ({ namespaces }: Props) => {
[PromAlertingRuleState.Pending, []],
[PromAlertingRuleState.Recovering, []],
[PromAlertingRuleState.Inactive, []],
[PromAlertingRuleState.Unknown, []],
]);
namespaces.forEach((namespace) =>
@ -70,6 +71,7 @@ const STATE_TITLES: Record<PromAlertingRuleState, string> = {
[PromAlertingRuleState.Pending]: 'Pending',
[PromAlertingRuleState.Inactive]: 'Normal',
[PromAlertingRuleState.Recovering]: 'Recovering',
[PromAlertingRuleState.Unknown]: 'Unknown',
};
const RulesByState = ({ state, rules }: { state: PromAlertingRuleState; rules: CombinedRule[] }) => {

View File

@ -29,13 +29,15 @@ const icons: Record<PromAlertingRuleState, IconName> = {
[PromAlertingRuleState.Pending]: 'circle',
[PromAlertingRuleState.Recovering]: 'exclamation-circle',
[PromAlertingRuleState.Firing]: 'exclamation-circle',
[PromAlertingRuleState.Unknown]: 'question-circle',
};
const color: Record<PromAlertingRuleState, 'success' | 'error' | 'warning'> = {
const color: Record<PromAlertingRuleState, 'success' | 'error' | 'warning' | 'info'> = {
[PromAlertingRuleState.Inactive]: 'success',
[PromAlertingRuleState.Pending]: 'warning',
[PromAlertingRuleState.Recovering]: 'warning',
[PromAlertingRuleState.Firing]: 'error',
[PromAlertingRuleState.Unknown]: 'info',
};
const stateNames: Record<PromAlertingRuleState, string> = {
@ -43,6 +45,7 @@ const stateNames: Record<PromAlertingRuleState, string> = {
[PromAlertingRuleState.Pending]: 'Pending',
[PromAlertingRuleState.Firing]: 'Firing',
[PromAlertingRuleState.Recovering]: 'Recovering',
[PromAlertingRuleState.Unknown]: 'Unknown',
};
const operationIcons: Record<RuleOperation, IconName> = {

View File

@ -222,6 +222,7 @@ const alertStateSortScore = {
[PromAlertingRuleState.Inactive]: 2,
[GrafanaAlertState.NoData]: 3,
[GrafanaAlertState.Normal]: 4,
[PromAlertingRuleState.Unknown]: 5,
};
export function sortAlerts(sortOrder: SortOrder, alerts: Alert[]): Alert[] {

View File

@ -13,6 +13,7 @@ export enum PromAlertingRuleState {
Inactive = 'inactive',
Pending = 'pending',
Recovering = 'recovering',
Unknown = 'unknown',
}
export enum GrafanaAlertState {