You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by wi...@apache.org on 2023/03/31 15:31:25 UTC
[couchdb] 03/04: feat (prometheus): membership metric
This is an automated email from the ASF dual-hosted git repository.
willholley pushed a commit to branch prometheus_metrics
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 78327f252648aed51d7a68b98273155debe3f905
Author: Will Holley <wi...@uk.ibm.com>
AuthorDate: Thu Mar 30 13:20:52 2023 +0000
feat (prometheus): membership metric
Add a gauge metric `membership` to the `_prometheus` endpoint. The metric
has labels:
- `nodes=all_nodes`
- `nodes=cluster_nodes`
matching the fields in the `_membership` endpoint (I think consistency
here is more useful than renaming the labels to e.g. expected/actual).
---
src/couch_prometheus/src/couch_prometheus_server.erl | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/couch_prometheus/src/couch_prometheus_server.erl b/src/couch_prometheus/src/couch_prometheus_server.erl
index 0fd169404..9bdf6242e 100644
--- a/src/couch_prometheus/src/couch_prometheus_server.erl
+++ b/src/couch_prometheus/src/couch_prometheus_server.erl
@@ -113,7 +113,8 @@ get_system_stats() ->
get_run_queue_stats(),
get_vm_stats(),
get_ets_stats(),
- get_internal_replication_jobs_stat()
+ get_internal_replication_jobs_stat(),
+ get_membership_stat()
]).
get_uptime_stat() ->
@@ -127,6 +128,19 @@ get_internal_replication_jobs_stat() ->
mem3_sync:get_backlog()
).
+
+get_membership_stat() ->
+ % expected nodes
+ ClusterNodes = mem3:nodes(),
+ % connected nodes
+ AllNodes = nodes([this, visible]),
+ Labels = [
+ {[{nodes, "cluster_nodes"}], length(ClusterNodes)},
+ {[{nodes, "all_nodes"}], length(AllNodes)}
+ ],
+ to_prom(membership, gauge, "count of nodes in the cluster", Labels).
+
+
get_vm_stats() ->
MemLabels = lists:map(
fun({Type, Value}) ->