From bcff7ec68f68458c90caa96bcb6b88c3d822b264 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Tue, 8 Feb 2022 22:27:44 +0100 Subject: [PATCH] Alerting: remove error banner when Prometheus ruler is not supported (#44571) (cherry picked from commit 3d0cff54102bd218019dce318611c5d3e835977f) Co-authored-by: Roy C --- .../features/alerting/unified/api/ruler.ts | 21 ++++++++----------- .../alerting/unified/state/actions.ts | 4 +++- .../features/alerting/unified/utils/rules.ts | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/public/app/features/alerting/unified/api/ruler.ts b/public/app/features/alerting/unified/api/ruler.ts index 8def1d17da4..ac3edeacf1c 100644 --- a/public/app/features/alerting/unified/api/ruler.ts +++ b/public/app/features/alerting/unified/api/ruler.ts @@ -107,15 +107,8 @@ async function rulerGetRequest(url: string, empty: T, params?: Record) { return ( - error.status === 500 && - error.data.message?.includes('unexpected content type from upstream. expected YAML, got text/html') + error.status === 404 || + (error.status === 500 && + error.data.message?.includes('unexpected content type from upstream. expected YAML, got text/html')) ); } function isCortexErrorResponse(error: FetchResponse) { - return error.data.message?.includes('group does not exist') || error.data.message?.includes('no rule groups found'); + return ( + error.status === 404 && + (error.data.message?.includes('group does not exist') || error.data.message?.includes('no rule groups found')) + ); } export async function deleteNamespace(dataSourceName: string, namespace: string): Promise { diff --git a/public/app/features/alerting/unified/state/actions.ts b/public/app/features/alerting/unified/state/actions.ts index e3fcd25b03d..ead22ca396c 100644 --- a/public/app/features/alerting/unified/state/actions.ts +++ b/public/app/features/alerting/unified/state/actions.ts @@ -66,6 +66,7 @@ import { addDefaultsToAlertmanagerConfig, removeMuteTimingFromRoute, isFetchErro import * as ruleId from '../utils/rule-id'; import { isEmpty } from 'lodash'; import messageFromError from 'app/plugins/datasource/grafana-azure-monitor-datasource/utils/messageFromError'; +import { RULER_NOT_SUPPORTED_MSG } from '../utils/constants'; const FETCH_CONFIG_RETRY_TIMEOUT = 30 * 1000; @@ -636,7 +637,8 @@ export const checkIfLotexSupportsEditingRulesAction = createAsyncThunk) { - return resp.error && resp.error?.message === RULER_NOT_SUPPORTED_MSG; + return resp.error && resp.error?.message?.includes(RULER_NOT_SUPPORTED_MSG); } export function isGrafanaRuleIdentifier(identifier: RuleIdentifier): identifier is GrafanaRuleIdentifier {