# Metricset mongodb.replstatus only work on primary server

**URL:** <https://discuss.elastic.co/t/metricset-mongodb-replstatus-only-work-on-primary-server/232045>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [May 11, 2020, 2:30pm UTC](https://discuss.elastic.co/t/metricset-mongodb-replstatus-only-work-on-primary-server/232045 "2020-05-11T14:30:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dbargo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dbargo/32/68072_2.png) [@dbargo](https://discuss.elastic.co/u/dbargo)\
**Post date:** [May 11, 2020, 2:30pm UTC](https://discuss.elastic.co/t/metricset-mongodb-replstatus-only-work-on-primary-server/232045/1 "2020-05-11T14:30:46Z")

</div>

We deploy metricbeat on 3 mongo servers ( 1 primary, 2 secondary )  
While metricbeat run on secondary server we get the following error:  
Error fetching data for metricset mongodb.replstatus: error getting replication info: no reachable servers  
Once this server become the primary this error disappear.  
Is this a bug or by design that metricset mongodb.replstatus work only for primary server:  
metricbeat.yml -

```auto
metricbeat.modules:
- module: mongodb
  metricsets: ["dbstats", "status", "collstats", "metrics", "replstatus"]
  period: 10s
  enabled: true

  # The hosts must be passed as MongoDB URLs in the format:
  # [mongodb://][user:pass@]host[:port].
  # The username and password can also be set using the respective configuration
  # options. The credentials in the URL take precedence over the username and
  # password configuration options.
  hosts: ["localhost:27017"]
  username: beats
  password: pass

```

---

<div class="post-metadata">

**Author:** ![Mario\_Castro](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mario_castro/32/35107_2.png) [@Mario\_Castro](https://discuss.elastic.co/u/Mario_Castro)\
**Post date:** [May 13, 2020, 9:15am UTC](https://discuss.elastic.co/t/metricset-mongodb-replstatus-only-work-on-primary-server/232045/2 "2020-05-13T09:15:06Z")

</div>

Hi @dbargo 🙂

I guess that replication only servers do not expose some cluster wide metrics, which makes sense or you'll get duplicate data. I'm not sure but it might be the case that you only need to monitor the master to get cluster wide metrics (which I know is unfortunate as the master and its IP can change but something you can solve with DNS)

Can you check if it's something related with a single metricset by enabling/disabling them one by one too, please?

Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 10, 2020, 9:15am UTC](https://discuss.elastic.co/t/metricset-mongodb-replstatus-only-work-on-primary-server/232045/3 "2020-06-10T09:15:09Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
