Skip to content

Commit

Permalink
add comments to metrics to indicate which collector it comes from (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
lu-zhengda authored Sep 18, 2024
1 parent 1ab760b commit d744388
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion mongo/datadog_checks/mongo/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
Core metrics collected by default.
"""
BASE_METRICS = {
# server_status collector
"asserts.msg": RATE,
"asserts.regular": RATE,
"asserts.rollovers": RATE,
Expand Down Expand Up @@ -125,14 +126,17 @@
"opcountersRepl.insert": RATE,
"opcountersRepl.query": RATE,
"opcountersRepl.update": RATE,
# replication_info collector
"oplog.logSizeMB": GAUGE,
"oplog.usedSizeMB": GAUGE,
"oplog.timeDiff": GAUGE,
# replica collector
"replSet.health": GAUGE,
"replSet.replicationLag": GAUGE,
"replSet.state": GAUGE,
"replSet.votes": GAUGE,
"replSet.voteFraction": GAUGE,
# db_stats collector
"stats.avgObjSize": GAUGE,
"stats.collections": GAUGE,
"stats.dataSize": GAUGE,
Expand All @@ -150,8 +154,10 @@
"stats.fsUsedSize": GAUGE,
"stats.fsTotalSize": GAUGE,
"stats.views": GAUGE,
# session_stats collector
"sessions.count": GAUGE,
"uptime": GAUGE,
# host_info collector
"system.memSizeMB": (GAUGE, "system.mem.total"), # total amount of system memory
"system.memLimitMB": (GAUGE, "system.mem.limit"), # memory usage limit
"system.numCores": (GAUGE, "system.cpu.cores"), # number of CPU cores
Expand Down Expand Up @@ -186,7 +192,8 @@
https://docs.mongodb.org/manual/reference/command/serverStatus/#serverStatus.metrics.commands
"""
COMMANDS_METRICS = {
# Required version >
# Required version > 3.0.0
# server_status collector
"metrics.commands.count.failed": RATE,
"metrics.commands.count.total": GAUGE,
"metrics.commands.createIndexes.failed": RATE,
Expand All @@ -210,6 +217,7 @@
https://docs.mongodb.org/manual/reference/command/serverStatus/#server-status-locks
"""
LOCKS_METRICS = {
# server_status collector
"locks.Collection.acquireCount.R": RATE,
"locks.Collection.acquireCount.r": RATE,
"locks.Collection.acquireCount.W": RATE,
Expand Down Expand Up @@ -262,6 +270,7 @@
TCMalloc memory allocator report.
"""
TCMALLOC_METRICS = {
# server_status collector
"tcmalloc.generic.current_allocated_bytes": GAUGE,
"tcmalloc.generic.heap_size": GAUGE,
"tcmalloc.tcmalloc.aggressive_memory_decommit": GAUGE,
Expand All @@ -279,6 +288,7 @@
WiredTiger storage engine.
"""
WIREDTIGER_METRICS = {
# server_status collector
"wiredTiger.cache.bytes currently in the cache": (GAUGE, "wiredTiger.cache.bytes_currently_in_cache"),
"wiredTiger.cache.bytes read into cache": GAUGE,
"wiredTiger.cache.bytes written from cache": GAUGE,
Expand Down Expand Up @@ -315,6 +325,7 @@
https://docs.mongodb.org/v3.0/reference/command/top/
"""
TOP_METRICS = {
# top collector
"commands.count": RATE,
"commands.time": GAUGE,
"getmore.count": RATE,
Expand All @@ -337,6 +348,7 @@

COLLECTION_METRICS = {
# collection storage stats
# coll_stats collector
'collection.size': GAUGE,
'collection.avgObjSize': GAUGE,
'collection.count': GAUGE,
Expand Down Expand Up @@ -365,13 +377,15 @@
}

SHARDED_DATA_DISTRIBUTION_METRICS = {
# sharded_data_distribution collector
'numOrphanedDocs': (GAUGE, 'sharded_data_distribution.num_orphaned_docs'),
'numOwnedDocuments': (GAUGE, 'sharded_data_distribution.num_owned_documents'),
'ownedSizeBytes': (GAUGE, 'sharded_data_distribution.owned_size_bytes'),
'orphanedSizeBytes': (GAUGE, 'sharded_data_distribution.orphaned_size_bytes'),
}

INDEX_METRICS = {
# index stats collector
'indexes.accesses.ops': RATE,
}

Expand Down

0 comments on commit d744388

Please sign in to comment.