36 lines
746 B
Go
36 lines
746 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"net/http"
|
|
|
|
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("###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))
|
|
}
|