diff options
author | Will Holley <will.holley@uk.ibm.com> | 2023-03-30 13:20:52 +0000 |
---|---|---|
committer | Will Holley <will.holley@uk.ibm.com> | 2023-04-03 11:32:56 +0000 |
commit | ee11952c86ac24cdc1bce6c92cd8530ff6b1e925 (patch) | |
tree | e37b4ccb168b9fe6ed83c59deb6455943e073968 | |
parent | f4fd6b5d337c272664b371addaa5e285f924e931 (diff) | |
download | couchdb-ee11952c86ac24cdc1bce6c92cd8530ff6b1e925.tar.gz |
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).
-rw-r--r-- | src/couch_prometheus/src/couch_prometheus_server.erl | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/couch_prometheus/src/couch_prometheus_server.erl b/src/couch_prometheus/src/couch_prometheus_server.erl index 0fd169404..05cd26265 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,17 @@ 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}) -> |