Skip to content

[system] Add MongoDB Grafana dashboards#2158

Merged
IvanHunters merged 2 commits intomainfrom
feat/mongodb-grafana-dashboards
Mar 6, 2026
Merged

[system] Add MongoDB Grafana dashboards#2158
IvanHunters merged 2 commits intomainfrom
feat/mongodb-grafana-dashboards

Conversation

@IvanHunters
Copy link
Collaborator

@IvanHunters IvanHunters commented Mar 5, 2026

What this PR does

Adds two Grafana dashboards for MongoDB monitoring, adapted to cozystack conventions:

  • MongoDB Overview — command operations, connections, cursors, document operations, queued operations, query efficiency, scanned objects, write time/operations, asserts, page faults
  • MongoDB InMemory Details — WiredTiger cache size/capacity, dirty pages, transactions, sessions, pages, concurrency tickets, cache eviction, document changes, scanned objects, page faults

Key adaptations from the original PMM dashboards:

  • Replaced hardcoded datasource UIDs with ${ds_prometheus} variable
  • Replaced PMM-specific variables with standard job-based service filtering
  • Removed Node Summary section (covered by existing node dashboards)
  • Registered both dashboards in dashboards.list for automatic GrafanaDashboard CRD generation

Release note

[system] Add MongoDB Overview and MongoDB InMemory Details Grafana dashboards to the monitoring stack

Summary by CodeRabbit

  • New Features
    • Added MongoDB InMemory dashboard providing detailed visibility into in-memory metrics, cache performance, and data management.
    • Added MongoDB Overview dashboard for monitoring operations, connections, cursors, document activity, and query efficiency.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances MongoDB monitoring capabilities by introducing two new Grafana dashboards. These dashboards provide detailed insights into MongoDB's operational metrics and WiredTiger in-memory performance, ensuring better visibility and easier troubleshooting for MongoDB instances within the system. The integration follows established conventions for datasource and service filtering, streamlining the monitoring setup.

Highlights

  • New MongoDB Grafana Dashboards: Two new Grafana dashboards, 'MongoDB Overview' and 'MongoDB InMemory Details', have been added for comprehensive MongoDB monitoring.
  • CozyStack Convention Adaptation: The dashboards were adapted to cozystack conventions by replacing hardcoded datasource UIDs with a ${ds_prometheus} variable and using standard job-based service filtering.
  • Node Summary Removal: The Node Summary section was removed from the dashboards as this information is already covered by existing node dashboards.
  • Automatic Dashboard Generation: Both new dashboards are registered in dashboards.list to enable automatic GrafanaDashboard CRD generation.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • dashboards/mongodb/mongodb-inmemory.json
    • Added a new Grafana dashboard for MongoDB WiredTiger InMemory Details.
  • dashboards/mongodb/mongodb-overview.json
    • Added a new Grafana dashboard for MongoDB Overview.
  • packages/system/monitoring/dashboards.list
    • Added entries for the new 'mongodb-overview' and 'mongodb-inmemory' dashboards to the list of available dashboards.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 5, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Two new MongoDB Grafana dashboards are added: mongodb-overview with 13 panels covering operational metrics, and mongodb-inmemory with 9 panels focusing on in-memory storage details. Both dashboards are registered in the dashboard manifest and configured to use Prometheus as the data source.

Changes

Cohort / File(s) Summary
MongoDB Dashboards
dashboards/mongodb/mongodb-overview.json, dashboards/mongodb/mongodb-inmemory.json
New Grafana dashboard configurations for MongoDB monitoring. Overview dashboard tracks operations, connections, cursors, document metrics, and query efficiency across 13 panels. In-memory dashboard monitors cache, transactions, evictions, and page faults across 9 panels. Both use Prometheus metrics and include templated variables for datasource and job selection.
Dashboard Registry
packages/system/monitoring/dashboards.list
Manifest file updated to register the two new MongoDB dashboards (mongodb-overview and mongodb-inmemory) for inclusion in the monitoring system.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 New dashboards hop into view,
MongoDB metrics shining through,
In-memory pages, overview wise,
Prometheus data before our eyes! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title '[system] Add MongoDB Grafana dashboards' accurately summarizes the main change: adding two new Grafana dashboard configuration files for MongoDB monitoring to the system.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/mongodb-grafana-dashboards

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Add two MongoDB dashboards adapted for cozystack monitoring:
- mongodb-overview: command operations, connections, cursors,
  document operations, queued operations, query efficiency,
  scanned objects, write time, asserts, page faults
- mongodb-inmemory: WiredTiger InMemory cache details including
  data size, capacity, transactions, sessions, pages, concurrency
  tickets, cache eviction, document changes

Dashboards use ds_prometheus variable for datasource selection and
job-based service filtering compatible with Percona MongoDB exporter
metrics.

Signed-off-by: IvanHunters <[email protected]>
Add mongodb/mongodb-overview and mongodb/mongodb-inmemory entries
to the monitoring dashboards list so GrafanaDashboard CRDs are
generated and dashboards are served by the grafana-dashboards
HTTP service.

