mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-22 08:26:19 +01: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
131 lines
4.8 KiB
Go
131 lines
4.8 KiB
Go
// Code generated by qtc from "alertmanager_request.qtpl". DO NOT EDIT.
|
|
// See https://github.com/valyala/quicktemplate for details.
|
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:1
|
|
package notifier
|
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:1
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:6
|
|
import (
|
|
qtio422016 "io"
|
|
|
|
qt422016 "github.com/valyala/quicktemplate"
|
|
)
|
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:6
|
|
var (
|
|
_ = qtio422016.Copy
|
|
_ = qt422016.AcquireByteBuffer
|
|
)
|
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:6
|
|
func streamamRequest(qw422016 *qt422016.Writer, alerts []Alert, generatorURL func(Alert) string) {
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:6
|
|
qw422016.N().S(`[`)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:8
|
|
for i, alert := range alerts {
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:8
|
|
qw422016.N().S(`{"startsAt":`)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:10
|
|
qw422016.N().Q(alert.Start.Format(time.RFC3339Nano))
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:10
|
|
qw422016.N().S(`,"generatorURL":`)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:11
|
|
qw422016.N().Q(generatorURL(alert))
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:11
|
|
qw422016.N().S(`,`)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:12
|
|
if !alert.End.IsZero() {
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:12
|
|
qw422016.N().S(`"endsAt":`)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:13
|
|
qw422016.N().Q(alert.End.Format(time.RFC3339Nano))
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:13
|
|
qw422016.N().S(`,`)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:14
|
|
}
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:14
|
|
qw422016.N().S(`"labels": {"alertname":`)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:16
|
|
qw422016.N().Q(alert.Name)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:17
|
|
for k, v := range alert.Labels {
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:17
|
|
qw422016.N().S(`,`)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:18
|
|
qw422016.N().Q(k)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:18
|
|
qw422016.N().S(`:`)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:18
|
|
qw422016.N().Q(v)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:19
|
|
}
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:19
|
|
qw422016.N().S(`},"annotations": {`)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:22
|
|
c := len(alert.Annotations)
|
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:23
|
|
for k, v := range alert.Annotations {
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:24
|
|
c = c - 1
|
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:25
|
|
qw422016.N().Q(k)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:25
|
|
qw422016.N().S(`:`)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:25
|
|
qw422016.N().Q(v)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:25
|
|
if c > 0 {
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:25
|
|
qw422016.N().S(`,`)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:25
|
|
}
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:26
|
|
}
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:26
|
|
qw422016.N().S(`}}`)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:29
|
|
if i != len(alerts)-1 {
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:29
|
|
qw422016.N().S(`,`)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:29
|
|
}
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:30
|
|
}
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:30
|
|
qw422016.N().S(`]`)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:32
|
|
}
|
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:32
|
|
func writeamRequest(qq422016 qtio422016.Writer, alerts []Alert, generatorURL func(Alert) string) {
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:32
|
|
qw422016 := qt422016.AcquireWriter(qq422016)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:32
|
|
streamamRequest(qw422016, alerts, generatorURL)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:32
|
|
qt422016.ReleaseWriter(qw422016)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:32
|
|
}
|
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:32
|
|
func amRequest(alerts []Alert, generatorURL func(Alert) string) string {
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:32
|
|
qb422016 := qt422016.AcquireByteBuffer()
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:32
|
|
writeamRequest(qb422016, alerts, generatorURL)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:32
|
|
qs422016 := string(qb422016.B)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:32
|
|
qt422016.ReleaseByteBuffer(qb422016)
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:32
|
|
return qs422016
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:32
|
|
}
|