Hi folks, how are you?
We need to manipulate the .GeneratorURL.
For example:
*.GeneratorURL*:
https://<prometheus_url>/graph?g0.expr=count%28up%29+%3E+0+and+on+%28%29+%28is_metrics_platform_up+%3D%3D+1%29&g0.tab=1
I need to remove: *+and+on+%28%29+%28is_metrics_platform_up+%3D%3D+1%29*
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 "prometheus.url" -}}
{{if eq .GroupLabels.env "prod" }}
{{ (index .Alerts 0).GeneratorURL | reReplaceAll
"\\+and\\+on\\+%28%29\\+%28is_metrics_platform_up\\+%3D%3D\\+1%29" "" }}
{{ else }}
{{ (index .Alerts 0).GeneratorURL }}{{ end }}{{ end }}
{"caller":"dispatch.go:354","component":"dispatcher","err":"ream_slack/slack[0]:
notify retry canceled due to unrecoverable error after 1 attempts:
template: service.tmpl:13:4: executing \"prometheus.url\" at <index .Alerts
0>: error calling index: index of untyped
nil","level":"error","msg":"Notify for alerts
failed","num_alerts":1,"ts":"2023-05-17T21:00:09.541Z"}
I do not know how to remove this part of the URL, someone can help me?
--
You received this message because you are subscribed to the Google Groups
"Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/prometheus-developers/e40ec0e8-b5e4-41b5-a065-0492f1be8b6dn%40googlegroups.com.