Monitoring
RaftNodeReport contains detailed information about
internal state of a RaftNode, such as its Raft role, term, leader, last log
index, and commit index. We can feed our external monitoring systems with these
information pieces as follows:
-
We can build a simple pull-based system to query
RaftNodeReportobjects viaRaftNode.getReport()and publish those objects to any external monitoring system. -
MicroRaft contains another abstraction,
RaftNodeReportListenerwhich is called by Raft nodes anytime there is an important change in the internal Raft state, such as leader change, term change, or snapshot installation. We can also use this abstraction to captureRaftNodeReportobjects and notify external monitoring systems promptly with a push-based approach.
Micrometer integration
MicroRaft offers a module to publish Raft node metrics to external systems easily via the Micrometer project. Just add the following dependency to the classpath for using the Micrometer integration.
<dependency>
<groupId>io.microraft</groupId>
<artifactId>microraft-metrics</artifactId>
<version>0.1</version>
</dependency>
RaftNodeMetrics implements the RaftNodeReportListener interface and can be injected into
created RaftNode instances via RaftNodeBuilder.setRaftNodeReportListener().
Then, several metrics extracted from published RaftNodeReport objects are
passed to meter registries.