Skip to content

Commit

Permalink
[mongo] emit collectionscans.total and collectionscans.nontailable as…
Browse files Browse the repository at this point in the history
… rate (#18511)

* emit collectionscans.total and collectionscans.nontailable as rate

* add changelog

* update changelog
  • Loading branch information
lu-zhengda authored Sep 5, 2024
1 parent f7b7ff3 commit b7d4b86
Show file tree
Hide file tree
Showing 7 changed files with 216 additions and 6 deletions.
1 change: 1 addition & 0 deletions mongo/changelog.d/18511.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Emit new metrics `mongodb.collection.collectionscans.totalps` & `mongodb.collection.collectionscans.nontailableps`. The new metrics measure the total number of queries that performed a collection scans or collection scans without tailable cursor per second.
1 change: 1 addition & 0 deletions mongo/changelog.d/18511.deprecated
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deprecate metrics `mongodb.collection.collectionscans.nontailable` & `mongodb.collection.collectionscans.total`.
10 changes: 8 additions & 2 deletions mongo/datadog_checks/mongo/collectors/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ def _submit_payload(self, payload, additional_tags=None, metrics_to_collect=None

metric_name_alias = self._normalize(metric_name_alias, submit_method, prefix)
submit_method(self.check, metric_name_alias, value, tags=tags)
if metric_name_alias.endswith("countps") or metric_name_alias.endswith("accesses.opsps"):
# Keep old incorrect metric name (only 'top' and 'index' metrics are affected)
if (
metric_name_alias.endswith("countps")
or metric_name_alias.endswith("accesses.opsps")
or metric_name_alias.endswith("collectionscans.totalps")
or metric_name_alias.endswith("collectionscans.nontailableps")
):
# Keep old incorrect metric name
# 'top' and 'index', 'collectionscans' metrics are affected
self.gauge(metric_name_alias[:-2], value, tags=tags)
4 changes: 2 additions & 2 deletions mongo/datadog_checks/mongo/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@
'collection.transactions.ops': RATE,
'collection.transactions.latency_avg': (GAUGE, 'collection.transactions.latency.avg'),
# collection query exec stats
'collection.collectionScans.total': GAUGE,
'collection.collectionScans.nonTailable': GAUGE,
'collection.collectionScans.total': RATE,
'collection.collectionScans.nonTailable': RATE,
}

SHARDED_DATA_DISTRIBUTION_METRICS = {
Expand Down
6 changes: 4 additions & 2 deletions mongo/metadata.csv
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ mongodb.chunks.jumbo,gauge,,,,Total number of 'jumbo' chunks in the mongo cluste
mongodb.chunks.total,gauge,,,,Total number of chunks in the mongo cluster.,0,mongodb,,,
mongodb.collection.avgobjsize,gauge,,byte,,The size of the average object in the collection in bytes.,0,mongodb,average object size in bytes,,
mongodb.collection.capped,gauge,,record,,Whether or not the collection is capped.,0,mongodb,collection cap,,
mongodb.collection.collectionscans.nontailable,gauge,,scan,,Number of times the collection was scanned without tailable cursor.,0,mongodb,collection scans non tailable,,
mongodb.collection.collectionscans.total,gauge,,scan,,Total number of times the collection was scanned.,0,mongodb,collection scans total,,
mongodb.collection.collectionscans.nontailable,gauge,,scan,,Number of times the collection was scanned without tailable cursor (deprecated).,0,mongodb,collection scans non tailable,,
mongodb.collection.collectionscans.nontailableps,gauge,,scan,second,Number of times the collection was scanned without tailable cursor per second.,0,mongodb,collection scans non tailable per second,,
mongodb.collection.collectionscans.total,gauge,,scan,,Total number of times the collection was scanned (deprecated).,0,mongodb,collection scans total,,
mongodb.collection.collectionscans.totalps,gauge,,scan,second,Total number of times the collection was scanned per second.,0,mongodb,collection scans total per second,,
mongodb.collection.commands.latency,gauge,,microsecond,,Total latency for commands on the collection.,0,mongodb,command latency,,
mongodb.collection.commands.latency.avg,gauge,,microsecond,,Average latency for commands on the collection.,0,mongodb,command latency avg,,
mongodb.collection.commands.opsps,gauge,,operation,second,Number of command operations per second on the collection.,0,mongodb,command operations per second,,
Expand Down
160 changes: 160 additions & 0 deletions mongo/tests/results/metrics-collection-autodiscover.json
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,46 @@
"collection:bar"
]
},
{
"name": "mongodb.collection.collectionscans.nontailableps",
"type": 1,
"value": 0.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test",
"db:test",
"collection:foo"
]
},
{
"name": "mongodb.collection.collectionscans.nontailableps",
"type": 1,
"value": 0.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test",
"db:test",
"collection:bar"
]
},
{
"name": "mongodb.collection.collectionscans.totalps",
"type": 1,
"value": 0.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test",
"db:test",
"collection:foo"
]
},
{
"name": "mongodb.collection.collectionscans.totalps",
"type": 1,
"value": 0.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test",
"db:test",
"collection:bar"
]
},
{
"name": "mongodb.collection.size",
"type": 0,
Expand Down Expand Up @@ -843,6 +883,46 @@
"collection:bar"
]
},
{
"name": "mongodb.collection.collectionscans.nontailableps",
"type": 1,
"value": 0.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test",
"db:admin",
"collection:foo"
]
},
{
"name": "mongodb.collection.collectionscans.nontailableps",
"type": 1,
"value": 0.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test",
"db:admin",
"collection:bar"
]
},
{
"name": "mongodb.collection.collectionscans.totalps",
"type": 1,
"value": 0.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test",
"db:admin",
"collection:foo"
]
},
{
"name": "mongodb.collection.collectionscans.totalps",
"type": 1,
"value": 0.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test",
"db:admin",
"collection:bar"
]
},
{
"name": "mongodb.collection.size",
"type": 0,
Expand Down Expand Up @@ -1245,6 +1325,46 @@
"collection:bar"
]
},
{
"name": "mongodb.collection.collectionscans.nontailableps",
"type": 1,
"value": 0.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test",
"db:local",
"collection:foo"
]
},
{
"name": "mongodb.collection.collectionscans.nontailableps",
"type": 1,
"value": 0.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test",
"db:local",
"collection:bar"
]
},
{
"name": "mongodb.collection.collectionscans.totalps",
"type": 1,
"value": 0.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test",
"db:local",
"collection:foo"
]
},
{
"name": "mongodb.collection.collectionscans.totalps",
"type": 1,
"value": 0.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test",
"db:local",
"collection:bar"
]
},
{
"name": "mongodb.collection.size",
"type": 0,
Expand Down Expand Up @@ -1646,5 +1766,45 @@
"db:integration",
"collection:bar"
]
},
{
"name": "mongodb.collection.collectionscans.nontailableps",
"type": 1,
"value": 0.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test",
"db:integration",
"collection:foo"
]
},
{
"name": "mongodb.collection.collectionscans.nontailableps",
"type": 1,
"value": 0.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test",
"db:integration",
"collection:bar"
]
},
{
"name": "mongodb.collection.collectionscans.totalps",
"type": 1,
"value": 0.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test",
"db:integration",
"collection:foo"
]
},
{
"name": "mongodb.collection.collectionscans.totalps",
"type": 1,
"value": 0.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test",
"db:integration",
"collection:bar"
]
}
]
40 changes: 40 additions & 0 deletions mongo/tests/results/metrics-collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -440,5 +440,45 @@
"db:test",
"collection:bar"
]
},
{
"name": "mongodb.collection.collectionscans.nontailableps",
"type": 1,
"value": 0.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test",
"db:test",
"collection:foo"
]
},
{
"name": "mongodb.collection.collectionscans.nontailableps",
"type": 1,
"value": 0.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test",
"db:test",
"collection:bar"
]
},
{
"name": "mongodb.collection.collectionscans.totalps",
"type": 1,
"value": 0.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test",
"db:test",
"collection:foo"
]
},
{
"name": "mongodb.collection.collectionscans.totalps",
"type": 1,
"value": 0.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test",
"db:test",
"collection:bar"
]
}
]

0 comments on commit b7d4b86

Please sign in to comment.