This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/main by this push:
new 84ed47f91 Add detailed node membership info to prometheus
84ed47f91 is described below
commit 84ed47f916cbeb652f3bccf7a46db6b73b00e7cf
Author: Nick Vatamaniuc <[email protected]>
AuthorDate: Fri Apr 25 19:16:27 2025 -0400
Add detailed node membership info to prometheus
One of our users in #5485 reported they would like to be able have a more
detailed picture of node connections and disconnections (are expected nodes
connected or disconnected) in prometheus, so that's what this PR does.
We already used per-node metrics for dist channel stats so went with the
same
format: `{node="..."} 0/1`
```
couchdb_membership{nodes="cluster_nodes"} 3
couchdb_membership{nodes="all_nodes"} 3
couchdb_membership{node="[email protected]"} 1
couchdb_membership{node="[email protected]"} 1
couchdb_erlang_distribution_recv_oct_bytes_total{node="[email protected]"}
40962
couchdb_erlang_distribution_recv_oct_bytes_total{node="[email protected]"}
25681
```
Fix: #5485
---
src/couch_prometheus/src/couch_prometheus.erl | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/couch_prometheus/src/couch_prometheus.erl
b/src/couch_prometheus/src/couch_prometheus.erl
index ee9a2b6ce..4d053d1af 100644
--- a/src/couch_prometheus/src/couch_prometheus.erl
+++ b/src/couch_prometheus/src/couch_prometheus.erl
@@ -67,6 +67,7 @@ get_system_stats() ->
get_ets_stats(),
get_internal_replication_jobs_stat(),
get_membership_stat(),
+ get_membership_nodes(),
get_distribution_stats()
]).
@@ -98,6 +99,19 @@ get_membership_stat() ->
],
to_prom(membership, gauge, "count of nodes in the cluster", Labels).
+get_membership_nodes() ->
+ Self = config:node_name(),
+ Expected = mem3:nodes() -- [Self],
+ Nodes = nodes(),
+ Disconnected = Expected -- Nodes,
+ % Extra nodes, connected but not part of mem3
+ Extra = Nodes -- Expected,
+ Connected = Nodes -- Extra,
+ ConnectedLabels = [{[{node, N}], 1} || N <- lists:sort(Connected)],
+ DisconnectedLables = [{[{node, N}], 0} || N <- lists:sort(Disconnected)],
+ Labels = ConnectedLabels ++ DisconnectedLables,
+ to_prom(membership_nodes, gauge, "cluster node connectivity", Labels).
+
get_vm_stats() ->
MemLabels = lists:map(
fun({Type, Value}) ->