Open fgouteroux opened 2 months ago
the issue is that url.QueryUnescape()
gets called twice, once directly in queryFromGeneratorURL
, and once in url.Parse()
.
This means that expressions containing %
and +
characters will be rendered incorrectly
Describe the bug
I'm using the alertmanager template custom functions
grafanaExploreURL
andqueryFromGeneratorURL
to generate the grafana explore link in mimir alertmanager receiver.I got this error:
After some investigations, I found the root cause. If the alert
expr
contain the character%
like(consul_raft_peers % 2) < 1
, the custom functionqueryFromGeneratorURL
failed at line: https://github.com/grafana/mimir/blob/main/pkg/alertmanager/alertmanager_template.go#L75-L78.The QueryUnescape failed to decode the
expr
.From prometheus ruler code the Generator alert field should be url encoded.
expr unescaped
expr escaped
If the alert generatorURL field was really escaped, we should not have this issue.
This is an important issue as the alert notification could not be sent to the receiver.
To Reproduce
Steps to reproduce the behavior:
consul_raft_peers % 2
(queryFromGeneratorURL (index .Alerts 0).GeneratorURL)
Workaround
I found a dirty workaround to bypass custom functions
grafanaExploreURL
andqueryFromGeneratorURL
but it is really ugly and unreadable.