fix(benchmarks): escape backslash in JMX metrics regex pattern#97
Open
k-wall wants to merge 3 commits into
Open
fix(benchmarks): escape backslash in JMX metrics regex pattern#97k-wall wants to merge 3 commits into
k-wall wants to merge 3 commits into
Conversation
When kafka.metrics.enabled=true in the Helm values (e.g. via cluster-overrides.yaml), Strimzi deploys a JMX Prometheus exporter sidecar on each Kafka broker pod. Metrics are exposed on port 9404. Adds poll-kafka-metrics.sh, which port-forwards to a broker pod and polls /metrics every METRICS_INTERVAL seconds, writing timestamped snapshots to kafka-metrics.txt in the probe output directory. If the endpoint is not available (metrics disabled), the script exits cleanly after 15 s so the benchmark is not disrupted. Wires the kafka metrics poller into run-benchmark.sh alongside the existing proxy metrics poller — started before the benchmark and stopped after it completes. The captured metrics enable direct observation of Kafka-side bottlenecks during connection sweeps: - kafka_server_requesthandlerpool_requesthandleravagidle (near 0 = I/O thread pool saturated) - kafka_network_socketserver_networkprocessoravagidle (network threads) - kafka_server_brokertopicmetrics_bytesin/outpersec_rate (throughput) - kafka_server_replicamanager_isrshrinks_rate (replication lag) - kafka_network_requestmetrics_totaltimems_produce (produce latency) Assisted-by: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Sam Barker <sam@quadrocket.co.uk>
The JMX metrics ConfigMap was causing Strimzi to fail with "Failed to parse metrics configuration" due to an unescaped backslash in a regex pattern. In double-quoted YAML strings, backslash starts an escape sequence. The pattern `(\w+)` contains `\w` which is not a valid YAML escape sequence (unlike `\n`, `\t`, etc), causing SnakeYAML to fail with: "found unknown escape character w(119)". Fixed by escaping the backslash: `(\w+)` → `(\\w+)`, which produces a literal backslash in the resulting string for the JMX exporter regex. Also replaced em-dashes with ASCII hyphens in comments for consistency. Tested on OpenShift with Strimzi 1.0.0 - Kafka broker pods now create successfully with metrics enabled. Assisted-by: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Keith Wall <kwall@apache.org>
7 tasks
3b17c62 to
d1d36cf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the YAML parsing error that prevented Kafka broker pods from being created when
kafka.metrics.enabled=true.Root Cause
The JMX metrics ConfigMap contained an unescaped backslash in line 59:
In double-quoted YAML strings,
\starts an escape sequence. Since\wis not a valid YAML escape (unlike\n,\t, etc.), SnakeYAML fails with:Fix
Escape the backslash so it becomes a literal backslash in the JMX exporter config:
Also replaced em-dashes (—) with ASCII hyphens (-) in comments for consistency, though this was not the cause of the error (YAML fully supports UTF-8).
Testing
Tested on OpenShift with Strimzi 1.0.0:
Failed to parse metrics configuration, Kafka broker pods never createdThe benchmark test is currently running and successfully polling Kafka JMX metrics.
🤖 Generated with Claude Code