Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MongoDB exporter gets some metrics but Grafana dashboard does not display them #1020

Open
Kenya-West opened this issue Feb 1, 2025 · 4 comments

Comments

@Kenya-West
Copy link

Kenya-West commented Feb 1, 2025

Describe the bug
Noobie here.
I successfully setup multi-target MongoDB exporter and got metrics by target URL in Prometheus but there is no data in Grafana dashboards. Used this and this one.

To Reproduce
Steps to reproduce the behavior:

  1. Setup docker-compose.yml:
---
services:
  mongodb_exporter:
    image: percona/mongodb_exporter:0.43.1
    container_name: mongodb_exporter
    cpus: 0.5
    mem_limit: 200m
    env_file:
      - .env
    networks:
      - caddy

networks:
  caddy:
    external: true
  1. In .env, set hosts to collect data from as following:
MONGODB_URI=mongodb+srv://user:password@cluster6.9texege.mongodb.net/admin
  1. Add Prometheus config record:
  - job_name: MongoDB
    file_sd_configs:
    - files:
      - /etc/file_sd/mongodb_targets_custom.yml
      refresh_interval: 30s
  1. Setup mongodb_targets_custom.yml:
- targets:
  - mongodb_exporter:9216
  labels:
    __metrics_path__: /scrape
    __param_target: cluster6.9texege.mongodb.net
  1. See green 🟩 UP status in Prometheus and check metrics manually by HTTP:
/ # wget -O- http://mongodb_exporter:9216/scrape?target=cluster6.9texege.mongodb.net | tail -n 12
Connecting to mongodb_exporter:9216 (172.18.0.13:9216)
writing to stdout
-                    100% |**************************************************|  8471  0:00:00 ETA
written to stdout
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 2.8643328e+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.73835338716e+09
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 1.279807488e+09
# 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
  1. Add this or this one of dashboards in Grafana

Expected behavior
I should see some bars, charts and data regardless of selected filters.

Actual behavior
All data is void.

Environment

  • MongoDB exporter 0.43.1
  • Ubuntu 24.04
  • Docker the latest
  • MongoDB version 8.0.4
@BupycHuk
Copy link
Member

BupycHuk commented Feb 5, 2025

Hello, have you enabled any collector on mongodb_exporter side? Have you converted PMM dashboards using this script? https://github.com/percona/grafana-dashboards/?tab=readme-ov-file#reusing-dashboards-outside-of-pmm

@jflebeau
Copy link

jflebeau commented Feb 5, 2025

Juste updated to latest (0.43.1) with mongob 7.x and prometheus is not getting anything anymore 🤔

@Kenya-West
Copy link
Author

Hello @BupycHuk!

Let's oversee, it was a little complicated to me:

  • I successfully converted dashboards from PMM format to Grafana one, using Python 2.7 (Using of Python 3 did not work), they display no metrics except one block with count(mongodb_up{instance=~"mongodb_exporter:9216"}) query - it displays value 1:

Image

  • Apparently, I did not enable any collectors. I added them:
    command: [
        "--mongodb.direct-connect=false",
        "--discovering-mode",
        "--collector.replicasetstatus=true",
        "--collector.indexstats=true",
        "--collector.collstats=true",
        "--log.level=info",
    ]

And despite some collectors were enabled, dashboards (which are MongoDB Instance Summary, MongoDB Instances Overview, MongoDB Collections Overview) display nothing.

I am not an expert in PromQL so running this expression mongodb_up get's straight line so seems like mongodb_exporter connects to database successfully.

And it does not matter if I connect admin database or a database with actual data, it still displays nothing.

Screenshot as an example

Image

In logs, it constantly spawn warning level message:

mongodb_exporter  | time="2025-02-07T19:35:09Z" level=warning msg="cannot load topology labels: error getting cluster ID: (AtlasError) (Unauthorized) not authorized on admin to execute command { replSetGetConfig: 1, lsid: { id: {4 [ some digits ]} }, $clusterTime: { clusterTime: {1738956909 30}, signature: { hash: {0 [some digits]}, keyId: 743947347633453444230.000000 } }, $db: \"admin\" }: cannot get topology labels"

@BupycHuk
Copy link
Member

Can you also enable --compatible-mode? And please provide required priveleges

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants