-
Notifications
You must be signed in to change notification settings - Fork 0
/
metrics.go
82 lines (78 loc) · 2.31 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package brewtracker
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
const Namespace = "brewtracker"
type metrics struct {
beerReading *prometheus.CounterVec
beerMeasuredOriginalGravity *prometheus.GaugeVec
beerEstimatedFinalGravity *prometheus.GaugeVec
beerEstimatedIbu *prometheus.GaugeVec
beerEstimatedSrm *prometheus.GaugeVec
beerGravity *prometheus.GaugeVec
beerTemperatureF *prometheus.GaugeVec
beerTemperatureC *prometheus.GaugeVec
}
func NewMetrics() *metrics {
m := &metrics{
beerReading: promauto.NewCounterVec(prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: "tilt",
Name: "readings_taken_total",
Help: "total number of beer readings taken",
},
[]string{"color"},
),
beerMeasuredOriginalGravity: promauto.NewGaugeVec(prometheus.GaugeOpts{
Namespace: Namespace,
Name: "measured_og",
Help: "Measured original gravity",
},
[]string{"id", "name"},
),
beerEstimatedFinalGravity: promauto.NewGaugeVec(prometheus.GaugeOpts{
Namespace: Namespace,
Name: "estimated_fg",
Help: "Brewfather estimated final gravity",
},
[]string{"id", "name"},
),
beerEstimatedIbu: promauto.NewGaugeVec(prometheus.GaugeOpts{
Namespace: Namespace,
Name: "estimated_ibu",
Help: "Brewfather estimated IBU",
},
[]string{"id", "name"},
),
beerEstimatedSrm: promauto.NewGaugeVec(prometheus.GaugeOpts{
Namespace: Namespace,
Name: "estimated_srm",
Help: "Estimated SRM",
},
[]string{"id", "name"},
),
beerGravity: promauto.NewGaugeVec(prometheus.GaugeOpts{
Namespace: Namespace,
Name: "gravity_reading",
Help: "latest specfic gravity reading",
},
[]string{"id", "name", "tilt_color"},
),
beerTemperatureF: promauto.NewGaugeVec(prometheus.GaugeOpts{
Namespace: Namespace,
Name: "temperature_reading_f",
Help: "latest temperature reading",
},
[]string{"id", "name", "tilt_color"},
),
beerTemperatureC: promauto.NewGaugeVec(prometheus.GaugeOpts{
Namespace: Namespace,
Name: "temperature_reading_c",
Help: "latest temperature reading",
},
[]string{"id", "name", "tilt_color"},
),
}
return m
}