Skip to content

ERR unknown command 'SELECT' when using stream key patterns with Valkey Sentinel #1013

@SheGe

Description

@SheGe

Describe the problem
When configuring redis_exporter to scan Valkey stream keys (e.g., --check-streams=events:*) in a Sentinel-managed Valkey deployment, the exporter attempts to execute SELECT before scanning keys. This results in ERR unknown command 'SELECT' because Valkey (≤8.x) does not support SELECT (at least in Sentinel and/or Cluster mode). Stream metrics (e.g., valkey_stream_length) are not exposed due to this error.

What version of redis_exporter are you running?
[X] 1.x.x

  • Version: 1.73.0

Running the exporter

redis_exporter --check-streams=events:* --exclude-latency-histogram-metrics=true

Expected behavior

  • The exporter should avoid the SELECT command in Sentinel/Cluster mode and scan keys directly in database 0.
  • Stream metrics like valkey_stream_length{key="events:xxx"} should be exposed without errors.

Additional context

  • Valkey Documentation: The Valkey SELECT command docs state that SELECT will be supported in Cluster mode starting in Valkey 9.0 (tentative release: September 2025), but it may remain unsupported in Sentinel mode.
  • Workarounds:
    • Gracefully ignore SELECT errors, db is a property of the client connection in Valkey (log a warning).
    • Add new flag(s) (e.g., --skip-db-selection, --db=0) to disable SELECT explicitly, or to configure the database that needs to be used while establishing a connection.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions