metrics
This commit is contained in:
parent
aca7f8a8b0
commit
feabcd9058
@ -29,7 +29,7 @@ type configStructure struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type configPrometheus struct {
|
type configPrometheus struct {
|
||||||
Temperature prometheus.Gauge
|
Temperature *prometheus.GaugeVec
|
||||||
}
|
}
|
||||||
|
|
||||||
var config = configStructure{
|
var config = configStructure{
|
||||||
@ -41,4 +41,14 @@ var config = configStructure{
|
|||||||
WebSrvReadTimeout: 5,
|
WebSrvReadTimeout: 5,
|
||||||
WebSrvWriteTimeout: 2,
|
WebSrvWriteTimeout: 2,
|
||||||
WebSrvIdleTimeout: 2,
|
WebSrvIdleTimeout: 2,
|
||||||
|
|
||||||
|
Prometheus: configPrometheus{
|
||||||
|
Temperature: prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||||
|
Namespace: "server_room",
|
||||||
|
Subsystem: "exhaust",
|
||||||
|
Name: "temp",
|
||||||
|
Help: "Temperature measured in the server room",
|
||||||
|
},
|
||||||
|
[]string{"unit"},
|
||||||
|
)},
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func forever() {
|
func forever() {
|
||||||
@ -16,6 +18,10 @@ func forever() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
prometheus.MustRegister(config.Prometheus.Temperature)
|
||||||
|
config.Prometheus.Temperature.With(prometheus.Labels{"unit": "celsius"}).Set(100)
|
||||||
|
config.Prometheus.Temperature.With(prometheus.Labels{"unit": "fahrenheit"}).Set(100)
|
||||||
|
config.Prometheus.Temperature.With(prometheus.Labels{"unit": "kelvin"}).Set(100)
|
||||||
go httpServer("0.0.0.0", 8080)
|
go httpServer("0.0.0.0", 8080)
|
||||||
forever()
|
forever()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user