Signed-off-by: IvanHunters <[email protected]>
@IvanHunters IvanHunters force-pushed the feat/mongodb-grafana-dashboards branch from ebb19d9 to c838358 Compare March 5, 2026 19:48
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces two new Grafana dashboards for MongoDB monitoring: 'MongoDB Overview' and 'MongoDB InMemory Details'. The dashboards are well-structured and provide valuable insights into MongoDB performance. My review focuses on improving the consistency and efficiency of the PromQL queries within the dashboard definitions. I've suggested using instant queries for stat panels where appropriate and replacing hardcoded time intervals with the dashboard's $interval variable for better dynamic control and maintainability. These changes will make the dashboards cleaner and more consistent.

Comment on lines +113 to +123
{
"datasource": {
"type": "prometheus",
"uid": "${ds_prometheus}"
},
"editorMode": "code",
"expr": "avg(mongodb_mongod_wiredtiger_cache_bytes{job=\"$job\", type=\"total\"})",
"interval": "5m",
"range": true,
"refId": "A"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For stat panels that should display the most recent value, it's more efficient and clearer to use an instant query. The current configuration uses a range query which is unnecessarily complex. Please use an instant query instead by applying the suggestion. Also, you should remove "timeFrom": "1m" on line 125 as it's related to the range query configuration.

          {
            "datasource": {
              "type": "prometheus",
              "uid": "${ds_prometheus}"
            },
            "editorMode": "code",
            "expr": "avg(mongodb_mongod_wiredtiger_cache_bytes{job=\"$job\", type=\"total\"})",
            "refId": "A"
          }

Comment on lines +199 to +209
{
"datasource": {
"type": "prometheus",
"uid": "${ds_prometheus}"
},
"editorMode": "code",
"expr": "avg(mongodb_mongod_wiredtiger_cache_max_bytes{job=\"$job\"})",
"interval": "5m",
"range": true,
"refId": "A"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For stat panels that should display the most recent value, it's more efficient and clearer to use an instant query. The current configuration uses a range query which is unnecessarily complex. Please use an instant query instead by applying the suggestion. Also, you should remove "timeFrom": "1m" on line 211 as it's related to the range query configuration.

          {
            "datasource": {
              "type": "prometheus",
              "uid": "${ds_prometheus}"
            },
            "editorMode": "code",
            "expr": "avg(mongodb_mongod_wiredtiger_cache_max_bytes{job=\"$job\"})",
            "refId": "A"
          }

"uid": "${ds_prometheus}"
},
"expr": "1-(avg(mongodb_mongod_wiredtiger_cache_bytes{job=\"$job\", type=\"total\"})/avg(mongodb_mongod_wiredtiger_cache_max_bytes{job=\"$job\"}))",
"interval": "5m",
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The interval property is not used for instant queries and can be removed for clarity.

"uid": "${ds_prometheus}"
},
"expr": "avg(mongodb_mongod_wiredtiger_cache_pages{job=\"$job\",type=\"dirty\"})/avg(mongodb_mongod_wiredtiger_cache_pages{job=\"$job\",type=\"total\"})",
"interval": "5m",
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The interval property is not used for instant queries and can be removed for clarity.

"type": "prometheus",
"uid": "${ds_prometheus}"
},
"expr": "sum(increase(mongodb_mongod_metrics_query_executor_total{job=~\"$job\", state=\"scanned_objects\"}[5m]))/sum(increase(mongodb_mongod_metrics_document_total{job=~\"$job\", state=\"returned\"}[5m]))",
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This query uses a hardcoded 5m time range. For consistency with other panels in this dashboard that use the $interval variable, please use $interval here as well. This allows the time range to be controlled dynamically.

Suggested change
"expr": "sum(increase(mongodb_mongod_metrics_query_executor_total{job=~\"$job\", state=\"scanned_objects\"}[5m]))/sum(increase(mongodb_mongod_metrics_document_total{job=~\"$job\", state=\"returned\"}[5m]))",
"expr": "sum(increase(mongodb_mongod_metrics_query_executor_total{job=~\"$job\", state=\"scanned_objects\"}[$interval]))/sum(increase(mongodb_mongod_metrics_document_total{job=~\"$job\", state=\"returned\"}[$interval]))",

"type": "prometheus",
"uid": "${ds_prometheus}"
},
"expr": "sum(increase(mongodb_mongod_metrics_query_executor_total{job=~\"$job\", state=\"scanned\"}[5m]))/sum(increase(mongodb_mongod_metrics_document_total{job=~\"$job\", state=\"returned\"}[5m]))",
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This query uses a hardcoded 5m time range. For consistency with other panels in this dashboard that use the $interval variable, please use $interval here as well. This allows the time range to be controlled dynamically.

Suggested change
"expr": "sum(increase(mongodb_mongod_metrics_query_executor_total{job=~\"$job\", state=\"scanned\"}[5m]))/sum(increase(mongodb_mongod_metrics_document_total{job=~\"$job\", state=\"returned\"}[5m]))",
"expr": "sum(increase(mongodb_mongod_metrics_query_executor_total{job=~\"$job\", state=\"scanned\"}[$interval]))/sum(increase(mongodb_mongod_metrics_document_total{job=~\"$job\", state=\"returned\"}[$interval]))",

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 6, 2026
@IvanHunters IvanHunters marked this pull request as ready for review March 6, 2026 11:46
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. enhancement New feature or request labels Mar 6, 2026
@IvanHunters IvanHunters merged commit 8166df2 into main Mar 6, 2026
11 of 12 checks passed
@IvanHunters IvanHunters deleted the feat/mongodb-grafana-dashboards branch March 6, 2026 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants