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

Add support for unknown rule state
pull/105057/head
Konrad Lalik 7 months ago committed by GitHub
parent 277d271476
commit e3d9c5d33e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      public/app/features/alerting/unified/components/rule-viewer/StateBadges.tsx
  2. 2
      public/app/features/alerting/unified/components/rules/RuleListStateView.tsx
  3. 2
      public/app/features/alerting/unified/rule-list/StateView.tsx
  4. 5
      public/app/features/alerting/unified/rule-list/components/RuleListIcon.tsx
  5. 1
      public/app/features/alerting/unified/utils/misc.ts
  6. 1
      public/app/types/unified-alerting-dto.ts

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

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

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

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

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

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

Loading…
Cancel
Save