prometheus

/*
 */
package main

import (
	"log"
	"net/http"

	"github.com/prometheus/client_golang/prometheus"
	"github.com/prometheus/client_golang/prometheus/promhttp"
)

var (
	hdFailures = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "hd_errors_total",
			Help: "Number of hard-disk errors.",
		},
		[]string{"src", "dest"},
	)
)

func init() {
	prometheus.MustRegister(hdFailures)
}

func main() {
	hdFailures.With(prometheus.Labels{"src": "src1", "dest": "dest1"}).Inc()
	hdFailures.With(prometheus.Labels{"src": "src2", "dest": "dest2"}).Add(float64(0.5))

	http.Handle("/metrics", promhttp.Handler())
	log.Fatal(http.ListenAndServe(":8081", nil))
}

上一篇:将Python3后台工程编译成pyc部署


下一篇:实验报告一 -宋岳 -201821410037