Metric type mismatch: mongodb_collstats_storageStats_indexSizes should be Untyped
bugcommunitytriage
**Describe the bug**
When the --collector.collstats option is enabled, a metric gathering error occurs if a MongoDB index name ends with the suffix "count"
This is caused by a type mismatch where the exporter incorrectly identifies these metrics as Counter types, while the Prometheus gatherer expects them to be Untyped. Although there is an exception logic for collstats.storageStats.indexSizes., it appears to be failing in recent versions due to a mismatch in the trailing dot of the prefix string.
**To Reproduce**
Steps to reproduce the behavior:
1. Run mongodb_exporter v0.47.2 with the --collector.collstats flag enabled.
2. Create an index in MongoDB with a name ending in "count" (e.g., ix_task_context.count).
3. Check the exporter logs during the scrape interval.
**Logs**
```
time=2026-01-20T15:10:18.269+09:00 level=ERROR source=http_error_logger.go:53 msg="error gathering metrics:[from Gatherer #2] collected metric mongodb_collstats_storageStats_indexSizes label:{name:\"cl_id\" value:\"695dd6fe29c533b01e45c424\"} label:{name:\"cl_role\" value:\"\"} label:{name:\"collection\" value:\"test\"} label:{name:\"database\" value:\"ex\"} label:{name:\"index_name\" value:\"ix_task_context.count\"} label:{name:\"rs_nm\" value:\"standard-seven01\"} label:{name:\"rs_state\" value:\"1\"} counter:{value:4096} should be Untyped"
```
**Environment**
- OS: Rocky Linux release 8.10
- environment (docker, k8s, etc): on premise
- MongoDB version: 7.0.28
- Exporter version: 0.47.2
**Reference**
https://github.com/percona/mongodb_exporter/blob/a3ae4cc4142fd8855ec8c13873be00dd139c7261/exporter/metrics.go#L226
**Proposed Fix**
Update the reservedPrefixes to match the actual prefix string or adjust the prefix check logic to handle the missing trailing dot.
0 条评论