Hi folks, how are you?
We need to manipulate the .GeneratorURL.
For example:
.GeneratorURL: https://<prometheus_url>/graph?g0.expr=(sum(up))%20and%20on()%20(is_metrics_platform_up%20%3D%3D%201)&g0.tab=1&g0.stacked=0&g0.show_exemplars=0&g0.range_input=1h
I need to remove: %20and%20on()%20(is_metrics_platform_up%20%3D%3D%201)
In the real world, I could get each parameter, decode it, remove the suffix and encode again to generate a new GeneratorURL, but in the alertmanager template I do not know how to do this.
The only way to that I found, is
{{ define "url" -}}
{{if and (eq .GroupLabels.env "prod") (contains (index .Alerts 0).GeneratorURL "is_metrics_platform_up") }}
{{js (index .Alerts 0).GeneratorURL | reReplaceAll "%20and%20on()%20(is_metrics_platform_up%20%3D%3D%201)" "" }}
{{ else }}
{{ (index .Alerts 0).GeneratorURL }}{{ end }}{{ end }}
Is there a way to do this more elegant?