How to use the templating Remove method

Hi, when sending an email alert a lot of useless labels also get sent. I’d like to remove the ones I don’t need. According to the docs we can achieve this by using the Remove method, but I can’t figure out how to use it (provide a list of strings to it).

We can loop over sorted pairs and display them all like this:

{{ range .Labels.SortedPairs }}{{ .Name }}: {{ .Value }}{{ end }}

The Remove method requires a list as input. But how does one use this method inside the Grafana templating language?

I am on Grafana 9.1.0 and using Unified Alerting.

1 Like

I’d very much like to know this as well - I’ve already spent half a day trying this out/googling for any examples with no luck whatsoever :grimacing:

I happened to have the same issue this week. You can find an example of how to use it Remove function in KV is hard to use from templates · Issue #3393 · prometheus/alertmanager · GitHub.

2 Likes