From ff8a4a2a2547629af694e8f9a051e98cea890b86 Mon Sep 17 00:00:00 2001 From: Afreen Misbah Date: Wed, 25 Feb 2026 16:43:22 +0530 Subject: [PATCH] mgr/dashboard: Add filtering of alerts via route - when user click on alerts of particular severity only those alerts should be shown Fixes https://tracker.ceph.com/issues/75158 Signed-off-by: Afreen Misbah --- .../active-alert-list.component.ts | 24 +++++++++++++++++++ .../overview-alerts-card.component.html | 5 ++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/active-alert-list/active-alert-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/active-alert-list/active-alert-list.component.ts index 3dd5ac7ece1..2930710b55b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/active-alert-list/active-alert-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/active-alert-list/active-alert-list.component.ts @@ -1,4 +1,5 @@ import { Component, Inject, OnInit, TemplateRef, ViewChild } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; import { PrometheusService } from '~/app/shared/api/prometheus.service'; import { CellTemplate } from '~/app/shared/enum/cell-template.enum'; @@ -15,6 +16,12 @@ import { URLBuilderService } from '~/app/shared/services/url-builder.service'; const BASE_URL = 'silences'; // as only silence actions can be used +const SeverityMap = { + critical: $localize`Critical`, + warning: $localize`Warning`, + all: $localize`All` +}; + @Component({ selector: 'cd-active-alert-list', providers: [{ provide: URLBuilderService, useValue: new URLBuilderService(BASE_URL) }], @@ -46,6 +53,18 @@ export class ActiveAlertListComponent extends PrometheusListHelper implements On if (value === 'All') return true; return false; } + }, + { + name: $localize`Severity`, + prop: 'labels.severity', + filterOptions: [SeverityMap['all'], SeverityMap['warning'], SeverityMap['critical']], + filterInitValue: SeverityMap['all'], + filterPredicate: (row, value) => { + if (value === SeverityMap['critical']) return row.labels?.severity === 'critical'; + else if (value === SeverityMap['warning']) return row.labels?.severity === 'warning'; + if (value === SeverityMap['all']) return true; + return false; + } } ]; @@ -54,6 +73,7 @@ export class ActiveAlertListComponent extends PrometheusListHelper implements On private authStorageService: AuthStorageService, public prometheusAlertService: PrometheusAlertService, private urlBuilder: URLBuilderService, + private route: ActivatedRoute, @Inject(PrometheusService) prometheusService: PrometheusService ) { super(prometheusService); @@ -139,6 +159,10 @@ export class ActiveAlertListComponent extends PrometheusListHelper implements On } ]; this.prometheusAlertService.getGroupedAlerts(true); + this.route.queryParams.subscribe((params) => { + const severity = params['severity']; + this.filters[1].filterInitValue = SeverityMap[severity]; + }); } setExpandedInnerRow(row: any) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/overview/alerts-card/overview-alerts-card.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/overview/alerts-card/overview-alerts-card.component.html index 1c8cd405111..7018f7fdaf8 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/overview/alerts-card/overview-alerts-card.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/overview/alerts-card/overview-alerts-card.component.html @@ -36,17 +36,18 @@ class="overview-alerts-card-badge" [class.overview-alerts-card-badge-with-border--right]="!last && compact" [class.overview-alerts-card-badge-with-border--bottom]="!compact"> - + + @if(compact) { {{ b.count }} } @else { {{b.key | upperFirst}} ({{ b.count }}) } + } -- 2.47.3