Skip to content

Document enabling query metrics for self-hosted MongoDB 8.0 - #39441

Merged
drichards-87 merged 2 commits into
masterfrom
zhengda.lu/mongo-querystats-docs
Aug 24, 2026
Merged

Document enabling query metrics for self-hosted MongoDB 8.0#39441
drichards-87 merged 2 commits into
masterfrom
zhengda.lu/mongo-querystats-docs

Conversation

@lu-zhengda

@lu-zhengda lu-zhengda commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

What does this PR do? What is the motivation?

Adds a Query Metrics section to the self-hosted MongoDB DBM setup page explaining that query metrics for self-hosted MongoDB require MongoDB 8.0+ and that query stats collection is disabled by default on the server.

The mongo DBM integration's query metrics feature reads via the $queryStats aggregation pipeline, but the integration cannot enable collection itself — users must set the internalQueryStatsSampleRate server parameter on each mongod/mongos. Without this section, self-hosted MongoDB 8.0 users would not know they need to enable a server parameter to get query metrics.

The section shows the three ways to set the parameter (config file, command line, and runtime setParameter), notes that the runtime form is not persistent, and links to the MongoDB Query Stats server-parameters documentation.

Merge instructions

Merge readiness:

  • Ready for merge

AI assistance

Used Claude Code for research (MongoDB $queryStats server parameter behavior) and initial draft of the doc section; manually reviewed and adjusted.

Additional notes

The internalQueryStatsSampleRate=1.0 value (100% sampling) matches what was validated in the DBM agent integration environment. Users can lower the value to reduce overhead.

@datadog-datadog-prod-us1

This comment has been minimized.

Add a Query Metrics section to the self-hosted MongoDB DBM setup page
explaining that query stats collection is disabled by default and must be
enabled via the internalQueryStatsSampleRate server parameter, with
config file, command line, and runtime setParameter examples.
@lu-zhengda
lu-zhengda force-pushed the zhengda.lu/mongo-querystats-docs branch from 7170c04 to 697ede8 Compare August 24, 2026 21:18
@lu-zhengda
lu-zhengda marked this pull request as ready for review August 24, 2026 21:23
@lu-zhengda
lu-zhengda requested review from a team as code owners August 24, 2026 21:23

@datadog-datadog-prod-us1 datadog-datadog-prod-us1 Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Datadog Autotest: FAIL

The command-line example configures only mongod. A sharded deployment also needs the parameter on each mongos process.

Open Bits AI session

🤖 Datadog Autotest · Commit 697ede8 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

Or pass it on the command line:

{{< code-block lang="shell" >}}
mongod --setParameter internalQueryStatsSampleRate=1.0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Add the mongos command-line form

Users can leave query statistics off on mongos and miss query metrics for router traffic.

Assertion details
  • Input: A user enables query metrics from the command line for a mongos process in a sharded cluster.
  • Expected: The command-line option must show both server types or use a binary placeholder.
  • Actual: The command example starts mongod only. It gives no command for mongos.

Was this helpful? React 👍 or 👎
🤖 Datadog Autotest · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

@drichards-87
drichards-87 merged commit c14fa7a into master Aug 24, 2026
32 of 35 checks passed
@drichards-87
drichards-87 deleted the zhengda.lu/mongo-querystats-docs branch August 24, 2026 22:08
@github-actions

Copy link
Copy Markdown
Contributor

Preview links (active after the build_preview check completes)

Modified Files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants