Alerting: Updates to recording rules (#82329)

This commit is contained in:
Gilles De Mey 2024-02-16 17:13:43 +01:00 committed by GitHub
parent 5de17432f5
commit f71f54c872
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 43 additions and 10 deletions

View File

@ -40,6 +40,7 @@ import { errorFromCurrentCondition, errorFromPreviewData, findRenamedDataQueryRe
import { CloudDataSourceSelector } from './CloudDataSourceSelector';
import { SmartAlertTypeDetector } from './SmartAlertTypeDetector';
import { DESCRIPTIONS } from './descriptions';
import {
addExpressions,
addNewDataQuery,
@ -243,6 +244,7 @@ export const QueryAndExpressionsStep = ({ editingExistingRule, onDataChange }: P
queryType: '',
relativeTimeRange: getDefaultRelativeTimeRange(),
expr,
instant: true,
model: {
refId: 'A',
hide: false,
@ -370,23 +372,22 @@ export const QueryAndExpressionsStep = ({ editingExistingRule, onDataChange }: P
condition,
]);
const { sectionTitle, helpLabel, helpContent, helpLink } = DESCRIPTIONS[type ?? RuleFormType.grafana];
return (
<RuleEditorSection
stepNo={2}
title={type !== RuleFormType.cloudRecording ? 'Define query and alert condition' : 'Define query'}
title={sectionTitle}
description={
<Stack direction="row" gap={0.5} alignItems="baseline">
<Stack direction="row" gap={0.5} alignItems="center">
<Text variant="bodySmall" color="secondary">
Define queries and/or expressions and then choose one of them as the alert rule condition. This is the
threshold that an alert rule must meet or exceed in order to fire.
{helpLabel}
</Text>
<NeedHelpInfo
contentText={`An alert rule consists of one or more queries and expressions that select the data you want to measure.
Define queries and/or expressions and then choose one of them as the alert rule condition. This is the threshold that an alert rule must meet or exceed in order to fire.
For more information on queries and expressions, see Query and transform data.`}
externalLink={`https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/`}
linkText={`Read about query and condition`}
title="Define query and alert condition"
contentText={helpContent}
externalLink={helpLink}
linkText={'Read more on our documentation website'}
title={helpLabel}
/>
</Stack>
}

View File

@ -0,0 +1,32 @@
import { RuleFormType } from '../../../types/rule-form';
type FormDescriptions = {
sectionTitle: string;
helpLabel: string;
helpContent: string;
helpLink: string;
};
export const DESCRIPTIONS: Record<RuleFormType, FormDescriptions> = {
[RuleFormType.cloudRecording]: {
sectionTitle: 'Define recording rule',
helpLabel: 'Define your recording rule',
helpContent:
'Pre-compute frequently needed or computationally expensive expressions and save their result as a new set of time series.',
helpLink: '',
},
[RuleFormType.grafana]: {
sectionTitle: 'Define query and alert condition',
helpLabel: 'Define query and alert condition',
helpContent:
'An alert rule consists of one or more queries and expressions that select the data you want to measure. Define queries and/or expressions and then choose one of them as the alert rule condition. This is the threshold that an alert rule must meet or exceed in order to fire. For more information on queries and expressions, see Query and transform data.',
helpLink: 'https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/',
},
[RuleFormType.cloudAlerting]: {
sectionTitle: 'Define query and alert condition',
helpLabel: 'Define query and alert condition',
helpContent:
'An alert rule consists of one or more queries and expressions that select the data you want to measure. Define queries and/or expressions and then choose one of them as the alert rule condition. This is the threshold that an alert rule must meet or exceed in order to fire. For more information on queries and expressions, see Query and transform data.',
helpLink: 'https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/',
},
};