Mongodb_exporter giving error after successfully connecting and showing down as a service in PMM

Description:

Service is added successfully but getting errors “context deadlne exceeded”

Steps to Reproduce:

Simply add a service using service add command.

pmm-admin add mongodb psmdb_node_1 --replication-set=ReplSet --cluster=us01 --environment=xyz --host= --port=27017 --query-source=“profiler” --username=pmmTest --password=1234567 --server-url=https://admin:xxxxxx@:443 --server-insecure-tls

Version:

ProjectName: pmm-admin

Version: 3.3.1
PMMVersion: 3.3.1

Logs:

time=“2025-08-29T09:43:05.381+00:00” level=error msg=“time=2025-08-29T09:43:05.381Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=1055549c-b537-4947-8bb6-c86f3244cbd1 component=agent-process type=mongodb_exporter

time=“2025-08-29T09:43:07.381+00:00” level=error msg=“time=2025-08-29T09:43:07.381Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=1055549c-b537-4947-8bb6-c86f3244cbd1 component=agent-process type=mongodb_exporter

Expected Result:

I am expecting my service to be shown as UP in pmm-server.

Actual Result:

Additional Information:

[Include any additional information that could be helpful to diagnose the issue, such as browser or device information]

Hi Saurabh,

Hope you are doing good!

I see it was having issues with connecting to the DB. Are you sure that it was connected earlier? Do you have that log?

Can you connect to this DB manually with the details you have given in pmm-admin add command? If so, how many databases/collections do you have? Similar old one - Jira . In that case, can you try add the service with options like “–skip-connection-check --max-collections-limit=10000” for pmm-client to establish a connection and disable collstats, dbstats, topmetrics and indexstats if there are more than 10k collections?

From the screenshot attached, I see mongodb_exporter in Running state. Do you see the service name added in the pmm MongoDB dashboard? We may need the log from pmm-client to look into the issue clearly.

Regards,

Vinodh Guruji

i am running into same/similar issue. i don’t see data in PMM server.

# mongodb exporter logs after pmm-admin add mongodb

docker logs -f -n 10 pmm-client

time=“2026-01-29T22:34:34.576+00:00” level=error msg=“time=2026-01-29T22:34:34.576Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:34:35.576+00:00” level=error msg=“time=2026-01-29T22:34:35.576Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:34:36.577+00:00” level=error msg=“time=2026-01-29T22:34:36.577Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:34:37.576+00:00” level=error msg=“time=2026-01-29T22:34:37.576Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:34:38.576+00:00” level=error msg=“time=2026-01-29T22:34:38.576Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:34:39.576+00:00” level=error msg=“time=2026-01-29T22:34:39.575Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:34:40.575+00:00” level=error msg=“time=2026-01-29T22:34:40.575Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:34:41.575+00:00” level=error msg=“time=2026-01-29T22:34:41.575Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:34:42.576+00:00” level=error msg=“time=2026-01-29T22:34:42.576Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:34:43.576+00:00” level=error msg=“time=2026-01-29T22:34:43.576Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:34:44.576+00:00” level=error msg=“time=2026-01-29T22:34:44.576Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:34:45.575+00:00” level=error msg=“time=2026-01-29T22:34:45.575Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:34:46.576+00:00” level=error msg=“time=2026-01-29T22:34:46.576Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:34:47.576+00:00” level=error msg=“time=2026-01-29T22:34:47.576Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: timed out while checking out a connection from connection pool: context deadline exceeded; total connections: 1, maxPoolSize: 100, idle connections: 0, wait duration: 1.074µs\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:34:48.577+00:00” level=error msg=“time=2026-01-29T22:34:48.576Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: timed out while checking out a connection from connection pool: context deadline exceeded; total connections: 1, maxPoolSize: 100, idle connections: 0, wait duration: 1.1µs\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:34:49.575+00:00” level=error msg=“time=2026-01-29T22:34:49.575Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: timed out while checking out a connection from connection pool: context deadline exceeded; total connections: 1, maxPoolSize: 100, idle connections: 0, wait duration: 1.313µs\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:34:50.576+00:00” level=error msg=“time=2026-01-29T22:34:50.576Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:34:51.576+00:00” level=error msg=“time=2026-01-29T22:34:51.576Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:34:52.576+00:00” level=error msg=“time=2026-01-29T22:34:52.576Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:34:53.576+00:00” level=error msg=“time=2026-01-29T22:34:53.575Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:34:54.576+00:00” level=error msg=“time=2026-01-29T22:34:54.576Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:34:55.575+00:00” level=error msg=“time=2026-01-29T22:34:55.575Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:34:56.576+00:00” level=error msg=“time=2026-01-29T22:34:56.576Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:34:57.576+00:00” level=error msg=“time=2026-01-29T22:34:57.575Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:34:58.575+00:00” level=error msg=“time=2026-01-29T22:34:58.575Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:34:59.575+00:00” level=error msg=“time=2026-01-29T22:34:59.575Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:35:00.577+00:00” level=error msg=“time=2026-01-29T22:35:00.576Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:35:01.576+00:00” level=error msg=“time=2026-01-29T22:35:01.576Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:35:02.576+00:00” level=error msg=“time=2026-01-29T22:35:02.575Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:35:03.576+00:00” level=error msg=“time=2026-01-29T22:35:03.576Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:35:04.576+00:00” level=error msg=“time=2026-01-29T22:35:04.576Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:35:05.576+00:00” level=error msg=“time=2026-01-29T22:35:05.576Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

