2020-02-21 22:15:05 +01:00
|
|
|
{% import (
|
2020-04-11 11:40:24 +02:00
|
|
|
"strconv"
|
2020-02-21 22:15:05 +01:00
|
|
|
"time"
|
|
|
|
) %}
|
|
|
|
{% stripspace %}
|
|
|
|
|
2020-04-06 13:44:03 +02:00
|
|
|
{% func amRequest(alerts []Alert, generatorURL func(string, string) string) %}
|
2020-03-13 11:19:31 +01:00
|
|
|
[
|
|
|
|
{% for i, alert := range alerts %}
|
2020-02-21 22:15:05 +01:00
|
|
|
{
|
|
|
|
"startsAt":{%q= alert.Start.Format(time.RFC3339Nano) %},
|
2020-05-10 18:58:17 +02:00
|
|
|
"generatorURL": {%q= generatorURL(strconv.FormatUint(alert.GroupID, 10), strconv.FormatUint(alert.ID, 10)) %},
|
2020-02-21 22:15:05 +01:00
|
|
|
{% if !alert.End.IsZero() %}
|
|
|
|
"endsAt":{%q= alert.End.Format(time.RFC3339Nano) %},
|
|
|
|
{% endif %}
|
|
|
|
"labels": {
|
|
|
|
"alertname":{%q= alert.Name %}
|
2020-04-06 13:44:03 +02:00
|
|
|
{% for k,v := range alert.Labels %}
|
|
|
|
,{%q= k %}:{%q= v %}
|
2020-02-21 22:15:05 +01:00
|
|
|
{% endfor %}
|
|
|
|
},
|
|
|
|
"annotations": {
|
2020-03-13 11:19:31 +01:00
|
|
|
{% code c := len(alert.Annotations) %}
|
|
|
|
{% for k,v := range alert.Annotations %}
|
|
|
|
{% code c = c-1 %}
|
|
|
|
{%q= k %}:{%q= v %}{% if c > 0 %},{% endif %}
|
|
|
|
{% endfor %}
|
2020-02-21 22:15:05 +01:00
|
|
|
}
|
|
|
|
}
|
2020-03-13 11:19:31 +01:00
|
|
|
{% if i != len(alerts)-1 %},{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
]
|
2020-02-21 22:15:05 +01:00
|
|
|
{% endfunc %}
|
|
|
|
{% endstripspace %}
|