Rename AlertHandlers to AlertNodes
parent
c0d1aa97a4
commit
851149b397
|
@ -229,7 +229,7 @@ type AlertRule struct {
|
|||
TICKScript TICKScript `json:"tickscript"` // TICKScript is the raw tickscript associated with this Alert
|
||||
Query *QueryConfig `json:"query"` // Query is the filter of data for the alert.
|
||||
Every string `json:"every"` // Every how often to check for the alerting criteria
|
||||
AlertHandlers AlertHandlers `json:"alertHandlers"` // AlertHandlers defines the destinations for the alert
|
||||
AlertNodes AlertNodes `json:"alertNodes"` // AlertNodes defines the destinations for the alert
|
||||
Message string `json:"message"` // Message included with alert
|
||||
Details string `json:"details"` // Details is generally used for the Email alert. If empty will not be added.
|
||||
Trigger string `json:"trigger"` // Trigger is a type that defines when to trigger the alert
|
||||
|
|
10
kapacitor.go
10
kapacitor.go
|
@ -2,8 +2,8 @@ package chronograf
|
|||
|
||||
import "encoding/json"
|
||||
|
||||
// AlertHandlers defines all possible kapacitor interactions with an alert.
|
||||
type AlertHandlers struct {
|
||||
// AlertNodes defines all possible kapacitor interactions with an alert.
|
||||
type AlertNodes struct {
|
||||
IsStateChangesOnly bool `json:"stateChangesOnly"` // IsStateChangesOnly will only send alerts on state changes.
|
||||
UseFlapping bool `json:"useFlapping"` // UseFlapping enables flapping detection. Flapping occurs when a service or host changes state too frequently, resulting in a storm of problem and recovery notification
|
||||
Posts []*Post `json:"post"` // HTTPPost will post the JSON alert data to the specified URLs.
|
||||
|
@ -133,9 +133,9 @@ type OpsGenie struct {
|
|||
// Talk sends alerts to Jane Talk (https://jianliao.com/site)
|
||||
type Talk struct{}
|
||||
|
||||
// MarshalJSON converts AlertHandlers to JSON
|
||||
func (n *AlertHandlers) MarshalJSON() ([]byte, error) {
|
||||
type Alias AlertHandlers
|
||||
// MarshalJSON converts AlertNodes to JSON
|
||||
func (n *AlertNodes) MarshalJSON() ([]byte, error) {
|
||||
type Alias AlertNodes
|
||||
var raw = &struct {
|
||||
Type string `json:"typeOf"`
|
||||
*Alias
|
||||
|
|
|
@ -89,7 +89,7 @@ func addAlertNodes(rule chronograf.AlertRule) (string, error) {
|
|||
|
||||
// AlertServices generates alert chaining methods to be attached to an alert from all rule Services
|
||||
func AlertServices(rule chronograf.AlertRule) (string, error) {
|
||||
node, err := addAlertNodes(rule.AlertHandlers)
|
||||
node, err := addAlertNodes(rule.AlertNodes)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ func AlertServices(rule chronograf.AlertRule) (string, error) {
|
|||
return node, nil
|
||||
}
|
||||
|
||||
func addAlertNodes(handlers chronograf.AlertHandlers) (string, error) {
|
||||
func addAlertNodes(handlers chronograf.AlertNodes) (string, error) {
|
||||
octets, err := json.Marshal(&handlers)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestAlertServices(t *testing.T) {
|
|||
{
|
||||
name: "Test several valid services",
|
||||
rule: chronograf.AlertRule{
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
Slack: []*chronograf.Slack{{}},
|
||||
VictorOps: []*chronograf.VictorOps{{}},
|
||||
Email: []*chronograf.Email{{}},
|
||||
|
@ -32,7 +32,7 @@ func TestAlertServices(t *testing.T) {
|
|||
{
|
||||
name: "Test single valid service",
|
||||
rule: chronograf.AlertRule{
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
Slack: []*chronograf.Slack{{}},
|
||||
},
|
||||
},
|
||||
|
@ -43,7 +43,7 @@ func TestAlertServices(t *testing.T) {
|
|||
{
|
||||
name: "Test single valid service and property",
|
||||
rule: chronograf.AlertRule{
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
Slack: []*chronograf.Slack{
|
||||
{
|
||||
Channel: "#general",
|
||||
|
@ -59,7 +59,7 @@ func TestAlertServices(t *testing.T) {
|
|||
{
|
||||
name: "Test tcp",
|
||||
rule: chronograf.AlertRule{
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
TCPs: []*chronograf.TCP{
|
||||
{
|
||||
Address: "myaddress:22",
|
||||
|
@ -74,7 +74,7 @@ func TestAlertServices(t *testing.T) {
|
|||
{
|
||||
name: "Test log",
|
||||
rule: chronograf.AlertRule{
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
Log: []*chronograf.Log{
|
||||
{
|
||||
FilePath: "/tmp/alerts.log",
|
||||
|
@ -89,7 +89,7 @@ func TestAlertServices(t *testing.T) {
|
|||
{
|
||||
name: "Test http as post",
|
||||
rule: chronograf.AlertRule{
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
Posts: []*chronograf.Post{
|
||||
{
|
||||
URL: "http://myaddress",
|
||||
|
@ -104,7 +104,7 @@ func TestAlertServices(t *testing.T) {
|
|||
{
|
||||
name: "Test post with headers",
|
||||
rule: chronograf.AlertRule{
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
Posts: []*chronograf.Post{
|
||||
{
|
||||
URL: "http://myaddress",
|
||||
|
@ -143,13 +143,13 @@ func TestAlertServices(t *testing.T) {
|
|||
func Test_addAlertNodes(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
handlers chronograf.AlertHandlers
|
||||
handlers chronograf.AlertNodes
|
||||
want string
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "foo",
|
||||
handlers: chronograf.AlertHandlers{
|
||||
handlers: chronograf.AlertNodes{
|
||||
IsStateChangesOnly: true,
|
||||
Email: []*chronograf.Email{
|
||||
{
|
||||
|
|
|
@ -495,7 +495,7 @@ func extractAlertNodes(p *pipeline.Pipeline, rule *chronograf.AlertRule) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return json.Unmarshal(octets, &rule.AlertHandlers)
|
||||
return json.Unmarshal(octets, &rule.AlertNodes)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
|
|
@ -69,7 +69,7 @@ func TestReverse(t *testing.T) {
|
|||
want: chronograf.AlertRule{
|
||||
Name: "name",
|
||||
Trigger: "threshold",
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
IsStateChangesOnly: true,
|
||||
Slack: []*chronograf.Slack{
|
||||
{},
|
||||
|
@ -241,7 +241,7 @@ func TestReverse(t *testing.T) {
|
|||
AreTagsAccepted: true,
|
||||
},
|
||||
Every: "30s",
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
IsStateChangesOnly: true,
|
||||
|
||||
Slack: []*chronograf.Slack{
|
||||
|
@ -349,7 +349,7 @@ func TestReverse(t *testing.T) {
|
|||
want: chronograf.AlertRule{
|
||||
Name: "haproxy",
|
||||
Trigger: "threshold",
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
IsStateChangesOnly: true,
|
||||
Email: []*chronograf.Email{
|
||||
{To: []string{}},
|
||||
|
@ -470,7 +470,7 @@ func TestReverse(t *testing.T) {
|
|||
want: chronograf.AlertRule{
|
||||
Name: "haproxy",
|
||||
Trigger: "threshold",
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
IsStateChangesOnly: true,
|
||||
Email: []*chronograf.Email{
|
||||
{To: []string{}},
|
||||
|
@ -593,7 +593,7 @@ func TestReverse(t *testing.T) {
|
|||
want: chronograf.AlertRule{
|
||||
Name: "name",
|
||||
Trigger: "threshold",
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
IsStateChangesOnly: true,
|
||||
Slack: []*chronograf.Slack{
|
||||
{},
|
||||
|
@ -730,7 +730,7 @@ func TestReverse(t *testing.T) {
|
|||
want: chronograf.AlertRule{
|
||||
Name: "name",
|
||||
Trigger: "threshold",
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
IsStateChangesOnly: true,
|
||||
Slack: []*chronograf.Slack{
|
||||
{},
|
||||
|
@ -867,7 +867,7 @@ func TestReverse(t *testing.T) {
|
|||
want: chronograf.AlertRule{
|
||||
Name: "name",
|
||||
Trigger: "threshold",
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
IsStateChangesOnly: true,
|
||||
Slack: []*chronograf.Slack{
|
||||
{},
|
||||
|
@ -994,7 +994,7 @@ func TestReverse(t *testing.T) {
|
|||
want: chronograf.AlertRule{
|
||||
Name: "name",
|
||||
Trigger: "threshold",
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
IsStateChangesOnly: true,
|
||||
Slack: []*chronograf.Slack{
|
||||
{},
|
||||
|
@ -1132,7 +1132,7 @@ trigger
|
|||
want: chronograf.AlertRule{
|
||||
Name: "name",
|
||||
Trigger: "relative",
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
IsStateChangesOnly: true,
|
||||
Slack: []*chronograf.Slack{
|
||||
{},
|
||||
|
@ -1280,7 +1280,7 @@ trigger
|
|||
want: chronograf.AlertRule{
|
||||
Name: "name",
|
||||
Trigger: "relative",
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
IsStateChangesOnly: true,
|
||||
Slack: []*chronograf.Slack{
|
||||
{},
|
||||
|
@ -1410,7 +1410,7 @@ trigger
|
|||
want: chronograf.AlertRule{
|
||||
Name: "name",
|
||||
Trigger: "deadman",
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
IsStateChangesOnly: true,
|
||||
Slack: []*chronograf.Slack{
|
||||
{},
|
||||
|
@ -1526,7 +1526,7 @@ trigger
|
|||
Every: "",
|
||||
Message: "",
|
||||
Details: "",
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
IsStateChangesOnly: true,
|
||||
},
|
||||
Query: &chronograf.QueryConfig{
|
||||
|
|
|
@ -316,7 +316,7 @@ trigger
|
|||
Operator: "greater than",
|
||||
Value: "90000",
|
||||
},
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
IsStateChangesOnly: true,
|
||||
},
|
||||
Query: &chronograf.QueryConfig{
|
||||
|
@ -641,7 +641,7 @@ trigger
|
|||
Operator: "greater than",
|
||||
Value: "90000",
|
||||
},
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
IsStateChangesOnly: true,
|
||||
},
|
||||
Query: &chronograf.QueryConfig{
|
||||
|
|
|
@ -13,7 +13,7 @@ func TestGenerate(t *testing.T) {
|
|||
alert := chronograf.AlertRule{
|
||||
Name: "name",
|
||||
Trigger: "relative",
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
Slack: []*chronograf.Slack{{}},
|
||||
VictorOps: []*chronograf.VictorOps{{}},
|
||||
Email: []*chronograf.Email{{}},
|
||||
|
@ -69,7 +69,7 @@ func TestThreshold(t *testing.T) {
|
|||
alert := chronograf.AlertRule{
|
||||
Name: "name",
|
||||
Trigger: "threshold",
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
Slack: []*chronograf.Slack{{}},
|
||||
VictorOps: []*chronograf.VictorOps{{}},
|
||||
Email: []*chronograf.Email{{}},
|
||||
|
@ -222,7 +222,7 @@ func TestThresholdStringCrit(t *testing.T) {
|
|||
alert := chronograf.AlertRule{
|
||||
Name: "haproxy",
|
||||
Trigger: "threshold",
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
Email: []*chronograf.Email{{}},
|
||||
},
|
||||
TriggerValues: chronograf.TriggerValues{
|
||||
|
@ -368,7 +368,7 @@ func TestThresholdStringCritGreater(t *testing.T) {
|
|||
alert := chronograf.AlertRule{
|
||||
Name: "haproxy",
|
||||
Trigger: "threshold",
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
Email: []*chronograf.Email{{}},
|
||||
},
|
||||
TriggerValues: chronograf.TriggerValues{
|
||||
|
@ -512,7 +512,7 @@ func TestThresholdDetail(t *testing.T) {
|
|||
alert := chronograf.AlertRule{
|
||||
Name: "name",
|
||||
Trigger: "threshold",
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
Slack: []*chronograf.Slack{{}},
|
||||
VictorOps: []*chronograf.VictorOps{{}},
|
||||
Email: []*chronograf.Email{{}},
|
||||
|
@ -669,7 +669,7 @@ func TestThresholdInsideRange(t *testing.T) {
|
|||
alert := chronograf.AlertRule{
|
||||
Name: "name",
|
||||
Trigger: "threshold",
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
Slack: []*chronograf.Slack{{}},
|
||||
VictorOps: []*chronograf.VictorOps{{}},
|
||||
Email: []*chronograf.Email{{}},
|
||||
|
@ -825,7 +825,7 @@ func TestThresholdOutsideRange(t *testing.T) {
|
|||
alert := chronograf.AlertRule{
|
||||
Name: "name",
|
||||
Trigger: "threshold",
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
Slack: []*chronograf.Slack{{}},
|
||||
VictorOps: []*chronograf.VictorOps{{}},
|
||||
Email: []*chronograf.Email{{}},
|
||||
|
@ -981,7 +981,7 @@ func TestThresholdNoAggregate(t *testing.T) {
|
|||
alert := chronograf.AlertRule{
|
||||
Name: "name",
|
||||
Trigger: "threshold",
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
Slack: []*chronograf.Slack{{}},
|
||||
VictorOps: []*chronograf.VictorOps{{}},
|
||||
Email: []*chronograf.Email{{}},
|
||||
|
@ -1120,7 +1120,7 @@ func TestRelative(t *testing.T) {
|
|||
alert := chronograf.AlertRule{
|
||||
Name: "name",
|
||||
Trigger: "relative",
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
Slack: []*chronograf.Slack{{}},
|
||||
VictorOps: []*chronograf.VictorOps{{}},
|
||||
Email: []*chronograf.Email{{}},
|
||||
|
@ -1287,7 +1287,7 @@ func TestRelativeChange(t *testing.T) {
|
|||
alert := chronograf.AlertRule{
|
||||
Name: "name",
|
||||
Trigger: "relative",
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
Slack: []*chronograf.Slack{{}},
|
||||
VictorOps: []*chronograf.VictorOps{{}},
|
||||
Email: []*chronograf.Email{{}},
|
||||
|
@ -1454,7 +1454,7 @@ func TestDeadman(t *testing.T) {
|
|||
alert := chronograf.AlertRule{
|
||||
Name: "name",
|
||||
Trigger: "deadman",
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
Slack: []*chronograf.Slack{{}},
|
||||
VictorOps: []*chronograf.VictorOps{{}},
|
||||
Email: []*chronograf.Email{{}},
|
||||
|
|
|
@ -358,111 +358,111 @@ func newAlertResponse(task *kapa.Task, srcID, kapaID int) *alertResponse {
|
|||
},
|
||||
}
|
||||
|
||||
if res.AlertHandlers.Alerta == nil {
|
||||
res.AlertHandlers.Alerta = []*chronograf.Alerta{}
|
||||
if res.AlertNodes.Alerta == nil {
|
||||
res.AlertNodes.Alerta = []*chronograf.Alerta{}
|
||||
}
|
||||
|
||||
for i, a := range res.AlertHandlers.Alerta {
|
||||
for i, a := range res.AlertNodes.Alerta {
|
||||
if a.Service == nil {
|
||||
a.Service = []string{}
|
||||
res.AlertHandlers.Alerta[i] = a
|
||||
res.AlertNodes.Alerta[i] = a
|
||||
}
|
||||
}
|
||||
|
||||
if res.AlertHandlers.Email == nil {
|
||||
res.AlertHandlers.Email = []*chronograf.Email{}
|
||||
if res.AlertNodes.Email == nil {
|
||||
res.AlertNodes.Email = []*chronograf.Email{}
|
||||
}
|
||||
|
||||
for i, a := range res.AlertHandlers.Email {
|
||||
for i, a := range res.AlertNodes.Email {
|
||||
if a.To == nil {
|
||||
a.To = []string{}
|
||||
res.AlertHandlers.Email[i] = a
|
||||
res.AlertNodes.Email[i] = a
|
||||
}
|
||||
}
|
||||
|
||||
if res.AlertHandlers.Exec == nil {
|
||||
res.AlertHandlers.Exec = []*chronograf.Exec{}
|
||||
if res.AlertNodes.Exec == nil {
|
||||
res.AlertNodes.Exec = []*chronograf.Exec{}
|
||||
}
|
||||
|
||||
for i, a := range res.AlertHandlers.Exec {
|
||||
for i, a := range res.AlertNodes.Exec {
|
||||
if a.Command == nil {
|
||||
a.Command = []string{}
|
||||
res.AlertHandlers.Exec[i] = a
|
||||
res.AlertNodes.Exec[i] = a
|
||||
}
|
||||
}
|
||||
|
||||
if res.AlertHandlers.HipChat == nil {
|
||||
res.AlertHandlers.HipChat = []*chronograf.HipChat{}
|
||||
if res.AlertNodes.HipChat == nil {
|
||||
res.AlertNodes.HipChat = []*chronograf.HipChat{}
|
||||
}
|
||||
|
||||
if res.AlertHandlers.Log == nil {
|
||||
res.AlertHandlers.Log = []*chronograf.Log{}
|
||||
if res.AlertNodes.Log == nil {
|
||||
res.AlertNodes.Log = []*chronograf.Log{}
|
||||
}
|
||||
|
||||
if res.AlertHandlers.OpsGenie == nil {
|
||||
res.AlertHandlers.OpsGenie = []*chronograf.OpsGenie{}
|
||||
if res.AlertNodes.OpsGenie == nil {
|
||||
res.AlertNodes.OpsGenie = []*chronograf.OpsGenie{}
|
||||
}
|
||||
|
||||
for i, a := range res.AlertHandlers.OpsGenie {
|
||||
for i, a := range res.AlertNodes.OpsGenie {
|
||||
if a.Teams == nil {
|
||||
a.Teams = []string{}
|
||||
res.AlertHandlers.OpsGenie[i] = a
|
||||
res.AlertNodes.OpsGenie[i] = a
|
||||
}
|
||||
|
||||
if a.Recipients == nil {
|
||||
a.Recipients = []string{}
|
||||
res.AlertHandlers.OpsGenie[i] = a
|
||||
res.AlertNodes.OpsGenie[i] = a
|
||||
}
|
||||
}
|
||||
|
||||
if res.AlertHandlers.PagerDuty == nil {
|
||||
res.AlertHandlers.PagerDuty = []*chronograf.PagerDuty{}
|
||||
if res.AlertNodes.PagerDuty == nil {
|
||||
res.AlertNodes.PagerDuty = []*chronograf.PagerDuty{}
|
||||
}
|
||||
|
||||
if res.AlertHandlers.Posts == nil {
|
||||
res.AlertHandlers.Posts = []*chronograf.Post{}
|
||||
if res.AlertNodes.Posts == nil {
|
||||
res.AlertNodes.Posts = []*chronograf.Post{}
|
||||
}
|
||||
|
||||
for i, a := range res.AlertHandlers.Posts {
|
||||
for i, a := range res.AlertNodes.Posts {
|
||||
if a.Headers == nil {
|
||||
a.Headers = map[string]string{}
|
||||
res.AlertHandlers.Posts[i] = a
|
||||
res.AlertNodes.Posts[i] = a
|
||||
}
|
||||
}
|
||||
|
||||
if res.AlertHandlers.Pushover == nil {
|
||||
res.AlertHandlers.Pushover = []*chronograf.Pushover{}
|
||||
if res.AlertNodes.Pushover == nil {
|
||||
res.AlertNodes.Pushover = []*chronograf.Pushover{}
|
||||
}
|
||||
|
||||
if res.AlertHandlers.Sensu == nil {
|
||||
res.AlertHandlers.Sensu = []*chronograf.Sensu{}
|
||||
if res.AlertNodes.Sensu == nil {
|
||||
res.AlertNodes.Sensu = []*chronograf.Sensu{}
|
||||
}
|
||||
|
||||
for i, a := range res.AlertHandlers.Sensu {
|
||||
for i, a := range res.AlertNodes.Sensu {
|
||||
if a.Handlers == nil {
|
||||
a.Handlers = []string{}
|
||||
res.AlertHandlers.Sensu[i] = a
|
||||
res.AlertNodes.Sensu[i] = a
|
||||
}
|
||||
}
|
||||
|
||||
if res.AlertHandlers.Slack == nil {
|
||||
res.AlertHandlers.Slack = []*chronograf.Slack{}
|
||||
if res.AlertNodes.Slack == nil {
|
||||
res.AlertNodes.Slack = []*chronograf.Slack{}
|
||||
}
|
||||
|
||||
if res.AlertHandlers.Talk == nil {
|
||||
res.AlertHandlers.Talk = []*chronograf.Talk{}
|
||||
if res.AlertNodes.Talk == nil {
|
||||
res.AlertNodes.Talk = []*chronograf.Talk{}
|
||||
}
|
||||
|
||||
if res.AlertHandlers.TCPs == nil {
|
||||
res.AlertHandlers.TCPs = []*chronograf.TCP{}
|
||||
if res.AlertNodes.TCPs == nil {
|
||||
res.AlertNodes.TCPs = []*chronograf.TCP{}
|
||||
}
|
||||
|
||||
if res.AlertHandlers.Telegram == nil {
|
||||
res.AlertHandlers.Telegram = []*chronograf.Telegram{}
|
||||
if res.AlertNodes.Telegram == nil {
|
||||
res.AlertNodes.Telegram = []*chronograf.Telegram{}
|
||||
}
|
||||
|
||||
if res.AlertHandlers.VictorOps == nil {
|
||||
res.AlertHandlers.VictorOps = []*chronograf.VictorOps{}
|
||||
if res.AlertNodes.VictorOps == nil {
|
||||
res.AlertNodes.VictorOps = []*chronograf.VictorOps{}
|
||||
}
|
||||
|
||||
if res.Query != nil {
|
||||
|
|
|
@ -114,7 +114,7 @@ func Test_KapacitorRulesGet(t *testing.T) {
|
|||
Type: "stream",
|
||||
DBRPs: []chronograf.DBRP{{DB: "telegraf", RP: "autogen"}},
|
||||
TICKScript: tickScript,
|
||||
AlertHandlers: chronograf.AlertHandlers{
|
||||
AlertNodes: chronograf.AlertNodes{
|
||||
Posts: []*chronograf.Post{},
|
||||
TCPs: []*chronograf.TCP{},
|
||||
Email: []*chronograf.Email{},
|
||||
|
|
Loading…
Reference in New Issue