Skip to content

Metric type mismatch: mongodb_collstats_storageStats_indexSizes should be Untyped #1229

Description

@light-won

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

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions