Skip to content

mongodb_version_info metric requires --compatible-mode; should be exposed unconditionally #1317

Description

@rajarameshyv

Summary

mongodb_version_info (server version/edition/vendor info) is only emitted when --compatible-mode is enabled. Since this is a legacy-compat flag intended for migrating old dashboards (and it also brings back a large set of other old-style duplicate metrics), users who don't need those legacy metrics have no way to get MongoDB/mongos version info without also enabling compat mode and its associated metric-cardinality overhead.

Version/edition info is generally useful data (fleet-wide version auditing, upgrade tracking, alerting on EOL versions, mongod/mongos version-skew detection across a cluster) that shouldn't be tied to a backward-compatibility flag.

Environment

mongodb_exporter version: v0.51.0 (Commit d0d33e6, built 2026-04-30T13:46:35Z)
MongoDB version: 8.0.26 (Enterprise)
Deployment: sharded cluster (shard node)
OS: Linux

Steps to reproduce

Run mongodb_exporter with --compatible-mode enabled:

/usr/bin/mongodb_exporter \
  --mongodb.connect-timeout-ms=20000 \
  --compatible-mode \
  --discovering-mode \
  --collector.diagnosticdata \
  --collector.replicasetstatus \
  --collector.replicasetconfig \
  --collector.dbstats \
  --collector.dbstatsfreestorage \
  --collector.indexstats \
  --collector.collstats \
  --collector.fcv \
  --collector.currentopmetrics \
  --collector.currentopmetrics-slow-time=1m \
  --web.listen-address 127.0.0.1:10052 \
  --mongodb.uri=mongodb://127.0.0.1:27017/?connect=direct&tls=true&...

Curl the metrics endpoint:

curl 127.0.0.1:10052/metrics | grep mongodb_version_info

Result:

   # HELP mongodb_version_info The server version
   # TYPE mongodb_version_info gauge
   mongodb_version_info{edition="Enterprise",mongodb="8.0.26",vendor="MongoDB"} 1

Remove only --compatible-mode (all other flags unchanged) and restart the exporter.
Curl the metrics endpoint again:

curl 127.0.0.1:10052/metrics | grep mongodb_version_info

Result: no output — the metric is completely absent.

Expected behavior

mongodb_version_info (or an equivalent version/edition/vendor info metric) should be exposed regardless of --compatible-mode, since it's not really a "legacy naming" concern — it's simply useful, low-cardinality, static info about the target instance.

Actual behavior

The metric is only present when --compatible-mode is enabled, and disappears entirely otherwise.

Suggested fix / options

Move the version-info metric out of the compatible-mode-only code path and into the always-on general/default collector, OR
Add a small, dedicated, always-on flag/collector for it (e.g. --collector.versioninfo, default true) so users aren't forced into full compatible-mode (and its extra old-style metric set) just to get version data, OR
At minimum, document clearly in the README/REFERENCE that mongodb_version_info requires --compatible-mode, since this isn't currently obvious from the docs and the metric's HELP text ("The server version") doesn't indicate any dependency on that flag.

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