How to use MongoDB exporter metrics in Grafana?

Good afternoon, I’m having some problems connecting Mongodb exporter metrics to Grafana. Metrics are being successfully extracted for Prometheus and now I would like to use Grafana to have a more interactive view of the data. The dashboards I used are from this link [GitHub - percona/grafana-dashboards: PMM dashboards for database monitoring] and the exporter version is the latest, 0.20.4. I wonder if anyone could assist me in this matter ?
Cheers

Hi Joao,

Could you try a dashboard that were prepared for PMM1? Dashboards for PMM2 are using a specific parameters in formulas.
e.g.

1 Like

I tried to access the dashboard that indicated me and I had to change the name of the datasource that is fixed as “Prometheus” to the name of my Prometheus. However, the errors that appeared in the other dashboards did not appear to me, but data are not shown.

1 Like

In the image below, you can see a case of a list of metrics from the MongoDB Exporter, so I assume that it is not a problem for either the exporter or Prometheus configuration.

1 Like

Could you share parameters that are provided by Prometheus for a metric?
e.g.
mongodb_mongod_op_counters_total

This metric is used in the first element of the dashboard.
rate(mongodb_mongod_op_counters_total{instance=~“$host”, type!=“command”}[$interval])

1 Like

Good morning, I researched the metrics that were indicated and just found this metric from op_counters but they have different names as you can see in the image below.

It represents an extraction of the exporter’s metrics to a txt file. I remember that I am using the latest version of Mongodb exporter.

1 Like

I looked at the dashboard json and the metrics he is waiting for have different names than those the exporter is drawing on. That is, do I have to change the name of the metrics in json manually?
If that is the case it is worth trying, however I thought that the metrics name would not be changed in this way.

Ok. I have missed the fact that you are using the latest version of exporter. :confused: So metrics name were changed there.

You should take a dashboard for PMM2 and modify variable names.
IMHO the easiest way is to modify formula for service_name variable.
Please replace “service_name” word by “instance”
label_values(mongodb_up{cluster=~“$cluster”}, service_name) → label_values(mongodb_up{cluster=~“$cluster”}, instance)

I followed these steps and already recognized my instance as you can see.

I still have to add this plugin to see if the mongodb_up metrics are really working.
But what about the rest of the metrics do I change manually? In this edit of connections you are going to get the name of old metrics.

Or is it better to wait for the updated dashboards to come out with the new metrics?

1 Like

Dashboards in PMM-2.0 brunch has already working new metrics names.
It’s a pretty strange that you don’t have metric mongodb_connections.
Could you check it on Prometheus UI?

1 Like

It’s working, I just needed to add the name of the metrics that appears in my exporter regarding the connections.

What it seems to me is that I have to do this process for all metrics. :confused:

1 Like

As far as connections are concerned, these are the names of the metrics that the exporter is drawing.

1 Like

I now also changed the cursors and did the same process, that is, the name of the metrics that the Mongodb exporter is drawing are different from those presented by the dashboard.

1 Like

Also you may use flag --compatible-mode for exporter in order to get both variants of metrics.

1 Like

Yes, I think that was the problem, when I implemented MongoDB exporter through CHEF, I did not set this flag to true, I have already seen the metrics and they are there with the correct name.

Having said that, I will configure the Grafana with these metrics and at the outset I should have no problems, thank you very much for your help and attention. :slightly_smiling_face:

1 Like

Did anyone face problem while importing MongoDB ReplSet Summary json file? i am not able to import any file of mongodb to grafana dashboard.I am using latest mongodb exporter and grafana version.
please help me out.

I am using this dashboard - GitHub - percona/grafana-dashboards: PMM dashboards for database monitoring

1 Like

Could you provide a screenshot with errors?

1 Like

Metrics are not showing on grafana dashboard. I have used below version of mongo exporter and dashboard version.

Mongodb_exporterv0.20.7
Grafana Dashboard versionv2.22.0
Grafana Version → Grafana v8.1.0
Screenshot Attached of error

Observation: The query which starts with mongodb_mongod doesn’t work on the Prometheus query.

1 Like

The dashboard is using PMM datasource for variables.
Please use next script for converting dashboards.

1 Like