This PR fixes several issues I was having with mongodb_exporter with -mongodb.collect.database enabled. My databases do not have any shards.
The prometheus library panics with "inconsistent label cardinality". This is fixed by passing "" for the shard label of the db status gauges when there are no shards.
In GetDatabaseStatus, the dbStatus object was empty after running the database query, causing failure to collect any statistics. This seems to be caused by embedding the RawStatus type in DatabaseStatus. The object is populated successfully when duplicating the fields in DatabaseStatus rather than embedding the type.
GetDatabaseStatus passes &dbStatus to session.DB(db).Run, but the type of dbStatus is *DatabaseStatus resulting in a pointer to a pointer to a DatabaseStatus being passed. This PR makes dbStatus a DatabaseStatus, avoiding the extra indirection.
@dcu Any chance this will be merged? It fixes the same "inconsistent label cardinality" problem we were experiencing on our own servers. (Thank you, @jnjackins!)
This PR fixes several issues I was having with mongodb_exporter with -mongodb.collect.database enabled. My databases do not have any shards.