From: Nizamudeen A Date: Tue, 23 Mar 2021 07:10:46 +0000 (+0530) Subject: mgr/dashboard: Fix for alert notification message being undefined X-Git-Tag: v14.2.22~27^2~1^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F40590%2Fhead;p=ceph.git mgr/dashboard: Fix for alert notification message being undefined Prometheus alert notification message in the dashboard always comes up as undefined. Its because we were showing the alert.summary instead of alert.description for displaying the message. I couldn't find the summary field in the ceph_default_alerts.yml file. So removed all the Summary fields from the dashboard code. Fixes: https://tracker.ceph.com/issues/49342 Signed-off-by: Nizamudeen A (cherry picked from commit 2921b2e9a939e1ad52b07327fdf84885568384b9) --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/models/prometheus-alerts.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/models/prometheus-alerts.ts index f5e8f850b15b..1239dcccdfe2 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/models/prometheus-alerts.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/models/prometheus-alerts.ts @@ -7,7 +7,6 @@ export class PrometheusAlertLabels { class Annotations { description: string; - summary: string; } class CommonAlertmanagerAlert { @@ -80,6 +79,6 @@ export class PrometheusCustomAlert { status: 'resolved' | 'unprocessed' | 'active' | 'suppressed'; name: string; url: string; - summary: string; + description: string; fingerprint?: string | boolean; } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-alert-formatter.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-alert-formatter.spec.ts index 0b0190553aaf..7a195e8b4949 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-alert-formatter.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-alert-formatter.spec.ts @@ -54,7 +54,7 @@ describe('PrometheusAlertFormatter', () => { { status: 'active', name: 'Something', - summary: 'Something is active', + description: 'Something is active', url: 'http://Something', fingerprint: 'Something' } as PrometheusCustomAlert @@ -69,7 +69,7 @@ describe('PrometheusAlertFormatter', () => { fingerprint: false, status: 'active', name: 'Something', - summary: 'Something is firing', + description: 'Something is firing', url: 'http://Something' } as PrometheusCustomAlert ]); @@ -80,7 +80,7 @@ describe('PrometheusAlertFormatter', () => { const alert: PrometheusCustomAlert = { status: 'active', name: 'Some alert', - summary: 'Some alert is active', + description: 'Some alert is active', url: 'http://some-alert', fingerprint: '42' }; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-alert-formatter.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-alert-formatter.ts index 47cb0307c1fa..cfa1896e0ed3 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-alert-formatter.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-alert-formatter.ts @@ -32,7 +32,7 @@ export class PrometheusAlertFormatter { : this.getPrometheusNotificationStatus(alert as AlertmanagerNotificationAlert), name: alert.labels.alertname, url: alert.generatorURL, - summary: alert.annotations.summary, + description: alert.annotations.description, fingerprint: _.isObject(alert.status) && (alert as AlertmanagerAlert).fingerprint }; }), @@ -52,7 +52,7 @@ export class PrometheusAlertFormatter { return new CdNotificationConfig( this.formatType(alert.status), `${alert.name} (${alert.status})`, - this.appendSourceLink(alert, alert.summary), + this.appendSourceLink(alert, alert.description), undefined, 'Prometheus' ); diff --git a/src/pybind/mgr/dashboard/frontend/src/testing/unit-test-helper.ts b/src/pybind/mgr/dashboard/frontend/src/testing/unit-test-helper.ts index a22c76ecacb4..a17bfeb2e2a6 100644 --- a/src/pybind/mgr/dashboard/frontend/src/testing/unit-test-helper.ts +++ b/src/pybind/mgr/dashboard/frontend/src/testing/unit-test-helper.ts @@ -262,7 +262,7 @@ export class PrometheusHelper { severity: 'someSeverity' }, annotations: { - summary: `${name} is ${state}` + description: `${name} is ${state}` }, generatorURL: `http://${name}`, startsAt: new Date(new Date('2022-02-22').getTime() * timeMultiplier).toString() @@ -276,7 +276,7 @@ export class PrometheusHelper { alertname: name }, annotations: { - summary: `${name} is ${status}` + description: `${name} is ${status}` }, generatorURL: `http://${name}` } as AlertmanagerNotificationAlert;