After I set up prometheus with mongodb_exporter I didn’t get any data in grafana ,
and the localhost:9216/metrics doesn’t show any mongodb metrics except "mongodb_up"
but for me i need all mongodb metrics in order to do the monitoring .
.
.
this my metrics
# HELP mongodb_up Whether MongoDB is up.
# TYPE mongodb_up gauge
mongodb_up 1
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 0.11
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 1.048576e+06
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 16
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 1.6887808e+07
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1.65307162516e+09
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 7.34683136e+08
# HELP process_virtual_memory_max_bytes Maximum amount of virtual memory available in bytes.
# TYPE process_virtual_memory_max_bytes gauge
process_virtual_memory_max_bytes 1.8446744073709552e+19
This my docker-compose.yml
services:
mongo :
image: "mongo:latest"
ports:
- 2000:27017
mongodb-exporter:
image: "percona/mongodb_exporter:0.32.0"
ports:
- 9216:9216
command:
- "--mongodb.uri=mongodb://mongo:27017"
- "--mongodb.collstats-colls=Test.Listings"
- "--discovering-mode"
- "--mongodb.direct-connect"
prometheus:
image: prom/prometheus:latest
volumes:
- ./prometheus/:/etc/prometheus/
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
ports:
- 9090:9090
grafana:
image: grafana/grafana:latest
ports:
- 3000:3000
2
Answers
For bitnami/mongodb-exporter:0.32.0-debian-10-r3 passing "–collect-all" as additional parameter in command worked for me to get the metrics. So the modification would look as follows:
However, the available dashboards make use of older metric names so my dashboards that I picked from under percona’s repository even after modifying the datasources did not get populated.
One suggestion regarding when I was searching online was that is adding "–compatible-mode" as well but that has been reported to be not working with mongo:5 and up. I have yet to confirm with previous releases such as mongo:4.2
I am currently trying to convert the queries of the dashboards accordingly with the new metric names though it ain’t pretty.
Adding –collect-all and –compatible-mode worked for me with the following configuration :