From f71f54c87235b3d7a77e2d60740980678603c9c5 Mon Sep 17 00:00:00 2001 From: Gilles De Mey Date: Fri, 16 Feb 2024 17:13:43 +0100 Subject: [PATCH] Alerting: Updates to recording rules (#82329) --- .../QueryAndExpressionsStep.tsx | 21 ++++++------ .../descriptions.tsx | 32 +++++++++++++++++++ 2 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/descriptions.tsx diff --git a/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/QueryAndExpressionsStep.tsx b/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/QueryAndExpressionsStep.tsx index 0aff0232535..eebc027a1b0 100644 --- a/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/QueryAndExpressionsStep.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/QueryAndExpressionsStep.tsx @@ -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 ( + - 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} } diff --git a/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/descriptions.tsx b/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/descriptions.tsx new file mode 100644 index 00000000000..fced3fa06a5 --- /dev/null +++ b/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/descriptions.tsx @@ -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.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/', + }, +};