How to monitor the state of MongoDB Replica Set members using Datadog agent? And by state I mean whether the node is Primary, Secondary, Arbiter.., and that in order to send an alert when the state changes. Thank you in advance.
How to monitor the state of MongoDB Replica Set members using Datadog agent? And by state I mean whether the node is Primary, Secondary, Arbiter.., and that in order to send an alert when the state changes. Thank you in advance.
With a Replica Set there are metrics that need to be collected only once (like the number of collections) and metrics that needs to be collected from every node. For this to happen, according to the docs, you need to set up one check instance for each member of the replica set.
init_config:
instances:
- hosts:
- primary_host:<PORT>
username: foo
password: bar
....
- hosts:
- secondary_host:<PORT>
username: foo
password: bar
....
The check figures out if the node is a primary or secondary and collects accordingly. Metrics from replica sets will be tagged with replset_name and replset_state.