Repository navigation
[9.3](backport #48638) metricbeat/module/mongodb/collstats: add $collStats aggregation support with fallback - #51469
Merged
Merged
Conversation
Contributor
🤖 GitHub commentsJust comment with:
|
5 of 6 tasks
shmsr
approved these changes
Jun 23, 2026
Contributor
Author
|
Tick the box to add this pull request to the merge queue (same as
|
bmorelli25
approved these changes
Jun 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed commit message
Replaces the deprecated
collstatscommand with the recommendedaggregatepipeline using the$collStatsstage. Thecollstatscommand was deprecated in MongoDB 6.2, and this change ensures compatibility with current and future MongoDB versions while providing enhanced collection statistics. Now it transparently uses either the deprecatedcollStatsdatabase command (legacy) or the$collStatsaggregation stage (MongoDB 6.2+) depending on server version and feature availability to collect collection-level operational and storage statistics from MongoDB.The new approach provides additional metrics that were not available in the old command. A few of them have been enabled, while the rest are currently disabled, pending further development to add them when a need arises.
Implementation wise, these are the following things added:
buildInfocommand$collStatsaggregation with fallback to legacy commandcollStatscommand$collStatspipeline withstorageStatsandcountoptionsstorageStatsto maintain compatibility with existing event mappingReferences
Checklist
CHANGELOG.next.asciidocorCHANGELOG-developer.next.asciidoc.Testing
Comprehensive testing performed across the MongoDB 6.2 deprecation boundary:
✅ MongoDB 5.0 (Pre-deprecation)
✅ MongoDB 7.0 (Post-deprecation)
numOrphanDocscorrectly captured✅ Cross-version Validation
numOrphanDocsonly in 6.0+)Even scripts for future testing added — standalone, replica set and sharded setups. The same standalone setup is being used by the newly written integration tests that has tests against both 5.0 and 7.0.
Related issues
This is an automatic backport of pull request metricbeat/module/mongodb/collstats: add $collStats aggregation support with fallback #48638 done by Mergify.