mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-11 14:53:49 +00:00
7ec6711f06
app/vmalert: Support custom URL for alerts source Add flag `external.alert.source` for configuring custom URL for alert's source. This may be handy to re-point default source URL to other systems like Grafana. Updates #517
33 lines
851 B
Text
33 lines
851 B
Text
{% import (
|
|
"time"
|
|
) %}
|
|
{% stripspace %}
|
|
|
|
{% func amRequest(alerts []Alert, generatorURL func(Alert) string) %}
|
|
[
|
|
{% 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": {
|
|
"alertname":{%q= alert.Name %}
|
|
{% for k,v := range alert.Labels %}
|
|
,{%q= k %}:{%q= v %}
|
|
{% 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 %}
|