-
Notifications
You must be signed in to change notification settings - Fork 2
/
types.go
58 lines (49 loc) · 1.51 KB
/
types.go
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"fmt"
"github.com/nlopes/slack"
"time"
)
type HookMessage struct {
Version string `json:"version"`
GroupKey string `json:"groupKey"`
Status string `json:"status" binding:"required"`
Receiver string `json:"receiver"`
GroupLabels KV `json:"groupLabels"`
CommonLabels KV `json:"commonLabels"`
CommonAnnotations KV `json:"commonAnnotations"`
ExternalURL string `json:"externalURL"`
Alerts []Alert `json:"alerts" binding:"required"`
}
// Alert holds one alert for notification templates.
type Alert struct {
Status AlertStatus `json:"status" binding:"required"`
Labels KV `json:"labels"`
Annotations KV `json:"annotations"`
StartsAt time.Time `json:"startsAt" binding:"required"`
EndsAt time.Time `json:"endsAt"`
GeneratorURL string `json:"generatorURL" binding:"required"`
Fingerprint string `json:"fingerprint"`
Channel string
MessageTS string
MessageBody []slack.Block
}
type AlertStatus string
const (
AlertStatusFiring AlertStatus = "firing"
AlertStatusResolved AlertStatus = "resolved"
)
// KV is a set of key/value string pairs.
type KV map[string]string
type SlackImage struct {
Url string `json:"url"`
Title string `json:"title"`
}
type PlotExpr struct {
Formula string
Operator string
Level float64
}
func (expr PlotExpr) String() string {
return fmt.Sprintf("%s %s %.2f", expr.Formula, expr.Operator, expr.Level)
}