time=“2026-01-29T22:35:06.576+00:00” level=error msg=“time=2026-01-29T22:35:06.576Z level=ERROR source=exporter.go:328 msg=\“Cannot connect to MongoDB\” error=\“cannot connect to MongoDB: context deadline exceeded\”” agentID=cd78b249-1c6e-4696-bd9f-86aab43ed74d component=agent-process type=mongodb_exporter

#add mongodb to pmm-client.

I experimented with multiple max-query-length , max-collections-limit

docker exec -it pmm-client pmm-admin add mongodb \

–username=root\

–password=‘’\

–host=10.1.0.130\

–port=29019\

–query-source=mongolog\

–enable-all-collectors\

–max-collections-limit=10\

–replication-set=rs0\

–server-insecure-tls\

–max-query-length=50\

–skip-connection-check

MongoDB Service added.

Service ID : 8cd24b13-6c2d-41c7-b076-599cb70d7a80

Service name: ip-10-1-0-130-mongodb

# check mongodb list

docker exec pmm-client pmm-admin list

Service type Service name Address and port Service ID

MongoDB ip-10-1-0-130-mongodb 10.1.0.130:29019 1b663aae-0734-437b-a5f2-cf6a91d2d386

Agent type Status Metrics Mode Agent ID Service ID Port

pmm_agent Connected 8e0d2832-d275-4061-b538-17814bc6b863 0

node_exporter Running push 7ed60f51-0217-4143-825b-cc14cbe328a4 42001

mongodb_exporter Running push 7807e7fd-4be7-4bfb-b130-551ceff6a2a0 1b663aae-0734-437b-a5f2-cf6a91d2d386 42018

mongodb_mongolog_agent Done 3e312fd0-9fef-4a4d-85d8-d3697406066b 1b663aae-0734-437b-a5f2-cf6a91d2d386 0

vmagent Running push 6c267065-4772-457a-ba13-2afdf7343c1a 42000

# check pmm-admin status

docker exec pmm-client pmm-admin status

Agent ID : 8e0d2832-d275-4061-b538-17814bc6b863

Node ID : 4160efa7-5984-472e-8505-a9f984bcea67

Node name: ip-10-1-0-130

PMM Server:

    URL    : https://10.1.0.131:443/

    Version: 3.5.0

PMM Client:

    Connected        : true

    Time drift       : 38.801µs

    Latency          : 889.198µs

    Connection uptime: 100

    pmm-admin version: 3.5.0

    pmm-agent version: 3.5.0

Agents:

    6c267065-4772-457a-ba13-2afdf7343c1a vmagent                        Running        42000

    7ed60f51-0217-4143-825b-cc14cbe328a4 node_exporter                  Running        42001

    b7416587-14e4-41e7-a089-92ec6c0fb3e3 mongodb_mongolog_agent         Unspecified    0

    cd78b249-1c6e-4696-bd9f-86aab43ed74d mongodb_exporter               Running        42024

# check if mongodb port is reachable

docker exec pmm-client timeout 5 bash -c ‘echo > /dev/tcp/10.1.0.130/29019’ && echo “Port reachable” || echo “Port NOT reachable”

Port reachable

# check mongodb status

docker exec zdMongoDb mongosh --eval “rs.status().members.map(m => ({name: m.name, state: m.stateStr}))” -u root -p ‘’ --authenticationDatabase admin

[ { name: ‘10.1.0.130:29019’, state: ‘PRIMARY’ } ]

# check pmm-admin version

docker exec -it pmm-client pmm-admin add mongodb --version

ProjectName: pmm-admin

Version: 3.5.0

PMMVersion: 3.5.0

Timestamp: 2025-11-14 23:23:32 (UTC)

FullCommit: 586a9227547b4991e5ee3edf793dcd22b6c08117

nodes :

Status Node Name Node Type Monitoring Address Services Options
Up ip-10-1-0-130 generic OK 10.1.0.130 ip-10-1-0-130-mongodb

Service :