2020-04-27 21:19:27 +00:00
|
|
|
// Code generated by qtc from "alertmanager_request.qtpl". DO NOT EDIT.
|
|
|
|
// See https://github.com/valyala/quicktemplate for details.
|
|
|
|
|
2022-10-11 10:37:47 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:1
|
2020-04-27 21:19:27 +00:00
|
|
|
package notifier
|
|
|
|
|
2022-10-11 10:37:47 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:1
|
2020-04-27 21:19:27 +00:00
|
|
|
import (
|
|
|
|
"time"
|
2022-04-09 06:21:16 +00:00
|
|
|
|
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promrelabel"
|
2020-04-27 21:19:27 +00:00
|
|
|
)
|
|
|
|
|
2022-10-11 10:37:47 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:8
|
2020-04-27 21:19:27 +00:00
|
|
|
import (
|
|
|
|
qtio422016 "io"
|
|
|
|
|
|
|
|
qt422016 "github.com/valyala/quicktemplate"
|
|
|
|
)
|
|
|
|
|
2022-10-11 10:37:47 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:8
|
2020-04-27 21:19:27 +00:00
|
|
|
var (
|
|
|
|
_ = qtio422016.Copy
|
|
|
|
_ = qt422016.AcquireByteBuffer
|
|
|
|
)
|
|
|
|
|
2022-10-11 10:37:47 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:8
|
2022-04-09 06:21:16 +00:00
|
|
|
func streamamRequest(qw422016 *qt422016.Writer, alerts []Alert, generatorURL func(Alert) string, relabelCfg *promrelabel.ParsedConfigs) {
|
2022-10-11 10:37:47 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:8
|
2022-04-09 06:21:16 +00:00
|
|
|
qw422016.N().S(`[`)
|
2022-10-11 10:37:47 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:10
|
2022-04-09 06:21:16 +00:00
|
|
|
for i, alert := range alerts {
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:11
|
|
|
|
lbls := alert.applyRelabelingIfNeeded(relabelCfg)
|
|
|
|
|
2022-10-11 10:37:47 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:12
|
2024-09-09 11:34:48 +00:00
|
|
|
if len(lbls) == 0 {
|
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:12
|
|
|
|
continue
|
2022-10-11 10:37:47 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:12
|
2024-09-09 11:34:48 +00:00
|
|
|
}
|
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:12
|
|
|
|
qw422016.N().S(`{"startsAt":`)
|
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:14
|
|
|
|
qw422016.N().Q(alert.Start.Format(time.RFC3339Nano))
|
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:14
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().S(`,"generatorURL":`)
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:15
|
2020-06-21 10:32:46 +00:00
|
|
|
qw422016.N().Q(generatorURL(alert))
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:15
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().S(`,`)
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:16
|
2020-04-27 21:19:27 +00:00
|
|
|
if !alert.End.IsZero() {
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:16
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().S(`"endsAt":`)
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:17
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().Q(alert.End.Format(time.RFC3339Nano))
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:17
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().S(`,`)
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:18
|
2020-04-27 21:19:27 +00:00
|
|
|
}
|
2022-10-11 10:37:47 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:18
|
2024-09-09 11:34:48 +00:00
|
|
|
qw422016.N().S(`"labels": {`)
|
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:20
|
2022-10-10 07:44:58 +00:00
|
|
|
ll := len(lbls)
|
|
|
|
|
2022-10-11 10:37:47 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:21
|
2024-09-09 11:34:48 +00:00
|
|
|
for idx, l := range lbls {
|
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:22
|
2022-04-09 06:21:16 +00:00
|
|
|
qw422016.N().Q(l.Name)
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:22
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().S(`:`)
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:22
|
2022-04-09 06:21:16 +00:00
|
|
|
qw422016.N().Q(l.Value)
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:22
|
2022-10-10 07:44:58 +00:00
|
|
|
if idx != ll-1 {
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:22
|
2022-10-10 07:44:58 +00:00
|
|
|
qw422016.N().S(`,`)
|
2022-10-11 10:37:47 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:22
|
2024-09-09 11:34:48 +00:00
|
|
|
}
|
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:23
|
2020-04-27 21:19:27 +00:00
|
|
|
}
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:23
|
2022-04-09 06:21:16 +00:00
|
|
|
qw422016.N().S(`},"annotations": {`)
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:26
|
2020-04-27 21:19:27 +00:00
|
|
|
c := len(alert.Annotations)
|
|
|
|
|
2022-10-11 10:37:47 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:27
|
2024-09-09 11:34:48 +00:00
|
|
|
for k, v := range alert.Annotations {
|
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:28
|
2020-04-27 21:19:27 +00:00
|
|
|
c = c - 1
|
|
|
|
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:29
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().Q(k)
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:29
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().S(`:`)
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:29
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().Q(v)
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:29
|
2020-04-27 21:19:27 +00:00
|
|
|
if c > 0 {
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:29
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().S(`,`)
|
2022-10-11 10:37:47 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:29
|
2024-09-09 11:34:48 +00:00
|
|
|
}
|
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:30
|
2020-04-27 21:19:27 +00:00
|
|
|
}
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:30
|
2022-04-09 06:21:16 +00:00
|
|
|
qw422016.N().S(`}}`)
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:33
|
2020-04-27 21:19:27 +00:00
|
|
|
if i != len(alerts)-1 {
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:33
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().S(`,`)
|
2022-10-11 10:37:47 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:33
|
2024-09-09 11:34:48 +00:00
|
|
|
}
|
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:34
|
2020-04-27 21:19:27 +00:00
|
|
|
}
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:34
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().S(`]`)
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:36
|
2020-04-27 21:19:27 +00:00
|
|
|
}
|
|
|
|
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:36
|
2022-04-09 06:21:16 +00:00
|
|
|
func writeamRequest(qq422016 qtio422016.Writer, alerts []Alert, generatorURL func(Alert) string, relabelCfg *promrelabel.ParsedConfigs) {
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:36
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016 := qt422016.AcquireWriter(qq422016)
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:36
|
2022-04-09 06:21:16 +00:00
|
|
|
streamamRequest(qw422016, alerts, generatorURL, relabelCfg)
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:36
|
2020-04-27 21:19:27 +00:00
|
|
|
qt422016.ReleaseWriter(qw422016)
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:36
|
2020-04-27 21:19:27 +00:00
|
|
|
}
|
|
|
|
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:36
|
2022-04-09 06:21:16 +00:00
|
|
|
func amRequest(alerts []Alert, generatorURL func(Alert) string, relabelCfg *promrelabel.ParsedConfigs) string {
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:36
|
2020-04-27 21:19:27 +00:00
|
|
|
qb422016 := qt422016.AcquireByteBuffer()
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:36
|
2022-04-09 06:21:16 +00:00
|
|
|
writeamRequest(qb422016, alerts, generatorURL, relabelCfg)
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:36
|
2020-04-27 21:19:27 +00:00
|
|
|
qs422016 := string(qb422016.B)
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:36
|
2020-04-27 21:19:27 +00:00
|
|
|
qt422016.ReleaseByteBuffer(qb422016)
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:36
|
2020-04-27 21:19:27 +00:00
|
|
|
return qs422016
|
2024-09-09 11:34:48 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:36
|
2020-04-27 21:19:27 +00:00
|
|
|
}
|