f-21: mon: add prometheus data
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
bcedeece18
commit
d393b647ac
2 changed files with 87 additions and 0 deletions
20
pkg/prometheus/server.go
Normal file
20
pkg/prometheus/server.go
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
package promserver
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
)
|
||||
|
||||
// Start launches the Prometheus metrics HTTP server on the given address.
|
||||
// The provided registry is used to expose metrics at /metrics.
|
||||
func Start(address string, registry *prometheus.Registry) {
|
||||
mux := http.NewServeMux()
|
||||
mux.Handle("/metrics", promhttp.HandlerFor(registry, promhttp.HandlerOpts{
|
||||
EnableOpenMetrics: true,
|
||||
}))
|
||||
log.Printf("Prometheus server listening on %s", address)
|
||||
log.Fatal(http.ListenAndServe(address, mux))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue