From 4689bb4a039ac33353fbf386d1e4feb6254ffebf Mon Sep 17 00:00:00 2001 From: Nizamudeen A Date: Mon, 22 Sep 2025 21:13:52 +0530 Subject: [PATCH] mgr/dashboard: fix prometheus API error when not configured Fixes: https://tracker.ceph.com/issues/73174 Signed-off-by: Nizamudeen A (cherry picked from commit 0c0e0d436e63fa767da149402fead6a25e513978) --- .../src/app/shared/api/prometheus.service.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/prometheus.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/prometheus.service.ts index bf340df1d03..9e41497446b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/prometheus.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/prometheus.service.ts @@ -154,10 +154,16 @@ export class PrometheusService { } getGaugeQueryData(query: string): Observable { - return this.getPrometheusQueryData({ params: query }).pipe( - map((result: PromqlGuageMetric) => result), - catchError(() => of({ result: [] } as PromqlGuageMetric)) - ); + let result$: Observable = of({ result: [] } as PromqlGuageMetric); + + this.ifPrometheusConfigured(() => { + result$ = this.getPrometheusQueryData({ params: query }).pipe( + map((result: PromqlGuageMetric) => result), + catchError(() => of({ result: [] } as PromqlGuageMetric)) + ); + }); + + return result$; } formatGuageMetric(data: string): number { -- 2.39.5