-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetrics.go
68 lines (58 loc) · 1.85 KB
/
metrics.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
64
65
66
67
68
package main
import (
"github.com/prometheus/client_golang/prometheus"
)
type (
MyUplinkMetrics struct {
system *prometheus.GaugeVec
systemDevice *prometheus.GaugeVec
systemDevicePoint *prometheus.GaugeVec
systemDevicePointEnum *prometheus.GaugeVec
systemDevicePointTotal *prometheus.GaugeVec
}
)
func NewMyUplinkMetrics(registry *prometheus.Registry) *MyUplinkMetrics {
metrics := &MyUplinkMetrics{}
pointLabels := []string{"systemID", "deviceID", "category", "parameterID", "parameterName", "parameterUnit"}
metrics.system = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "myuplink_system_info",
Help: "myUplink system information",
},
[]string{"systemID", "systemName", "country"},
)
registry.MustRegister(metrics.system)
metrics.systemDevice = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "myuplink_system_device_info",
Help: "myUplink system device information",
},
[]string{"systemID", "deviceID", "deviceName", "serialNumber", "connectionState", "firmwareVersion"},
)
registry.MustRegister(metrics.systemDevice)
metrics.systemDevicePoint = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "myuplink_system_device_point",
Help: "myUplink device metric point",
},
pointLabels,
)
registry.MustRegister(metrics.systemDevicePoint)
metrics.systemDevicePointEnum = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "myuplink_system_device_point_enum",
Help: "myUplink device metric point enum value",
},
append(pointLabels, "valueText"),
)
registry.MustRegister(metrics.systemDevicePointEnum)
metrics.systemDevicePointTotal = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "myuplink_system_device_point_total",
Help: "myUplink device metric point total",
},
pointLabels,
)
registry.MustRegister(metrics.systemDevicePointTotal)
return metrics
}