From 4889faa7e0bc4903295cbc6ac7a38f3a0e72c057 Mon Sep 17 00:00:00 2001 From: Alexander Pivkin Date: Mon, 24 Nov 2025 18:12:23 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B7=D0=B3=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go_exporter/main.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/go_exporter/main.go b/go_exporter/main.go index 85fcb97..0444d5f 100644 --- a/go_exporter/main.go +++ b/go_exporter/main.go @@ -5,14 +5,30 @@ import ( "log" "net/http" - "github.com/prometheus/client_golang/prometheus/promhttp" + promhttp "github.com/prometheus/client_golang/prometheus/promhttp" + prometheus "github.com/prometheus/client_golang/prometheus" ) +var fooMetric = prometheus.NewGauge(prometheus.GaugeOpts{ + Name: "foo_metric", + Help: "Show whether a foo has occured in a cluster", +}) + +var barMetric = prometheus.NewGauge(prometheus.GaugeOpts{ + Name: "bar_metric", + Help: "Show whether a bar has happened in a cluster", +}) func init() { - fmt.Println("###INIT THE CODE####") + fmt.Println("###Register my metrics in prometheus####") + prometheus.MustRegister(fooMetric) + prometheus.MustRegister(barMetric) + + fooMetric.Set(0) + barMetric.Set(1) } + func main() { http.Handle("/metrics",promhttp.Handler()) log.Fatal(http.ListenAndServe(":9040",nil))