diff --git a/cmd/go-temper/config.go b/cmd/go-temper/config.go index 96513a2..46fa422 100644 --- a/cmd/go-temper/config.go +++ b/cmd/go-temper/config.go @@ -29,7 +29,7 @@ type configStructure struct { } type configPrometheus struct { - Temperature prometheus.Gauge + Temperature *prometheus.GaugeVec } var config = configStructure{ @@ -41,4 +41,14 @@ var config = configStructure{ WebSrvReadTimeout: 5, WebSrvWriteTimeout: 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"}, + )}, } diff --git a/cmd/go-temper/main.go b/cmd/go-temper/main.go index 114cd42..756065c 100644 --- a/cmd/go-temper/main.go +++ b/cmd/go-temper/main.go @@ -5,6 +5,8 @@ import ( "os" "os/signal" "syscall" + + "github.com/prometheus/client_golang/prometheus" ) func forever() { @@ -16,6 +18,10 @@ func forever() { } 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) forever()