Skip to content

Commit

Permalink
[mongo] new query plancache and sort stage metrics (#18513)
Browse files Browse the repository at this point in the history
* new query plancache and sort stage metrics

* add changelog

* update metadata
  • Loading branch information
lu-zhengda authored Sep 5, 2024
1 parent 75adce4 commit 32687a4
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mongo/changelog.d/18513.added
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Add new metrics for MongoDB query plan cache (requires MongoDB 7.0+) and sort stages (requires MongoDB 6.2+):
- mongodb.metrics.query.plancache.classic.hitsps
- mongodb.metrics.query.plancache.classic.missesps
- mongodb.metrics.query.plancache.sbe.hitsps
- mongodb.metrics.query.plancache.sbe.missesps
- mongodb.metrics.query.sort.spilltodiskps
- mongodb.metrics.query.sort.totalbytessortedps
- mongodb.metrics.query.sort.totalkeyssortedps
7 changes: 7 additions & 0 deletions mongo/datadog_checks/mongo/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@
"metrics.operation.idhack": RATE,
"metrics.operation.scanAndOrder": RATE,
"metrics.operation.writeConflicts": RATE,
"metrics.query.sort.spillToDisk": RATE,
"metrics.query.sort.totalBytesSorted": RATE,
"metrics.query.sort.totalKeysSorted": RATE,
"metrics.query.planCache.classic.hits": RATE,
"metrics.query.planCache.classic.misses": RATE,
"metrics.query.planCache.sbe.hits": RATE,
"metrics.query.planCache.sbe.misses": RATE,
"metrics.queryExecutor.scanned": RATE,
"metrics.queryExecutor.scannedObjects": RATE,
"metrics.record.moves": RATE,
Expand Down
7 changes: 7 additions & 0 deletions mongo/metadata.csv
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ mongodb.metrics.operation.fastmodps,gauge,,operation,second,Number of update ope
mongodb.metrics.operation.idhackps,gauge,,query,second,Number of queries per second that contain the _id field.,0,mongodb,operation idhack ps,,
mongodb.metrics.operation.scanandorderps,gauge,,query,second,Number of queries per second that return sorted numbers that cannot perform the sort operation using an index.,0,mongodb,operation scanandorder ps,,
mongodb.metrics.operation.writeconflictsps,gauge,,event,second,Number of times per second that write concern operations has encounter a conflict.,0,mongodb,write conflict,,
mongodb.metrics.query.plancache.classic.hitsps,gauge,,operation,second,Number of times per second the query planner accesses the classic plan cache and finds a cached plan (requires MongoDB 7.0 and above).,0,mongodb,query plancache classic hits ps,,
mongodb.metrics.query.plancache.classic.missesps,gauge,,operation,second,Number of times per second the query planner accesses the classic plan cache and does not find a cached plan (requires MongoDB 7.0 and above).,0,mongodb,query plancache classic misses ps,,
mongodb.metrics.query.plancache.sbe.hitsps,gauge,,operation,second,Number of times per second the query planner accesses the slot-based execution engine plan cache and finds a cached plan (requires MongoDB 7.0 and above).,0,mongodb,query plancache sbe hits ps,,
mongodb.metrics.query.plancache.sbe.missesps,gauge,,operation,second,Number of times per second the query planner accesses the slot-based execution engine plan cache and does not find a cached plan (requires MongoDB 7.0 and above).,0,mongodb,query plancache sbe misses ps,,
mongodb.metrics.query.sort.spilltodiskps,gauge,,operation,second,The total number of writes per second to disk caused by sort stages (requires MongoDB 6.2 and above).,0,mongodb,sort spill to disk ps,,
mongodb.metrics.query.sort.totalbytessortedps,gauge,,byte,second,The total amount of sorted data in bytes per second (requires MongoDB 6.2 and above).,0,mongodb,sort total bytes sorted ps,,
mongodb.metrics.query.sort.totalkeyssortedps,gauge,,key,second,The total number of keys used in sorts per second (requires MongoDB 6.2 and above).,0,mongodb,sort total keys sorted ps,,
mongodb.metrics.queryexecutor.scannedobjectsps,gauge,,operation,second,Number of documents scanned per second during queries and query-plan evaluation.,0,mongodb,queryexecutor scanned object ps,,
mongodb.metrics.queryexecutor.scannedps,gauge,,operation,second,Number of index items scanned per second during queries and query-plan evaluation.,0,mongodb,queryexecutor scanned ps,,
mongodb.metrics.record.movesps,gauge,,operation,second,Number of times per second documents move within the on-disk representation of the MongoDB data set.,0,mongodb,record moves ps,,
Expand Down
11 changes: 11 additions & 0 deletions mongo/tests/fixtures/serverStatus
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,17 @@
"fastmod": 12,
"idhack": 13
},
"query": {
"planCache": {
"classic": { "hits": 13041302, "misses": 1023350 },
"sbe": { "hits": 444, "misses": 878 }
},
"sort": {
"spillToDisk": 18,
"totalBytesSorted": 4808797953,
"totalKeysSorted": 14394599
}
},
"queryExecutor": {
"scanned": 46,
"scannedObjects": 97
Expand Down
56 changes: 56 additions & 0 deletions mongo/tests/results/metrics-serverStatus.json
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,62 @@
"server:mongodb://testUser2:*****@localhost:27017/test"
]
},
{
"name": "mongodb.metrics.query.plancache.classic.hitsps",
"type": 1,
"value": 13041302.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test"
]
},
{
"name": "mongodb.metrics.query.plancache.classic.missesps",
"type": 1,
"value": 1023350.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test"
]
},
{
"name": "mongodb.metrics.query.plancache.sbe.hitsps",
"type": 1,
"value": 444.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test"
]
},
{
"name": "mongodb.metrics.query.plancache.sbe.missesps",
"type": 1,
"value": 878.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test"
]
},
{
"name": "mongodb.metrics.query.sort.spilltodiskps",
"type": 1,
"value": 18.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test"
]
},
{
"name": "mongodb.metrics.query.sort.totalbytessortedps",
"type": 1,
"value": 4808797953.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test"
]
},
{
"name": "mongodb.metrics.query.sort.totalkeyssortedps",
"type": 1,
"value": 14394599.0,
"tags": [
"server:mongodb://testUser2:*****@localhost:27017/test"
]
},
{
"name": "mongodb.metrics.queryexecutor.scannedps",
"type": 1,
Expand Down

0 comments on commit 32687a4

Please sign in to comment.