This commit is contained in:
Hyatt 2021-10-30 14:21:54 -05:00
parent aca7f8a8b0
commit feabcd9058
Signed by: nhyatt
GPG Key ID: C50D0BBB5BC40BEA
2 changed files with 17 additions and 1 deletions

View File

@ -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"},
)},
} }

View File

@ -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()