Created
July 25, 2024 04:33
-
-
Save jiekun/57114fb9552b6d180bca50cc36882be9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/prometheus/client_golang/prometheus" | |
"github.com/prometheus/client_golang/prometheus/promhttp" | |
"net/http" | |
"time" | |
) | |
var ( | |
testHistogramVec = prometheus.NewHistogramVec(prometheus.HistogramOpts{ | |
Name: "test_histogram_seconds", | |
Help: "example metrics", | |
}, []string{"label_1"}) | |
) | |
func main() { | |
prometheus.Register(testHistogramVec) | |
for i := 0; i < 1; i++ { | |
go func() { | |
for { | |
testHistogramVec.With(prometheus.Labels{ | |
"label_1": "value_1", | |
}).Observe(1) | |
time.Sleep(time.Second) | |
} | |
}() | |
} | |
http.Handle("/metrics", promhttp.Handler()) | |
http.ListenAndServe(":2112", nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment