згл
This commit is contained in:
parent
e9454a187c
commit
4889faa7e0
|
|
@ -5,14 +5,30 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"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() {
|
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() {
|
func main() {
|
||||||
http.Handle("/metrics",promhttp.Handler())
|
http.Handle("/metrics",promhttp.Handler())
|
||||||
log.Fatal(http.ListenAndServe(":9040",nil))
|
log.Fatal(http.ListenAndServe(":9040",nil))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user