-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathformat.go
More file actions
43 lines (34 loc) · 1.11 KB
/
format.go
File metadata and controls
43 lines (34 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package alertmanager
import (
"time"
"github.com/fatih/structs"
)
// Source: https://github.com/prometheus/alertmanager/blob/ba8da18fb2b769ace00d270d677980c4d57310e7/template/template.go
type Payload struct {
Receiver string `json:"receiver"`
Status string `json:"status"`
Alerts []*Alert `json:"alerts"`
GroupLabels map[string]string `json:"groupLabels"`
CommonLabels map[string]string `json:"commonLabels"`
CommonAnnotations map[string]string `json:"commonAnnotations"`
ExternalURL string `json:"externalURL"`
}
type Alert struct {
Status string `json:"status"`
Labels map[string]string `json:"labels"`
Annotations map[string]string `json:"annotations"`
StartsAt time.Time `json:"startsAt"`
EndsAt time.Time `json:"endsAt"`
GeneratorURL string `json:"generatorURL"`
Fingerprint string `json:"fingerprint"`
}
func (a *Alert) Map() map[string]interface{} {
s := structs.New(a)
s.TagName = "json"
return s.Map()
}
func (d *Payload) Map() map[string]interface{} {
s := structs.New(d)
s.TagName = "json"
return s.Map()
}