mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
bf6c24d0f4
* [vmalert] config parser * make linter be happy * fix test * fix sprintf add test for rule validation
34 lines
958 B
Text
34 lines
958 B
Text
{% import (
|
|
"time"
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmalert/common"
|
|
) %}
|
|
{% stripspace %}
|
|
|
|
{% func amRequest(alerts []common.Alert, generatorURL func(string, string) string) %}
|
|
[
|
|
{% for i, alert := range alerts %}
|
|
{
|
|
"startsAt":{%q= alert.Start.Format(time.RFC3339Nano) %},
|
|
"generatorURL": {%q= generatorURL(alert.Group, alert.Name) %},
|
|
{% if !alert.End.IsZero() %}
|
|
"endsAt":{%q= alert.End.Format(time.RFC3339Nano) %},
|
|
{% endif %}
|
|
"labels": {
|
|
"alertname":{%q= alert.Name %}
|
|
{% for _,v := range alert.Labels %}
|
|
,{%q= v.Name %}:{%q= v.Value %}
|
|
{% 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 %}
|