@@ -22,6 +22,9 @@ const (
22
22
UnHealthSleep = 10 * time .Second
23
23
24
24
MissedVotesCounterMetricName = "missed_votes_counter"
25
+ ActiveMetricName = "active"
26
+ StatusMetricName = "status"
27
+
25
28
VotingPowerMetricName = "voting_power"
26
29
SignedVotesWindowMetricName = "signed_votes_window"
27
30
MinSignedPerWindowMetricName = "min_signed_per_window"
@@ -66,8 +69,30 @@ func loop(exporter *common.Exporter, p common.Packager) {
66
69
common .MonikerLabel ,
67
70
common .OrchestratorAddressLabel ,
68
71
common .BTCPKLabel ,
69
- common .StatusLabel ,
70
- common .ActiveLabel ,
72
+ })
73
+
74
+ activeMetric := p .Factory .NewGaugeVec (prometheus.GaugeOpts {
75
+ Namespace : common .Namespace ,
76
+ Subsystem : Subsystem ,
77
+ Name : ActiveMetricName ,
78
+ ConstLabels : packageLabels ,
79
+ Help : "active status of finality provider, 1 means active, 0 means inactive" ,
80
+ }, []string {
81
+ common .MonikerLabel ,
82
+ common .OrchestratorAddressLabel ,
83
+ common .BTCPKLabel ,
84
+ })
85
+
86
+ statusMetric := p .Factory .NewGaugeVec (prometheus.GaugeOpts {
87
+ Namespace : common .Namespace ,
88
+ Subsystem : Subsystem ,
89
+ Name : StatusMetricName ,
90
+ ConstLabels : packageLabels ,
91
+ Help : "specific status of finality provider, 1 means active, 0 means jailed, -1 means slashed" ,
92
+ }, []string {
93
+ common .MonikerLabel ,
94
+ common .OrchestratorAddressLabel ,
95
+ common .BTCPKLabel ,
71
96
})
72
97
73
98
vpMetric := p .Factory .NewGaugeVec (prometheus.GaugeOpts {
@@ -79,8 +104,6 @@ func loop(exporter *common.Exporter, p common.Packager) {
79
104
common .MonikerLabel ,
80
105
common .OrchestratorAddressLabel ,
81
106
common .BTCPKLabel ,
82
- common .StatusLabel ,
83
- common .ActiveLabel ,
84
107
})
85
108
86
109
// metrics for each chain
@@ -183,22 +206,32 @@ func loop(exporter *common.Exporter, p common.Packager) {
183
206
common .MonikerLabel : item .Moniker ,
184
207
common .BTCPKLabel : item .BTCPK ,
185
208
common .OrchestratorAddressLabel : item .Address ,
186
- common .StatusLabel : item .Status ,
187
- common .ActiveLabel : item .Active ,
188
209
}).
189
210
Set (float64 (item .MissedBlockCounter ))
190
211
191
- if item .VotingPower != 0 {
192
- vpMetric .
193
- With (prometheus.Labels {
194
- common .MonikerLabel : item .Moniker ,
195
- common .BTCPKLabel : item .BTCPK ,
196
- common .OrchestratorAddressLabel : item .Address ,
197
- common .StatusLabel : item .Status ,
198
- common .ActiveLabel : item .Active ,
199
- }).
200
- Set (item .VotingPower )
201
- }
212
+ vpMetric .
213
+ With (prometheus.Labels {
214
+ common .MonikerLabel : item .Moniker ,
215
+ common .BTCPKLabel : item .BTCPK ,
216
+ common .OrchestratorAddressLabel : item .Address ,
217
+ }).
218
+ Set (item .VotingPower )
219
+
220
+ activeMetric .
221
+ With (prometheus.Labels {
222
+ common .MonikerLabel : item .Moniker ,
223
+ common .BTCPKLabel : item .BTCPK ,
224
+ common .OrchestratorAddressLabel : item .Address ,
225
+ }).
226
+ Set (item .Active )
227
+
228
+ statusMetric .
229
+ With (prometheus.Labels {
230
+ common .MonikerLabel : item .Moniker ,
231
+ common .BTCPKLabel : item .BTCPK ,
232
+ common .OrchestratorAddressLabel : item .Address ,
233
+ }).
234
+ Set (item .Status )
202
235
}
203
236
204
237
fpTotalMetric .With (prometheus.Labels {common .StatusLabel : "active" }).Set (float64 (status .FinalityProviderTotal .Active ))
@@ -213,22 +246,32 @@ func loop(exporter *common.Exporter, p common.Packager) {
213
246
common .MonikerLabel : item .Moniker ,
214
247
common .BTCPKLabel : item .BTCPK ,
215
248
common .OrchestratorAddressLabel : item .Address ,
216
- common .StatusLabel : item .Status ,
217
- common .ActiveLabel : item .Active ,
218
249
}).
219
250
Set (float64 (item .MissedBlockCounter ))
220
251
221
- if item .VotingPower != 0 {
222
- vpMetric .
223
- With (prometheus.Labels {
224
- common .MonikerLabel : item .Moniker ,
225
- common .BTCPKLabel : item .BTCPK ,
226
- common .OrchestratorAddressLabel : item .Address ,
227
- common .StatusLabel : item .Status ,
228
- common .ActiveLabel : item .Active ,
229
- }).
230
- Set (item .VotingPower )
231
- }
252
+ vpMetric .
253
+ With (prometheus.Labels {
254
+ common .MonikerLabel : item .Moniker ,
255
+ common .BTCPKLabel : item .BTCPK ,
256
+ common .OrchestratorAddressLabel : item .Address ,
257
+ }).
258
+ Set (item .VotingPower )
259
+
260
+ activeMetric .
261
+ With (prometheus.Labels {
262
+ common .MonikerLabel : item .Moniker ,
263
+ common .BTCPKLabel : item .BTCPK ,
264
+ common .OrchestratorAddressLabel : item .Address ,
265
+ }).
266
+ Set (item .Active )
267
+
268
+ statusMetric .
269
+ With (prometheus.Labels {
270
+ common .MonikerLabel : item .Moniker ,
271
+ common .BTCPKLabel : item .BTCPK ,
272
+ common .OrchestratorAddressLabel : item .Address ,
273
+ }).
274
+ Set (item .Status )
232
275
}
233
276
}
234
277
}
0 commit comments