-
Notifications
You must be signed in to change notification settings - Fork 0
/
Alert.go
39 lines (34 loc) · 911 Bytes
/
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
// Rule.go
package graphitenotifier
import (
"encoding/json"
"io/ioutil"
)
type Alert struct {
Name string `json:"name"`
Query string `json:"query"`
DisplayFormat struct {
Title []struct {
Match string `json:"match"`
Replace string `json:"replace"`
}
Units string `json:"units"`
} `json:"displayFormat"`
States map[string]string `json:"states"`
AlertConditions map[string]string `json:"alertConditions"`
Mail struct {
HTMLTemplate string `json:"htmlTemplate"`
ToList []string `json:"toList"`
CCList []string `json:"ccList"`
Subject string `json:"subject"`
} `json:"mail"`
}
func loadAlertFromFile(file string) (*Alert, error) {
var alert Alert
var err error
bytes, err := ioutil.ReadFile(file)
if err == nil {
err = json.Unmarshal(bytes, &alert)
}
return &alert, err
}