percona / mongodb_exporter

A Prometheus exporter for MongoDB including sharding, replication and storage engines
Apache License 2.0
1.16k stars 425 forks source link

When mongodb down, mongodb_up does not return a correct value #766

Closed xucong18 closed 8 months ago

xucong18 commented 8 months ago

Describe the bug When mongodb is started normally, the value of mogndb_up is 1. When mongodb is stopped, the value of mogndb_Up is empty. As a result, mongodb running status cannot be properly monitored

Logs

ERRO[0639] Cannot connect to MongoDB: cannot connect to MongoDB: server selection error: server selection timeout, current topology: { Type: Single, Servers: [{ Addr: 127.0.0.1:27017, Type: Unknown, Last error: dial tcp 127.0.0.1:27017: connect: no route to host }, ] } WARN[0641] cannot load topology labels: cannot check if the instance is an arbiter: server selection error: context deadline exceeded, current topology: { Type: Single, Servers: [{ Addr: 127.0.0.1:27017, Type: Unknown, Last error: dial tcp 127.0.0.1:27017: connect: connection refused }, ] } ERRO[0641] Registry - Cannot get node type to check if this is a mongos : server selection error: context deadline exceeded, current topology: { Type: Single, Servers: [{ Addr: 127.0.0.1:27017, Type: Unknown, Last error: dial tcp 127.0.0.1:27017: connect: connection refused }, ] } ERRO[0641] Registry - Cannot get arbiterOnly to check if this is arbiter role : cannot check if the instance is an arbiter: server selection error: context deadline exceeded, current topology: { Type: Single, Servers: [{ Addr: 127.0.0.1:27017, Type: Unknown, Last error: dial tcp 127.0.0.1:27017: connect: connection refused }, ] }

version: mongodb_exporter-0.40.0

xucong18 commented 8 months ago

@BupycHuk

xucong18 commented 8 months ago

When I set ConnectTimeoutMS to less than 3000, the data is returned normally command: --mongodb.connect-timeout-ms=2000

LOGS:

ERRO[0153] error while checking mongodb connection: server selection error: server selection timeout, current topology: { Type: Single, Servers: [{ Addr: 127.0.0.1:27017, Type: Unknown, Last error: dial tcp 127.0.0.1:27017: connect: connection refused }, ] }. mongo_up is set to 0