Skip to content

Commit 5786b0d

Browse files
janlsteveny91
andauthored
Fix CouchDB 2+ message_queues metric collection (#19521)
* Fix CouchDB 2+ message_queues metric collection At the moment, the `count` value in the metric block is recorded as a gauge. That value is the number of instances of each type of message queue. Say you have two database files open, then `message_queues.couch_file.count` will be `2`. That information is already available in the `_stats` endpoint as `open_os_files`. The actually valuable part of the message_queue metric is the `max` entry, it shows that the longest backlog of messages for each instance type. A longer backlog means a reduction in performance. Without this patch, this value is not available. Technically all of the `max`, `min`, `50`, `90`, `99` are valuable, but I wanted to keep this patch as small as possible until it is clear the change will be accepted. I’m happy to add the other fields as well if desired. * OPTIONAL: expose more useful message_queues metrics * lint * fix: add assertions for new stats * add new message queue metric descriptions * changelog * move changelog * delete --------- Co-authored-by: steveny91 <steven.yuen@datadoghq.com>
1 parent 02fc83f commit 5786b0d

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

couch/changelog.d/19521.added

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add support for collecting different metric aggregations for message_queue metrics.

couch/datadog_checks/couch/couch.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,18 @@ def _build_system_metrics(self, data, tags, prefix='couchdb.erlang'):
247247
queue_tags = list(tags)
248248
queue_tags.append("queue:{0}".format(queue))
249249
if isinstance(val, dict):
250-
if 'count' in val:
251-
self.gauge("{0}.{1}.size".format(prefix, key), val['count'], queue_tags)
250+
if 'max' in val:
251+
self.gauge("{0}.{1}.max".format(prefix, key), val['max'], queue_tags)
252+
if 'min' in val:
253+
self.gauge("{0}.{1}.min".format(prefix, key), val['min'], queue_tags)
254+
if '50' in val:
255+
self.gauge("{0}.{1}.50".format(prefix, key), val['50'], queue_tags)
256+
if '90' in val:
257+
self.gauge("{0}.{1}.90".format(prefix, key), val['90'], queue_tags)
258+
if '99' in val:
259+
self.gauge("{0}.{1}.99".format(prefix, key), val['99'], queue_tags)
252260
else:
253-
self.agent_check.log.debug(
254-
"Queue %s does not have a key 'count'. It will be ignored.", queue
255-
)
261+
self.agent_check.log.debug("Queue %s does not have any keys. It will be ignored.", queue)
256262
else:
257263
self.gauge("{0}.{1}.size".format(prefix, key), val, queue_tags)
258264
elif key == "distribution":

couch/metadata.csv

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,12 @@ couchdb.erlang.memory.ets,gauge,,byte,,,0,couchdb,,
260260
couchdb.erlang.memory.other,gauge,,byte,,,0,couchdb,,
261261
couchdb.erlang.memory.processes,gauge,,byte,,,0,couchdb,,
262262
couchdb.erlang.memory.processes_used,gauge,,byte,,,0,couchdb,,
263-
couchdb.erlang.message_queues.size,gauge,,,,,0,couchdb,,
263+
couchdb.erlang.message_queues.size,gauge,,,,number of message queues,0,couchdb,,
264+
couchdb.erlang.message_queues.max,gauge,,,,max message queue length,0,couchdb,,
265+
couchdb.erlang.message_queues.min,gauge,,,,min message queue length,0,couchdb,,
266+
couchdb.erlang.message_queues.50,gauge,,,,50th percentile message queue length,0,couchdb,,
267+
couchdb.erlang.message_queues.90,gauge,,,,90th percentile message queue length,0,couchdb,,
268+
couchdb.erlang.message_queues.99,gauge,,,,99th percentile message queue length,0,couchdb,,
264269
couchdb.erlang.os_proc_count,gauge,,,,,0,couchdb,,
265270
couchdb.erlang.process_count,gauge,,,,,0,couchdb,,
266271
couchdb.erlang.process_limit,gauge,,,,,0,couchdb,,

0 commit comments

Comments
 (0)