From: Patrick Seidensal Date: Tue, 3 Dec 2019 19:46:17 +0000 (+0100) Subject: mgr/dashboard: show alert panel if prometheus/alertmanager is unconfigured X-Git-Tag: v15.1.0~650^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F31937%2Fhead;p=ceph.git mgr/dashboard: show alert panel if prometheus/alertmanager is unconfigured If the tabs under the "Monitoring" page aren't properly configured, a notification is shown which explains the user which setting needs to be enabled and also provides a link to the corresponding documentation. Fixes: https://tracker.ceph.com/issues/42877 Signed-off-by: Patrick Seidensal --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/monitoring-list/monitoring-list.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/monitoring-list/monitoring-list.component.html index 55f571d8427a..f54c1fe515f5 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/monitoring-list/monitoring-list.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/monitoring-list/monitoring-list.component.html @@ -3,18 +3,36 @@ heading="Active Alerts" (selectTab)="setFragment($event)" i18n-heading> - + + To see all active Prometheus alerts, please + provide the URL to the API of Prometheus' Alertmanager as described in the + documentation. - + + To see all configured Prometheus alerts, please provide the URL to + the API of Prometheus as described in the + documentation. - + + To enable Silences, please provide the URL to the API of the Prometheus' Alertmanager as + described in the + documentation. diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/monitoring-list/monitoring-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/monitoring-list/monitoring-list.component.ts index f6f57a9b3766..5e96d126fdda 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/monitoring-list/monitoring-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/monitoring-list/monitoring-list.component.ts @@ -3,7 +3,10 @@ import { ActivatedRoute, Router } from '@angular/router'; import { TabDirective, TabsetComponent } from 'ngx-bootstrap/tabs'; +import { PrometheusService } from '../../../../shared/api/prometheus.service'; +import { CephReleaseNamePipe } from '../../../../shared/pipes/ceph-release-name.pipe'; import { PrometheusAlertService } from '../../../../shared/services/prometheus-alert.service'; +import { SummaryService } from '../../../../shared/services/summary.service'; @Component({ selector: 'cd-monitoring-list', @@ -11,16 +14,43 @@ import { PrometheusAlertService } from '../../../../shared/services/prometheus-a styleUrls: ['./monitoring-list.component.scss'] }) export class MonitoringListComponent implements OnInit { - @ViewChild('tabs', { static: true }) - tabs: TabsetComponent; - constructor( public prometheusAlertService: PrometheusAlertService, + private prometheusService: PrometheusService, private route: ActivatedRoute, - private router: Router + private router: Router, + private summaryService: SummaryService, + private cephReleaseNamePipe: CephReleaseNamePipe ) {} + @ViewChild('tabs', { static: true }) + tabs: TabsetComponent; + + isPrometheusConfigured = false; + isAlertmanagerConfigured = false; + + docsUrl = ''; ngOnInit() { + this.prometheusService.ifAlertmanagerConfigured(() => { + this.isAlertmanagerConfigured = true; + }); + this.prometheusService.ifPrometheusConfigured(() => { + this.isPrometheusConfigured = true; + }); + + const subs = this.summaryService.subscribe((summary: any) => { + if (!summary) { + return; + } + + const releaseName = this.cephReleaseNamePipe.transform(summary.version); + this.docsUrl = `https://docs.ceph.com/docs/${releaseName}/mgr/dashboard/#enabling-prometheus-alerting`; + + setTimeout(() => { + subs.unsubscribe(); + }, 0); + }); + // Activate tab according to given fragment if (this.route.snapshot.fragment) { const tab = this.tabs.tabs.find( diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.html b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.html index 77b30500847e..21360dd11a53 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.html @@ -147,7 +147,7 @@
  • + *ngIf="(isAlertmanagerConfigured || isPrometheusConfigured) && permissions.prometheus.read"> Monitoring diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.ts index 94313d5a5615..83c8690f4b9c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.ts @@ -19,9 +19,9 @@ export class NavigationComponent implements OnInit { permissions: Permissions; summaryData: any; icons = Icons; - isCollapsed = true; - prometheusConfigured = false; + isAlertmanagerConfigured = false; + isPrometheusConfigured = false; enabledFeature$: FeatureTogglesMap$; constructor( @@ -42,7 +42,10 @@ export class NavigationComponent implements OnInit { this.summaryData = data; }); this.prometheusService.ifAlertmanagerConfigured(() => { - this.prometheusConfigured = true; + this.isAlertmanagerConfigured = true; + }); + this.prometheusService.ifPrometheusConfigured(() => { + this.isPrometheusConfigured = true; }); }