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:
- Run mongodb_exporter v0.47.2 with the --collector.collstats flag enabled.
- Create an index in MongoDB with a name ending in "count" (e.g., ix_task_context.count).
- 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
|
reservedPrefixes := []string{"collstats.storageStats.indexSizes."} |
Proposed Fix
Update the reservedPrefixes to match the actual prefix string or adjust the prefix check logic to handle the missing trailing dot.
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:
Logs
Environment
Reference
mongodb_exporter/exporter/metrics.go
Line 226 in a3ae4cc
Proposed Fix
Update the reservedPrefixes to match the actual prefix string or adjust the prefix check logic to handle the missing trailing dot.