0

I found a template for Prometheus Alert Manager for alerts, but I receive many unnecessary labels in notification. How to remove labels in template? This code is responsible for labels (look below). I dont have deep knowledge in Go Templating system & Json, so I'm asking for help.

{{ if gt (len $alerts.Labels.SortedPairs) 0 -}},
"labels": 
    {{ "{" }}
        {{ range $index, $label := $alerts.Labels.SortedPairs }}
            {{ if $index }}, 
            {{ end }}
            "{{ $label.Name }}": "{{ $label.Value }}"
        {{ end }}
    {{ "}" }}
{{- end }}
Epic555
  • 131
  • 5

1 Answers1

0

The method for removing labels in an alert template can vary depending on the specific alert system or software you are using. However, in general, you can follow these steps:

Locate the section of the alert template that contains the labels you want to remove. Delete or comment out the code that generates the labels. The code will vary depending on the programming language used to create the alert template. Save the changes to the alert template. If you're not sure how to locate the alert template or how to modify it, you may need to consult the documentation for the alert system or software you are using or seek assistance from a technical support team.

  • I wrote the code that is responsible for labels, look above, i can't delete or comment it, because this code also shows necessary labels. I tried to set conditions in If operator, but it didnt help. – Epic555 Mar 28 '23 at 03:43