-
Notifications
You must be signed in to change notification settings - Fork 2
/
metrics.go
180 lines (169 loc) · 5.04 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
package main
import "github.com/prometheus/client_golang/prometheus"
var (
Temperature *prometheus.GaugeVec
Humidity *prometheus.GaugeVec
ChPm1dot0 *prometheus.GaugeVec
ChPm2dot5 *prometheus.GaugeVec
ChPm10 *prometheus.GaugeVec
UsPm1dot0 *prometheus.GaugeVec
UsPm2dot5 *prometheus.GaugeVec
UsPm10 *prometheus.GaugeVec
Gt0dot3um *prometheus.GaugeVec
Gt0dot5um *prometheus.GaugeVec
Gt1dot0um *prometheus.GaugeVec
Gt2dot5um *prometheus.GaugeVec
Gt5dot0um *prometheus.GaugeVec
Gt10um *prometheus.GaugeVec
Co2 *prometheus.GaugeVec
Hcho *prometheus.GaugeVec
Tvoc *prometheus.GaugeVec
Aqiatpm2dot5 *prometheus.GaugeVec
)
// SetupMetrics 定义指标
func SetupMetrics() {
Temperature = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "meter_temperature",
Help: "Current temperature in ℃ / 温度摄氏度℃",
}, []string{
"sensor_id",
"sensor_location",
})
Humidity = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "meter_humidity",
Help: "Current humidity level in % / 湿度百分比%",
}, []string{
"sensor_id",
"sensor_location",
})
ChPm1dot0 = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "meter_ch_pm1dot0",
Help: "Current ch pm1.0 level in ug/m³ / 国标CH PM1.0 ug/m³",
}, []string{
"sensor_id",
"sensor_location",
})
ChPm2dot5 = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "meter_ch_pm2dot5",
Help: "Current ch pm2.5 level in ug/m³ / 国标CH PM2.5 ug/m³",
}, []string{
"sensor_id",
"sensor_location",
})
ChPm10 = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "meter_ch_pm10",
Help: "Current ch pm10 level in ug/m³ / 国标CH PM10 ug/m³",
}, []string{
"sensor_id",
"sensor_location",
})
UsPm1dot0 = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "meter_us_pm1dot0",
Help: "Current us pm1.0 level in ug/m³ / 美标US PM1.0 ug/m³",
}, []string{
"sensor_id",
"sensor_location",
})
UsPm2dot5 = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "meter_us_pm2dot5",
Help: "Current us pm2.5 level in ug/m³ / 美标US PM2.5 ug/m³",
}, []string{
"sensor_id",
"sensor_location",
})
UsPm10 = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "meter_us_pm10",
Help: "Current us pm10 level in ug/m³ / 美标US PM10 ug/m³",
}, []string{
"sensor_id",
"sensor_location",
})
Gt0dot3um = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "meter_gt0dot3um",
Help: "Current >0.3um level in ug/m³ / 直径大于 >0.3um 颗粒物个数 ug/m³",
}, []string{
"sensor_id",
"sensor_location",
})
Gt0dot5um = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "meter_gt0dot5um",
Help: "Current >0.5um level in ug/m³ / 直径大于 >0.5um 颗粒物个数 ug/m³",
}, []string{
"sensor_id",
"sensor_location",
})
Gt1dot0um = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "meter_gt1dot0um",
Help: "Current >1.0um level in ug/m³ / 直径大于 >1.0um 颗粒物个数 ug/m³",
}, []string{
"sensor_id",
"sensor_location",
})
Gt2dot5um = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "meter_gt2dot5um",
Help: "Current >2.5um level in ug/m³ / 直径大于 >2.5um 颗粒物个数 ug/m³",
}, []string{
"sensor_id",
"sensor_location",
})
Gt5dot0um = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "meter_gt5dot0um",
Help: "Current >5.0um level in ug/m³ / 直径大于 >5.0um 颗粒物个数 ug/m³",
}, []string{
"sensor_id",
"sensor_location",
})
Gt10um = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "meter_gt10um",
Help: "Current >10um level in ug/m³ / 直径大于 >10um 颗粒物个数 ug/m³",
}, []string{
"sensor_id",
"sensor_location",
})
Co2 = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "meter_co2",
Help: "Current CO2 level in ppm / 二氧化碳 CO2 < 1000 ppm",
}, []string{
"sensor_id",
"sensor_location",
})
Hcho = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "meter_hcho",
Help: "Current hcho level in mg/m³ / 甲醛 HCHO < 0.08 mg/m³",
}, []string{
"sensor_id",
"sensor_location",
})
Tvoc = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "meter_tvoc",
Help: "Current tvoc level in mg/m³ / 异味 TVOC < 0.8 mg/m³",
}, []string{
"sensor_id",
"sensor_location",
})
Aqiatpm2dot5 = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "meter_aqiatpm2dot5",
Help: "Current [email protected] / [email protected] 空气质量指数",
}, []string{
"sensor_id",
"sensor_location",
})
prometheus.MustRegister(Temperature)
prometheus.MustRegister(Humidity)
prometheus.MustRegister(ChPm1dot0)
prometheus.MustRegister(ChPm2dot5)
prometheus.MustRegister(ChPm10)
prometheus.MustRegister(UsPm1dot0)
prometheus.MustRegister(UsPm2dot5)
prometheus.MustRegister(UsPm10)
prometheus.MustRegister(Gt0dot3um)
prometheus.MustRegister(Gt0dot5um)
prometheus.MustRegister(Gt1dot0um)
prometheus.MustRegister(Gt2dot5um)
prometheus.MustRegister(Gt5dot0um)
prometheus.MustRegister(Gt10um)
prometheus.MustRegister(Co2)
prometheus.MustRegister(Hcho)
prometheus.MustRegister(Tvoc)
prometheus.MustRegister(Aqiatpm2dot5)
}