[system] Add MongoDB Grafana dashboards#2158
Conversation
Summary of ChangesHello, 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 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
Activity
Using Gemini Code AssistThe 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
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 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
|
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughTwo 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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. Comment |
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]>
ebb19d9 to
c838358
Compare
There was a problem hiding this comment.
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.
| { | ||
| "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" | ||
| } |
There was a problem hiding this comment.
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"
}| { | ||
| "datasource": { | ||
| "type": "prometheus", | ||
| "uid": "${ds_prometheus}" | ||
| }, | ||
| "editorMode": "code", | ||
| "expr": "avg(mongodb_mongod_wiredtiger_cache_max_bytes{job=\"$job\"})", | ||
| "interval": "5m", | ||
| "range": true, | ||
| "refId": "A" | ||
| } |
There was a problem hiding this comment.
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", |
| "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", |
| "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]))", |
There was a problem hiding this comment.
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.
| "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]))", |
There was a problem hiding this comment.
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.
| "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]))", |
What this PR does
Adds two Grafana dashboards for MongoDB monitoring, adapted to cozystack conventions:
Key adaptations from the original PMM dashboards:
${ds_prometheus}variablejob-based service filteringdashboards.listfor automatic GrafanaDashboard CRD generationRelease note
Summary by CodeRabbit