This commit is contained in:
Alexander Pivkin 2025-11-24 18:12:23 +03:00
parent e9454a187c
commit 4889faa7e0

View File

@ -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))