-
Notifications
You must be signed in to change notification settings - Fork 8
/
events_alert.go
73 lines (62 loc) · 1.83 KB
/
events_alert.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package scalingo
import "fmt"
type EventAlertTypeData struct {
SenderName string `json:"sender_name"`
Metric string `json:"metric"`
Limit float64 `json:"limit"`
LimitText string `json:"limit_text"`
Value float64 `json:"value"`
ValueText string `json:"value_text"`
Activated bool `json:"activated"`
SendWhenBelow bool `json:"send_when_below"`
RawLimit float64 `json:"raw_limit"`
RawValue float64 `json:"raw_value"`
}
type EventAlertType struct {
Event
TypeData EventAlertTypeData `json:"type_data"`
}
func (ev *EventAlertType) String() string {
d := ev.TypeData
var res string
if d.SendWhenBelow {
res = "Low"
} else {
res = "High"
}
res += fmt.Sprintf(" %s usage on container %s ", d.Metric, d.SenderName)
if ev.TypeData.Activated {
res += "triggered"
} else {
res += "resolved"
}
res += fmt.Sprintf(" (value: %s, limit: %s)", d.ValueText, d.LimitText)
return res
}
type EventNewAlertTypeData struct {
ContainerType string `json:"container_type"`
Metric string `json:"metric"`
Limit float64 `json:"limit"`
LimitText string `json:"limit_text"`
SendWhenBelow bool `json:"send_when_below"`
}
type EventNewAlertType struct {
Event
TypeData EventNewAlertTypeData `json:"type_data"`
}
func (ev *EventNewAlertType) String() string {
d := ev.TypeData
return fmt.Sprintf("Alert created about %s on container %s (limit: %s)", d.Metric, d.ContainerType, d.LimitText)
}
type EventDeleteAlertTypeData struct {
ContainerType string `json:"container_type"`
Metric string `json:"metric"`
}
type EventDeleteAlertType struct {
Event
TypeData EventDeleteAlertTypeData `json:"type_data"`
}
func (ev *EventDeleteAlertType) String() string {
d := ev.TypeData
return fmt.Sprintf("Alert deleted about %s on container %s", d.Metric, d.ContainerType)
}