diff options
author | Will Holley <will.holley@uk.ibm.com> | 2023-03-31 12:25:05 +0000 |
---|---|---|
committer | Will Holley <will.holley@uk.ibm.com> | 2023-04-03 11:33:14 +0000 |
commit | 8c1ef5bfeaa6fbf36dc8147eeff2349ec9edff6e (patch) | |
tree | 96bff7d3b47e1a608060ac6d8c884c07145fd9ad | |
parent | ee11952c86ac24cdc1bce6c92cd8530ff6b1e925 (diff) | |
download | couchdb-8c1ef5bfeaa6fbf36dc8147eeff2349ec9edff6e.tar.gz |
fix (prometheus): gauge types for metrics that can be decremented
Prometheus assumes that metrics with `counter` types are cumulative.
This isn't the case in CouchDB / Folsom, which allows counters to
be decremented.
This changes the type of metrics where we decrement the counter values
to `gauge`:
- couchdb_open_databases
- couchdb_couchdb_open_os_files
- couchdb_httpd_clients_requesting_changes
-rw-r--r-- | src/couch_prometheus/src/couch_prometheus_util.erl | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/couch_prometheus/src/couch_prometheus_util.erl b/src/couch_prometheus/src/couch_prometheus_util.erl index 16886f4a7..5775b9693 100644 --- a/src/couch_prometheus/src/couch_prometheus_util.erl +++ b/src/couch_prometheus/src/couch_prometheus_util.erl @@ -71,6 +71,19 @@ couch_to_prom([couchdb, httpd_status_codes, 200], Info, _All) -> }); couch_to_prom([couchdb, httpd_status_codes, Code], Info, _All) -> to_prom(httpd_status_codes, {[{code, Code}], val(Info)}); +% Convert to gauge in prometheus type. This is required because +% prometheus assumes that counters are cumulative and should be +% rated by default, whereas folsom (the library CouchDB uses for +% metrics) allows counters to be decremented as well. Folsom supports +% gauges but does not track their state to allow increment/decrement. +% Basically, anywhere we use couch_stats:decrement_count we should +% be converting to a prometheus gauge. +couch_to_prom([couchdb, open_databases], Info, _All) -> + to_prom(open_databases, gauge, desc(Info), val(Info)); +couch_to_prom([couchdb, open_os_files], Info, _All) -> + to_prom(open_os_files, gauge, desc(Info), val(Info)); +couch_to_prom([couchdb, httpd, clients_requesting_changes], Info, _All) -> + to_prom(httpd_clients_requesting_changes, gauge, desc(Info), val(Info)); couch_to_prom([ddoc_cache, hit], Info, All) -> Total = val(Info) + val([ddoc_cache, miss], All), to_prom(ddoc_cache_requests_total, counter, "number of design doc cache requests", Total); |