-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmetric.go
63 lines (54 loc) · 1.32 KB
/
metric.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"github.com/prometheus/client_golang/prometheus"
)
var (
labels = []string{"name", "mac", "type"}
errorCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "shelly_error_count",
Help: "Shows number of failed requests for device",
},
labels,
)
temperatureGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "shelly_temperature",
Help: "Shows current temperature",
},
labels,
)
isOvertemperatureGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "shelly_overtemperature",
Help: "Shows wether device is over normal temperature",
},
labels,
)
voltageGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "shelly_voltage",
Help: "Shows current voltage"},
labels,
)
uptimeGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "shelly_uptime",
Help: "Shows current uptime"},
labels,
)
isUpdateAvailableGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "shelly_update_available",
Help: "Shows whether an update is available"},
labels,
)
)
func registerMetrics() {
prometheus.Register(errorCounter)
prometheus.Register(temperatureGauge)
prometheus.Register(isOvertemperatureGauge)
prometheus.Register(voltageGauge)
prometheus.Register(uptimeGauge)
prometheus.Register(isUpdateAvailableGauge)
}