aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/system.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2024-02-20 12:37:55 +0100
committerAlex Auvolat <alex@adnab.me>2024-02-20 13:50:45 +0100
commit3cdf69f07924d120c572577495789774535daafe (patch)
tree794c4edc27c7a0761d604f584dcca8b48dbed0ae /src/rpc/system.rs
parent00d479358d31b445bfbe6d7ee3c37520be7e6d85 (diff)
downloadgarage-3cdf69f07924d120c572577495789774535daafe.tar.gz
garage-3cdf69f07924d120c572577495789774535daafe.zip
[peer-metrics] Add metrics for cluster health, like GetClusterHealth admin API
Diffstat (limited to 'src/rpc/system.rs')
-rw-r--r--src/rpc/system.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/rpc/system.rs b/src/rpc/system.rs
index 4a505f58..8ecefd84 100644
--- a/src/rpc/system.rs
+++ b/src/rpc/system.rs
@@ -104,7 +104,7 @@ pub struct System {
#[cfg(feature = "kubernetes-discovery")]
kubernetes_discovery: Option<KubernetesDiscoveryConfig>,
- _metrics: SystemMetrics,
+ metrics: SystemMetrics,
replication_mode: ReplicationMode,
replication_factor: usize,
@@ -168,7 +168,7 @@ pub struct ClusterHealth {
pub partitions_all_ok: usize,
}
-#[derive(Debug, Clone, Copy)]
+#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum ClusterHealthStatus {
/// All nodes are available
Healthy,
@@ -376,7 +376,7 @@ impl System {
consul_discovery,
#[cfg(feature = "kubernetes-discovery")]
kubernetes_discovery: config.kubernetes_discovery.clone(),
- _metrics: metrics,
+ metrics,
ring,
update_ring: Mutex::new(update_ring),
@@ -698,7 +698,13 @@ impl System {
while !*stop_signal.borrow() {
let restart_at = Instant::now() + STATUS_EXCHANGE_INTERVAL;
+ // Update local node status that is exchanged.
+ // Status variables are exported into Prometheus in SystemMetrics,
+ // so we take the opportunity to also update here the health status
+ // that is reported in those metrics.
self.update_local_status();
+ *self.metrics.health.write().unwrap() = Some(self.health());
+
let local_status: NodeStatus = self.local_status.read().unwrap().clone();
let _ = self
.rpc