mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
b099d84271
* Initial rules evaluation support. Rules are now store alerts state in private field `alerts`. Every evaluation updates the alerts and state. Every unique metric received from datastore represents a unique alert, uniqueness is guaranteed by hashing ordered labelset. * merge with master * cleanup * support endAt parameter as 3*evaluationInterval for active alerts * make golint happy
33 lines
872 B
Text
33 lines
872 B
Text
{% import (
|
|
"time"
|
|
) %}
|
|
{% stripspace %}
|
|
|
|
{% func amRequest(alerts []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 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 %}
|