Skip to content

fix(benchmarks): escape backslash in JMX metrics regex pattern#97

Open
k-wall wants to merge 3 commits into
SamBarker:feat/omb-kafka-metricsfrom
k-wall:fix/kafka-metrics-yaml-escape
Open

fix(benchmarks): escape backslash in JMX metrics regex pattern#97
k-wall wants to merge 3 commits into
SamBarker:feat/omb-kafka-metricsfrom
k-wall:fix/kafka-metrics-yaml-escape

Conversation

@k-wall
Copy link
Copy Markdown

@k-wall k-wall commented May 19, 2026

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:

- pattern: "kafka.network<type=RequestMetrics, name=TotalTimeMs, request=Produce><>(\w+)"

In double-quoted YAML strings, \ starts an escape sequence. Since \w is not a valid YAML escape (unlike \n, \t, etc.), SnakeYAML fails with:

found unknown escape character w(119)
in 'reader', line 44, column 88:
... otalTimeMs, request=Produce><>(\w+)"

Fix

Escape the backslash so it becomes a literal backslash in the JMX exporter config:

- pattern: "kafka.network<type=RequestMetrics, name=TotalTimeMs, request=Produce><>(\\w+)"

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:

  • ✅ Before fix: Failed to parse metrics configuration, Kafka broker pods never created
  • ✅ After fix: Kafka broker pods create successfully, metrics endpoint available on port 9404

The benchmark test is currently running and successfully polling Kafka JMX metrics.

🤖 Generated with Claude Code

SamBarker and others added 3 commits May 15, 2026 20:41
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants