# Pmm-agent throwing errors

**URL:** <https://forums.percona.com/t/pmm-agent-throwing-errors/9078>\
**Category:** PMM 2.x\
**Created:** [February 3, 2021, 3:30pm UTC](https://forums.percona.com/t/pmm-agent-throwing-errors/9078 "2021-02-03T15:30:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cukal](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/cukal/32/1277_2.png) [@cukal](https://forums.percona.com/u/cukal)\
**Post date:** [February 3, 2021, 3:30pm UTC](https://forums.percona.com/t/pmm-agent-throwing-errors/9078/1 "2021-02-03T15:30:24Z")

</div>

I’ve installed the 2.14 appliance and added 2 mongodb nodes (primary / secondary) using pmm2-client.  
These nodes were previously monitored with pmm 1.17.4.

When starting the pmm-agent these errors start showing up after a few minutes of uptime.  
Dashboards / QAN etc all continue to work.

```
Feb 03 16:14:30 vlst-mongodb-replica01 pmm-agent[30149]: INFO[2021-02-03T16:14:30.011+01:00]logrus/entry.go:359 logrus.(*Entry).Logln time="2021-02-03T16:14:30+01:00" level=error msg="error while checking mongodb connection: connection(127.0.0.1:27017[-5]) failed to write: context canceled. mongo_up is set to 0" agentID=/agent_id/7ced8a41-fd19-4ef1-b7a5-73acc0c13a10 component=agent-process type=mongodb_exporter

Feb 03 16:14:30 vlst-mongodb-replica01 pmm-agent[30149]: INFO[2021-02-03T16:14:30.073+01:00]logrus/entry.go:359 logrus.(*Entry).Logln time="2021-02-03T16:14:30+01:00" level=error msg="Cannot get node type to check if this is a mongos: connection(127.0.0.1:27017[-6]) failed to write: context canceled" agentID=/agent_id/7ced8a41-fd19-4ef1-b7a5-73acc0c13a10 component=agent-process type=mongodb_exporter

Feb 03 16:14:30 vlst-mongodb-replica01 pmm-agent[30149]: INFO[2021-02-03T16:14:30.074+01:00]logrus/entry.go:359 logrus.(*Entry).Logln time="2021-02-03T16:14:30+01:00" level=error msg="cannot get replSetGetStatus: connection(127.0.0.1:27017[-6]) failed to write: context canceled" agentID=/agent_id/7ced8a41-fd19-4ef1-b7a5-73acc0c13a10 component=agent-process type=mongodb_exporter

Feb 03 16:14:30 vlst-mongodb-replica01 pmm-agent[30149]: INFO[2021-02-03T16:14:30.077+01:00]logrus/entry.go:359 logrus.(*Entry).Logln time="2021-02-03T16:14:30+01:00" level=error msg="error while checking mongodb connection: connection(127.0.0.1:27017[-6]) failed to write: context canceled. mongo_up is set to 0" agentID=/agent_id/7ced8a41-fd19-4ef1-b7a5-73acc0c13a10 component=agent-process type=mongodb_exporter

Feb 03 16:14:30 vlst-mongodb-replica01 pmm-agent[30149]: INFO[2021-02-03T16:14:30.077+01:00]logrus/entry.go:359 logrus.(*Entry).Logln time="2021-02-03T16:14:30+01:00" level=error msg="cannot run getDiagnosticData: connection(127.0.0.1:27017[-6]) failed to write: context canceled" agentID=/agent_id/7ced8a41-fd19-4ef1-b7a5-73acc0c13a10 component=agent-process type=mongodb_exporter

```

Whenever that happens I need to restart pmm-agent several times and eventually it will no longer throw those errors.

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [February 3, 2021, 4:29pm UTC](https://forums.percona.com/t/pmm-agent-throwing-errors/9078/2 "2021-02-03T16:29:21Z")

</div>

It’s obvious from the logs that the agent is trying to establish a connection at 127.0.0.1:27017 but it is timing out. Perhaps you need to specify the correct IP:PORT when configuring the agent?

---

<div class="post-metadata">

**Author:** ![cukal](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/cukal/32/1277_2.png) [@cukal](https://forums.percona.com/u/cukal)\
**Post date:** [February 3, 2021, 4:37pm UTC](https://forums.percona.com/t/pmm-agent-throwing-errors/9078/3 "2021-02-03T16:37:32Z")

</div>

I was under the impression running

> pmm-admin add mongodb --uri mongodb://user:pass@127.0.0.1:27017

was sufficient to configure it?

I can’t understand how all the mongodb metrics / QAN stats etc are all available in the dashboard when the agent seemingly can’t connect.

---

<div class="post-metadata">

**Author:** ![Peter](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/peter/32/2_2.png) [@Peter](https://forums.percona.com/u/Peter)\
**Post date:** [February 3, 2021, 5:58pm UTC](https://forums.percona.com/t/pmm-agent-throwing-errors/9078/4 "2021-02-03T17:58:20Z")

</div>

Can you connect to 127.0.0.1 port 27017

For example what “telnet 127.0.0.1 27017” while on this box tells ?

---

<div class="post-metadata">

**Author:** ![cukal](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/cukal/32/1277_2.png) [@cukal](https://forums.percona.com/u/cukal)\
**Post date:** [February 3, 2021, 8:23pm UTC](https://forums.percona.com/t/pmm-agent-throwing-errors/9078/5 "2021-02-03T20:23:43Z")

</div>

Yes, mongo is listening on 27017.

Netcat does a clean TCP connect:

> nc -v 127.0.0.1 27017  
> Ncat: Version 7.50 ( [Ncat - Netcat for the 21st Century](https://nmap.org/ncat) )  
> Ncat: Connected to 127.0.0.1:27017.

This also works:

> ./mongo -u mongo\_user --authenticationDatabase=admin --host 127.0.0.1  
> Percona Server for MongoDB shell version v4.0.20-14  
> Enter password:

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [February 3, 2021, 9:29pm UTC](https://forums.percona.com/t/pmm-agent-throwing-errors/9078/6 "2021-02-03T21:29:26Z")

</div>

This must be some sort of bug in the mongo exporter. Context’s in golang deal with multiple threads, timeouts, etc. It’s possible that thread #2 got the connection and caused thread #1 to cancel/abort, which would explain why you do have metrics.

Would you mind filling out a bug report at [https://jira.percona.com/](https://jira.percona.com/) ?
