@@ -10,6 +10,7 @@ import (
10
10
"encoding/json"
11
11
"time"
12
12
13
+ "github.com/prometheus/client_golang/prometheus"
13
14
"github.com/zjshen14/go-fsm"
14
15
15
16
"github.com/iotexproject/iotex-core/consensus"
@@ -22,6 +23,18 @@ import (
22
23
// TODO: HeartbeatHandler opens encapsulation of a few structs to inspect the internal status, we need to find a better
23
24
// approach to do so in the future
24
25
26
+ var heartbeatMtc = prometheus .NewGaugeVec (
27
+ prometheus.GaugeOpts {
28
+ Name : "iotex_heartbeat_status" ,
29
+ Help : "Node heartbeat status." ,
30
+ },
31
+ []string {"status_type" },
32
+ )
33
+
34
+ func init () {
35
+ prometheus .MustRegister (heartbeatMtc )
36
+ }
37
+
25
38
// HeartbeatHandler is the handler to periodically log the system key metrics
26
39
type HeartbeatHandler struct {
27
40
s * Server
@@ -91,17 +104,30 @@ func (h *HeartbeatHandler) Log() {
91
104
height = 0
92
105
}
93
106
107
+ actPoolSize := h .s .actPool .GetSize ()
108
+ actPoolCapacity := h .s .actPool .GetCapacity ()
109
+ pendingActs := h .s .actPool .GetUnconfirmedActSize ()
110
+
94
111
logger .Info ().
95
- Uint ("num-peers " , numPeers ).
96
- Time ("last-out " , lastOutTime ).
97
- Time ("last-in " , lastInTime ).
98
- Int ("dispatcher-events " , numDPEvts ).
99
- Str ("dispatcher-events-audit " , string (dpEvtsAudit )).
100
- Int ("rolldpos-events " , numPendingEvts ).
101
- Str ("fsm-state " , string (state )).
102
- Uint64 ("height " , height ).
103
- Uint64 ("actpool-size " , h . s . actPool . GetSize () ).
104
- Uint64 ("actpool-capacity " , h . s . actPool . GetCapacity () ).
105
- Uint64 ("actpool-unconfirmed-size " , h . s . actPool . GetUnconfirmedActSize () ).
112
+ Uint ("numPeers " , numPeers ).
113
+ Time ("lastOut " , lastOutTime ).
114
+ Time ("lastIn " , lastInTime ).
115
+ Int ("pendingDispatcherEvents " , numDPEvts ).
116
+ Str ("pendingDispatcherEventsAudit " , string (dpEvtsAudit )).
117
+ Int ("rolldposEvents " , numPendingEvts ).
118
+ Str ("fsmState " , string (state )).
119
+ Uint64 ("blockchainHeight " , height ).
120
+ Uint64 ("actpoolSize " , actPoolSize ).
121
+ Uint64 ("actpoolCapacity " , actPoolCapacity ).
122
+ Uint64 ("pendingActions " , pendingActs ).
106
123
Msg ("node status" )
124
+
125
+ heartbeatMtc .WithLabelValues ("numPeers" ).Set (float64 (numPeers ))
126
+ heartbeatMtc .WithLabelValues ("pendingDispatcherEvents" ).Set (float64 (numDPEvts ))
127
+ heartbeatMtc .WithLabelValues ("pendingRolldposEvents" ).Set (float64 (numPendingEvts ))
128
+ heartbeatMtc .WithLabelValues ("blockchainHeight" ).Set (float64 (height ))
129
+ heartbeatMtc .WithLabelValues ("actpoolSize" ).Set (float64 (actPoolSize ))
130
+ heartbeatMtc .WithLabelValues ("actpoolCapacity" ).Set (float64 (actPoolCapacity ))
131
+ heartbeatMtc .WithLabelValues ("pendingActions" ).Set (float64 (actPoolCapacity ))
132
+
107
133
}
0 commit comments