mongodb_exporter icon indicating copy to clipboard operation
mongodb_exporter copied to clipboard

rs_state out of sync with member_state

Open vishal-h opened this issue 4 years ago • 1 comments

If I run the exporter and enable it scrape multiple URIs, like

./mongodb_exporter --mongodb.uri=mongodb://127.0.0.1:17000,127.0.0.1:17001,127.0.0.1:17002,[host:port] --mongodb.direct-connect=false --web.listen-address=":9200" --discovering-mode &

and query a metric like mongodb_rs_members_id[5m]

then the labels are shown like this {member_idx="172.19.0.2:27017", member_state="SECONDARY", rs_nm="cnf-serv", rs_state="1"}

rs_state in the above should be 2 to reflect that it's a secondary

vishal-h avatar Aug 03 '21 14:08 vishal-h

Hi,

Even when the MongoDB driver allows setting several hosts in the URI, the exporter is not designed to support multiple hosts. Also, mongodb.direct-connect is true by default. The topology information is being loaded only once per scrape here and you can see it just returns ReplicasetGetStatus.MyState from getDiagnosticData. Since we are not handling the connection manually, the driver returns the state of the server it is connected to.

percona-csalguero avatar Aug 03 '21 18:08 percona-csalguero