From 95d383d656f167736e2a80a14e03b114cc64be22 Mon Sep 17 00:00:00 2001 From: icey-yu <1186114839@qq.com> Date: Fri, 26 Sep 2025 15:53:52 +0800 Subject: [PATCH] fix: prometheus --- internal/api/prometheus_discovery.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/api/prometheus_discovery.go b/internal/api/prometheus_discovery.go index 6bd9cd4a7..6ec563721 100644 --- a/internal/api/prometheus_discovery.go +++ b/internal/api/prometheus_discovery.go @@ -2,6 +2,7 @@ package api import ( "encoding/json" + "errors" "net/http" "github.com/gin-gonic/gin" @@ -38,10 +39,13 @@ func (p *PrometheusDiscoveryApi) Enable(c *gin.Context) { func (p *PrometheusDiscoveryApi) discovery(c *gin.Context, key string) { value, err := p.client.GetKeyWithPrefix(c, prommetrics.BuildDiscoveryKeyPrefix(key)) if err != nil { + if errors.Is(err, discovery.ErrNotSupported) { + c.JSON(http.StatusOK, []struct{}{}) + return + } apiresp.GinError(c, errs.WrapMsg(err, "get key value")) return } - if len(value) == 0 { c.JSON(http.StatusOK, []*prommetrics.RespTarget{}) return