heading="Active Alerts"
(selectTab)="setFragment($event)"
i18n-heading>
- <cd-active-alert-list></cd-active-alert-list>
+ <cd-active-alert-list *ngIf="isAlertmanagerConfigured"></cd-active-alert-list>
+ <cd-alert-panel type="info"
+ i18n
+ *ngIf="!isAlertmanagerConfigured">To see all active Prometheus alerts, please
+ provide the URL to the API of Prometheus' Alertmanager as described in the
+ <a href="{{docsUrl}}"
+ target="_blank">documentation</a>.</cd-alert-panel>
</tab>
<tab id="all-alerts"
heading="All Alerts"
(selectTab)="setFragment($event)"
i18n-heading>
- <cd-rules-list [data]="prometheusAlertService.rules"></cd-rules-list>
+ <cd-rules-list *ngIf="isPrometheusConfigured"
+ [data]="prometheusAlertService.rules"></cd-rules-list>
+ <cd-alert-panel type="info"
+ *ngIf="!isPrometheusConfigured">To see all configured Prometheus alerts, please provide the URL to
+ the API of Prometheus as described in the
+ <a href="{{docsUrl}}"
+ target="_blank">documentation</a>.</cd-alert-panel>
</tab>
<tab id="silences"
heading="Silences"
(selectTab)="setFragment($event)"
i18n-heading>
- <cd-silences-list></cd-silences-list>
+ <cd-silences-list *ngIf="isAlertmanagerConfigured"></cd-silences-list>
+ <cd-alert-panel *ngIf="!isAlertmanagerConfigured"
+ type="info"
+ i18n>To enable Silences, please provide the URL to the API of the Prometheus' Alertmanager as
+ described in the
+ <a href="{{docsUrl}}"
+ target="_blank">documentation</a>.</cd-alert-panel>
</tab>
</tabset>
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',
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(
</li>
<li routerLinkActive="active"
class="tc_submenuitem tc_submenuitem_monitoring"
- *ngIf="prometheusConfigured && permissions.prometheus.read">
+ *ngIf="(isAlertmanagerConfigured || isPrometheusConfigured) && permissions.prometheus.read">
<a i18n
class="dropdown-item"
routerLink="/monitoring">Monitoring</a>
permissions: Permissions;
summaryData: any;
icons = Icons;
-
isCollapsed = true;
- prometheusConfigured = false;
+ isAlertmanagerConfigured = false;
+ isPrometheusConfigured = false;
enabledFeature$: FeatureTogglesMap$;
constructor(
this.summaryData = data;
});
this.prometheusService.ifAlertmanagerConfigured(() => {
- this.prometheusConfigured = true;
+ this.isAlertmanagerConfigured = true;
+ });
+ this.prometheusService.ifPrometheusConfigured(() => {
+ this.isPrometheusConfigured = true;
});
}