[Metricbeat][Redis] keyspace metrics silently dropped on Valkey ≥ 9.0 / Redis ≥ 7.4 (8.19.x–9.3.x)
- Dominant language
- Go
- Stars
- 12.7k
- Forks
- 5k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 364
Description
For confirmed bugs, please report:
- **Version:** 8.19.0–8.19.19 and 9.0.x–9.3.x (every release without #47971; fixed in 9.4.0+)
- **Operating System:** Any (verified on Linux)
- **Discuss Forum URL:** n/a — confirmed bug with root cause below
- **Steps to Reproduce:**
1. Point the redis module at a Valkey ≥ 9.0 (or Redis ≥ 7.4) host:
```yaml
- module: redis
metricsets: [info, keyspace]
hosts: [":6379"]
```
2. `redis.info` events are produced; `redis.keyspace` events are **not**, and nothing is logged.
**Expected:** one `redis.keyspace` event per database, as on Redis < 7.4 / Valkey < 9.0.
**Actual:** no `redis.keyspace` events at all — silently, with no error in the metricbeat log.
**Root cause:** `metricbeat/module/redis/keyspace/data.go` → `parseKeyspaceStats` maps a database
line only when it splits into exactly 3 comma-separated fields (`keys`, `expires`, `avg_ttl`):
```go
dbInfo := redis.ParseRedisLine(v, ",")
if len(dbInfo) == 3 {
...
}
```
Example `INFO keyspace` line on Valkey ≥ 9.0 (note the 4th field):
```
db0:keys=1000,expires=200,avg_ttl=0,keys_with_volatile_items=0
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
Redis 7.4 (`subexpiry`) and Valkey 9.0 (`keys_with_volatile_items`) append a 4th field, so the guard
is never true and every database line is silently skipped. Because it is a bare `if` (not an error
path), nothing is logged — the metricset just goes quiet while `redis.info` keeps working.
Confirmed against the 8.19.x and 9.3.x source; a local build changing the guard to
`len(dbInfo) >= 3` restores the events.
**Fixed on `main` / 9.4+ but not backported:** #47971 relaxed the guard to `== 3 || == 4` (for Redis
7.4's `subexpiry`), which also covers Valkey's 4-field line. It shipped only in 9.4.0+, so the
8.19.x and 9.0–9.3 lines remain affected.
**Request:** backport the parser fix to the still-supported 8.19.x line (and 9.0–9.3 if applicable).
#43887 has an unanswered comment reporting a Redis upgrade blocked on exactly this. `len(dbInfo) >= 3`
would be more robust than `== 3 || == 4` for future keyspace fields.
Companion enhancement (add the new Valkey field on `main`): #52179
Contributor guide
Research direction
Start with metricbeat/module/redis/keyspace/data.go and the parseKeyspaceStats guard, then compare the existing #47971 change on main. Reproduce with the supplied Valkey or Redis INFO keyspace line and verify that each database produces a redis.keyspace event on the supported affected branches, without silent omission.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, redis
- Domain
- databases, observability-sre
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100