这是官方的prometheus golang-client示例:
package main
import (
"log"
"net/http"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
var cpuTemp = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "cpu_temperature_celsius",
Help: "Current temperature of the CPU.",
})
func init() {
// Metrics have to be registered to be exposed:
prometheus.MustRegister(cpuTemp)
}
func main() {
cpuTemp.Set(65.3)
// The Handler function provides a default handler to expose metrics
// via an HTTP server. "/metrics" is the usual endpoint for that.
http.Handle("/metrics", promhttp.Handler())
log.Fatal(http.ListenAndServe(":8080", nil))
}
在此代码中,http 服务器使用该库。promhttp
使用框架时如何修改指标处理程序?我没有在文档中找到答案。gin
明月笑刀无情
温温酱
HUWWW
相关分类