Escaping of promql queries in alertmanager Slack alerts broken
When we have an alerting rule that uses backslashes, the links posted by alertmanager to the promql query in grafana ("grafana explore") are broken because the backslashes are not sufficiently escaped.
Impact:
This is impacting SRE's ability to quickly understand the nature and timing of an incoming workhorse
alert.
Example alert:
Broken link:
Error:
bad_data: invalid parameter "query": 4:135: parse error: unknown escape sequence U+007A 'z'
Problem:
The query contains matchers that look like this:
route!="^/([^/]+/){1,}[^/]+/uploads\z",route!="^/-/health$",route!="^/-/(readiness|liveness)$",route!="^/([^/]+/){1,}[^/]+\.git/git-receive-pack\z",route!="^/([^/]+/){1,}[^/]+\.git/git-upload-pack\z"
Fix:
The \
needs to be escaped, so \z
needs to be \\z
and \.
needs to be \\.
.
Edited by Igor