mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-01 14:47:38 +00:00
d9abdc57d4
vmalert: prevent duplicating label `alertname` for notifications The issue has no impact on alerting procedure. But still needs to be fixed for clarity. https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3053 Signed-off-by: lihaowei <haoweili35@gmail.com>
36 lines
1 KiB
Text
36 lines
1 KiB
Text
{% import (
|
|
"time"
|
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promrelabel"
|
|
) %}
|
|
{% stripspace %}
|
|
|
|
{% func amRequest(alerts []Alert, generatorURL func(Alert) string, relabelCfg *promrelabel.ParsedConfigs) %}
|
|
[
|
|
{% for i, alert := range alerts %}
|
|
{
|
|
"startsAt":{%q= alert.Start.Format(time.RFC3339Nano) %},
|
|
"generatorURL": {%q= generatorURL(alert) %},
|
|
{% if !alert.End.IsZero() %}
|
|
"endsAt":{%q= alert.End.Format(time.RFC3339Nano) %},
|
|
{% endif %}
|
|
"labels": {
|
|
{% code lbls := alert.toPromLabels(relabelCfg) %}
|
|
{% code ll := len(lbls) %}
|
|
{% for idx, l := range lbls %}
|
|
{%q= l.Name %}:{%q= l.Value %}{% if idx != ll-1 %}, {% endif %}
|
|
{% endfor %}
|
|
},
|
|
"annotations": {
|
|
{% code c := len(alert.Annotations) %}
|
|
{% for k,v := range alert.Annotations %}
|
|
{% code c = c-1 %}
|
|
{%q= k %}:{%q= v %}{% if c > 0 %},{% endif %}
|
|
{% endfor %}
|
|
}
|
|
}
|
|
{% if i != len(alerts)-1 %},{% endif %}
|
|
{% endfor %}
|
|
]
|
|
{% endfunc %}
|
|
{% endstripspace %}
|