From adb9d145ac33661d365ea7100db38d9cb07887ca Mon Sep 17 00:00:00 2001 From: Wang Guangshuo <64081036+limowang@users.noreply.github.com> Date: Mon, 15 Jan 2024 16:07:44 +0800 Subject: [PATCH] fix(collector): fix the problem that prometheus cannot display the indicators collected by collector (#1851) --- collector/webui/webserver.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/collector/webui/webserver.go b/collector/webui/webserver.go index 8c13dda9cf..8783f0cac8 100644 --- a/collector/webui/webserver.go +++ b/collector/webui/webserver.go @@ -21,12 +21,22 @@ import ( "context" "time" + "github.com/apache/incubator-pegasus/collector/metrics" "github.com/kataras/iris/v12" + "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" ) // StartWebServer starts an iris-powered HTTP server. func StartWebServer() { + registry := prometheus.NewRegistry() + for _, cV := range metrics.CounterMetricsMap { + registry.MustRegister(cV) + } + for _, gV := range metrics.GaugeMetricsMap { + registry.MustRegister(gV) + } + app := iris.New() app.Get("/", indexHandler) app.Get("/tables", tablesHandler)