Skip to content

[Metricbeat][Redis] Do not drop keyspace metrics when INFO keyspace reports extra fields#52180

Open
aglowienka wants to merge 1 commit into
elastic:mainfrom
aglowienka:fix/redis-keyspace-field-count-guard
Open

[Metricbeat][Redis] Do not drop keyspace metrics when INFO keyspace reports extra fields#52180
aglowienka wants to merge 1 commit into
elastic:mainfrom
aglowienka:fix/redis-keyspace-field-count-guard

Conversation

@aglowienka

@aglowienka aglowienka commented Jul 22, 2026

Copy link
Copy Markdown

Proposed commit message

parseKeyspaceStats (metricbeat/module/redis/keyspace/data.go) only mapped a database line when
INFO keyspace split into exactly 3 or 4 comma-separated fields. Redis 7.4 added subexpiry and
Valkey 9.0 added keys_with_volatile_items; any further field makes the guard fail. When it fails
the line is silently skipped — no event, no error logged — so redis.keyspace stops producing data
entirely while redis.info keeps working.

This changes the guard to accept any line with at least 3 fields (>= 3). The parser is name-based
and the schema only extracts the fields it knows, so extra/unknown keyspace fields are ignored
safely and won't silently break collection again the next time a field is added.

Relates to #52178.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation (no user-facing fields change)
  • [ ] I have made corresponding change to the default configuration files (n/a)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool

Disruptive User Impact

None. The only behavior change is that keyspace lines carrying extra fields are no longer dropped.

How to test this PR locally

go test ./metricbeat/module/redis/keyspace/...

TestParseKeyspaceStats now includes a db line with extra fields and asserts it is still parsed.

Backport

The same bug affects the 8.19.x and 9.0–9.3 lines (see #52178), where redis.keyspace is
lost entirely on Valkey ≥ 9.0 / Redis ≥ 7.4. #47971 relaxed the guard to == 3 || == 4 on main
(9.4+) but was not backported; this change supersedes it with the more robust >= 3. Please
backport to 8.19 (and 9.0–9.3 if still applicable).

…ields

parseKeyspaceStats only mapped a database line when INFO keyspace split into
exactly 3 or 4 comma-separated fields. Redis 7.4 (subexpiry) and Valkey 9.0
(keys_with_volatile_items) append extra fields, and any further field makes the
guard fail; when it does the line is silently skipped with nothing logged, so
redis.keyspace stops producing data while redis.info keeps working.

Accept any line with at least 3 fields. The parser is name-based and the schema
only extracts the fields it knows, so extra fields are ignored safely.

Relates to elastic#52178

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@aglowienka
aglowienka requested a review from a team as a code owner July 22, 2026 08:34
@botelastic botelastic Bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jul 22, 2026
@botelastic

botelastic Bot commented Jul 22, 2026

Copy link
Copy Markdown

This pull request doesn't have a Team:<team> label.

@cla-checker-service

cla-checker-service Bot commented Jul 22, 2026

Copy link
Copy Markdown

💚 CLA has been signed

@github-actions

Copy link
Copy Markdown
Contributor

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)
  • /test : Run the Buildkite pipeline.

@mergify

mergify Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @aglowienka? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.

@aglowienka

Copy link
Copy Markdown
Author

CLA signed.
This bugfix should be backported to all active branches
I am unable to change labels

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

Labels

needs_team Indicates that the issue/PR needs a Team:* label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant