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

Better usability for `mongodb_collstats_storageStats_indexSizes_.*` metrics #882

Open rpstw opened 1 month ago

rpstw commented 1 month ago

97 introduce index sizes metrics years ago, which is useful for huge indexes monitoring.

However, similar to no.3 in https://github.com/percona/mongodb_exporter/pull/97#issuecomment-389147048, for every index, there will be a separate metric for every single index. For example, mongodb_collstats_storageStats_indexSizes_user_id_1 and mongodb_collstats_storageStats_indexSizes_id_1 could be the same metric (index size) for a same collection.

The number of indexes, or to be more precisely, the number of series is not a major concern from our side.

The problem is it's not of good usability. Here's the argue:

To query the index sizes, we have to perform a regex __name__ query, like {__name__=~"mongodb_collstats_storageStats_indexSizes_.*"}. This works but IMO is against the normal usage pattern of prometheus. A quote from their best practice:

should represent the same logical thing-being-measured across all label dimensions.

Therefor I propose we change the metric format from mongodb_collstats_storageStats_indexSizes_keya_1_keyb_1 to mongodb_collstats_storageStats_indexSizes{name="keya_1_keyb_1"}.The name of index will be a label instead of being included in the metric name.Since it's a backward break change, there should be a flag control this incompatible change. I'm ok with it being default old format.

Any thoughts?

BupycHuk commented 1 month ago

Hello, sounds like a good suggestion, let us discuss with Percona experts and ask if they really need per index metric and if they don't we will rework it to provide some agregated metrics