andrii29 / mongodb-profiler-exporter

A Prometheus exporter for MongoDB Profiler
MIT License
9 stars 0 forks source link

Problem on Prometheus Dashboard #10

Closed zaffaridam closed 3 weeks ago

zaffaridam commented 1 month ago

As can be seen in the image, the panel where slow queries should be displayed is not showing the data.

image

Upon checking the panel configuration, there is an error that I couldn't fix.

Query: sum(rate(slow_queries_count_total{job=~"$job", ns=~"$ns", query_hash=~"$query_hash" }[$__range])) by (query_hash, ns) * on (query_hash, ns) group_left(op, plan_summary, query_framework, query_shape) slow_queries_info

image

execution: found duplicate series for the match group {ns="maischat_db.contacts", query_hash="FB0D13D4"} on the right hand-side of the operation: [{__name__="slow_queries_info", db="maischat_db", instance="monitor-eveo.maischat.io:80", job="mongodb-exporter-maischat-new-0", ns="maischat_db.contacts", op="query", plan_summary="IXSCAN { tenant: 1 }", query_hash="FB0D13D4", query_shape="{'find': '?', 'filter': {'tenant': '?', '$or': [{'whatsappId': {'$exists': '?'}}, {'messengerId': {'$exists': '?'}}, {'instagramId': {'$exists': '?'}}]}, 'sort': {'name': '?'}, 'returnKey': '?', 'showRecordId': '?'}"}, {__name__="slow_queries_info", db="maischat_db", instance="monitor-eveo.maischat.io:80", job="mongodb-exporter-maischat-new-0", ns="maischat_db.contacts", op="query", plan_summary="IXSCAN { name: 1 }", query_hash="FB0D13D4", query_shape="{'find': '?', 'filter': {'tenant': '?', '$or': [{'whatsappId': {'$exists': '?'}}, {'messengerId': {'$exists': '?'}}, {'instagramId': {'$exists': '?'}}]}, 'sort': {'name': '?'}, 'returnKey': '?', 'showRecordId': '?'}"}];many-to-many matching not allowed: matching labels must be unique on one side

andrii29 commented 1 month ago

Try to install the latest version of the 20383 dashboard

Explanation: In your case, the queryHash "FB0D13D4" had multiple plans, such as plan_summary="IXSCAN { name: 1 }" and plan_summary="IXSCAN { tenant: 1 }", which caused an error in the Grafana panel. I updated the dashboard query to pick only one label value per queryHash (randomly). This will allow the display queries with multiple label values for single queryHash.