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
|
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.
|
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
|
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
|
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.
|
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
|
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"
|
import "encoding/json"
|
||||||
|
|
||||||
// AlertHandlers defines all possible kapacitor interactions with an alert.
|
// AlertNodes defines all possible kapacitor interactions with an alert.
|
||||||
type AlertHandlers struct {
|
type AlertNodes struct {
|
||||||
IsStateChangesOnly bool `json:"stateChangesOnly"` // IsStateChangesOnly will only send alerts on state changes.
|
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
|
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.
|
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)
|
// Talk sends alerts to Jane Talk (https://jianliao.com/site)
|
||||||
type Talk struct{}
|
type Talk struct{}
|
||||||
|
|
||||||
// MarshalJSON converts AlertHandlers to JSON
|
// MarshalJSON converts AlertNodes to JSON
|
||||||
func (n *AlertHandlers) MarshalJSON() ([]byte, error) {
|
func (n *AlertNodes) MarshalJSON() ([]byte, error) {
|
||||||
type Alias AlertHandlers
|
type Alias AlertNodes
|
||||||
var raw = &struct {
|
var raw = &struct {
|
||||||
Type string `json:"typeOf"`
|
Type string `json:"typeOf"`
|
||||||
*Alias
|
*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
|
// AlertServices generates alert chaining methods to be attached to an alert from all rule Services
|
||||||
func AlertServices(rule chronograf.AlertRule) (string, error) {
|
func AlertServices(rule chronograf.AlertRule) (string, error) {
|
||||||
node, err := addAlertNodes(rule.AlertHandlers)
|
node, err := addAlertNodes(rule.AlertNodes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ func AlertServices(rule chronograf.AlertRule) (string, error) {
|
||||||
return node, nil
|
return node, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func addAlertNodes(handlers chronograf.AlertHandlers) (string, error) {
|
func addAlertNodes(handlers chronograf.AlertNodes) (string, error) {
|
||||||
octets, err := json.Marshal(&handlers)
|
octets, err := json.Marshal(&handlers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|
|
@ -17,7 +17,7 @@ func TestAlertServices(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "Test several valid services",
|
name: "Test several valid services",
|
||||||
rule: chronograf.AlertRule{
|
rule: chronograf.AlertRule{
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
Slack: []*chronograf.Slack{{}},
|
Slack: []*chronograf.Slack{{}},
|
||||||
VictorOps: []*chronograf.VictorOps{{}},
|
VictorOps: []*chronograf.VictorOps{{}},
|
||||||
Email: []*chronograf.Email{{}},
|
Email: []*chronograf.Email{{}},
|
||||||
|
@ -32,7 +32,7 @@ func TestAlertServices(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "Test single valid service",
|
name: "Test single valid service",
|
||||||
rule: chronograf.AlertRule{
|
rule: chronograf.AlertRule{
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
Slack: []*chronograf.Slack{{}},
|
Slack: []*chronograf.Slack{{}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -43,7 +43,7 @@ func TestAlertServices(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "Test single valid service and property",
|
name: "Test single valid service and property",
|
||||||
rule: chronograf.AlertRule{
|
rule: chronograf.AlertRule{
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
Slack: []*chronograf.Slack{
|
Slack: []*chronograf.Slack{
|
||||||
{
|
{
|
||||||
Channel: "#general",
|
Channel: "#general",
|
||||||
|
@ -59,7 +59,7 @@ func TestAlertServices(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "Test tcp",
|
name: "Test tcp",
|
||||||
rule: chronograf.AlertRule{
|
rule: chronograf.AlertRule{
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
TCPs: []*chronograf.TCP{
|
TCPs: []*chronograf.TCP{
|
||||||
{
|
{
|
||||||
Address: "myaddress:22",
|
Address: "myaddress:22",
|
||||||
|
@ -74,7 +74,7 @@ func TestAlertServices(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "Test log",
|
name: "Test log",
|
||||||
rule: chronograf.AlertRule{
|
rule: chronograf.AlertRule{
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
Log: []*chronograf.Log{
|
Log: []*chronograf.Log{
|
||||||
{
|
{
|
||||||
FilePath: "/tmp/alerts.log",
|
FilePath: "/tmp/alerts.log",
|
||||||
|
@ -89,7 +89,7 @@ func TestAlertServices(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "Test http as post",
|
name: "Test http as post",
|
||||||
rule: chronograf.AlertRule{
|
rule: chronograf.AlertRule{
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
Posts: []*chronograf.Post{
|
Posts: []*chronograf.Post{
|
||||||
{
|
{
|
||||||
URL: "http://myaddress",
|
URL: "http://myaddress",
|
||||||
|
@ -104,7 +104,7 @@ func TestAlertServices(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "Test post with headers",
|
name: "Test post with headers",
|
||||||
rule: chronograf.AlertRule{
|
rule: chronograf.AlertRule{
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
Posts: []*chronograf.Post{
|
Posts: []*chronograf.Post{
|
||||||
{
|
{
|
||||||
URL: "http://myaddress",
|
URL: "http://myaddress",
|
||||||
|
@ -143,13 +143,13 @@ func TestAlertServices(t *testing.T) {
|
||||||
func Test_addAlertNodes(t *testing.T) {
|
func Test_addAlertNodes(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
handlers chronograf.AlertHandlers
|
handlers chronograf.AlertNodes
|
||||||
want string
|
want string
|
||||||
wantErr bool
|
wantErr bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "foo",
|
name: "foo",
|
||||||
handlers: chronograf.AlertHandlers{
|
handlers: chronograf.AlertNodes{
|
||||||
IsStateChangesOnly: true,
|
IsStateChangesOnly: true,
|
||||||
Email: []*chronograf.Email{
|
Email: []*chronograf.Email{
|
||||||
{
|
{
|
||||||
|
|
|
@ -495,7 +495,7 @@ func extractAlertNodes(p *pipeline.Pipeline, rule *chronograf.AlertRule) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return json.Unmarshal(octets, &rule.AlertHandlers)
|
return json.Unmarshal(octets, &rule.AlertNodes)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
|
@ -69,7 +69,7 @@ func TestReverse(t *testing.T) {
|
||||||
want: chronograf.AlertRule{
|
want: chronograf.AlertRule{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
Trigger: "threshold",
|
Trigger: "threshold",
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
IsStateChangesOnly: true,
|
IsStateChangesOnly: true,
|
||||||
Slack: []*chronograf.Slack{
|
Slack: []*chronograf.Slack{
|
||||||
{},
|
{},
|
||||||
|
@ -241,7 +241,7 @@ func TestReverse(t *testing.T) {
|
||||||
AreTagsAccepted: true,
|
AreTagsAccepted: true,
|
||||||
},
|
},
|
||||||
Every: "30s",
|
Every: "30s",
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
IsStateChangesOnly: true,
|
IsStateChangesOnly: true,
|
||||||
|
|
||||||
Slack: []*chronograf.Slack{
|
Slack: []*chronograf.Slack{
|
||||||
|
@ -349,7 +349,7 @@ func TestReverse(t *testing.T) {
|
||||||
want: chronograf.AlertRule{
|
want: chronograf.AlertRule{
|
||||||
Name: "haproxy",
|
Name: "haproxy",
|
||||||
Trigger: "threshold",
|
Trigger: "threshold",
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
IsStateChangesOnly: true,
|
IsStateChangesOnly: true,
|
||||||
Email: []*chronograf.Email{
|
Email: []*chronograf.Email{
|
||||||
{To: []string{}},
|
{To: []string{}},
|
||||||
|
@ -470,7 +470,7 @@ func TestReverse(t *testing.T) {
|
||||||
want: chronograf.AlertRule{
|
want: chronograf.AlertRule{
|
||||||
Name: "haproxy",
|
Name: "haproxy",
|
||||||
Trigger: "threshold",
|
Trigger: "threshold",
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
IsStateChangesOnly: true,
|
IsStateChangesOnly: true,
|
||||||
Email: []*chronograf.Email{
|
Email: []*chronograf.Email{
|
||||||
{To: []string{}},
|
{To: []string{}},
|
||||||
|
@ -593,7 +593,7 @@ func TestReverse(t *testing.T) {
|
||||||
want: chronograf.AlertRule{
|
want: chronograf.AlertRule{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
Trigger: "threshold",
|
Trigger: "threshold",
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
IsStateChangesOnly: true,
|
IsStateChangesOnly: true,
|
||||||
Slack: []*chronograf.Slack{
|
Slack: []*chronograf.Slack{
|
||||||
{},
|
{},
|
||||||
|
@ -730,7 +730,7 @@ func TestReverse(t *testing.T) {
|
||||||
want: chronograf.AlertRule{
|
want: chronograf.AlertRule{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
Trigger: "threshold",
|
Trigger: "threshold",
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
IsStateChangesOnly: true,
|
IsStateChangesOnly: true,
|
||||||
Slack: []*chronograf.Slack{
|
Slack: []*chronograf.Slack{
|
||||||
{},
|
{},
|
||||||
|
@ -867,7 +867,7 @@ func TestReverse(t *testing.T) {
|
||||||
want: chronograf.AlertRule{
|
want: chronograf.AlertRule{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
Trigger: "threshold",
|
Trigger: "threshold",
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
IsStateChangesOnly: true,
|
IsStateChangesOnly: true,
|
||||||
Slack: []*chronograf.Slack{
|
Slack: []*chronograf.Slack{
|
||||||
{},
|
{},
|
||||||
|
@ -994,7 +994,7 @@ func TestReverse(t *testing.T) {
|
||||||
want: chronograf.AlertRule{
|
want: chronograf.AlertRule{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
Trigger: "threshold",
|
Trigger: "threshold",
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
IsStateChangesOnly: true,
|
IsStateChangesOnly: true,
|
||||||
Slack: []*chronograf.Slack{
|
Slack: []*chronograf.Slack{
|
||||||
{},
|
{},
|
||||||
|
@ -1132,7 +1132,7 @@ trigger
|
||||||
want: chronograf.AlertRule{
|
want: chronograf.AlertRule{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
Trigger: "relative",
|
Trigger: "relative",
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
IsStateChangesOnly: true,
|
IsStateChangesOnly: true,
|
||||||
Slack: []*chronograf.Slack{
|
Slack: []*chronograf.Slack{
|
||||||
{},
|
{},
|
||||||
|
@ -1280,7 +1280,7 @@ trigger
|
||||||
want: chronograf.AlertRule{
|
want: chronograf.AlertRule{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
Trigger: "relative",
|
Trigger: "relative",
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
IsStateChangesOnly: true,
|
IsStateChangesOnly: true,
|
||||||
Slack: []*chronograf.Slack{
|
Slack: []*chronograf.Slack{
|
||||||
{},
|
{},
|
||||||
|
@ -1410,7 +1410,7 @@ trigger
|
||||||
want: chronograf.AlertRule{
|
want: chronograf.AlertRule{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
Trigger: "deadman",
|
Trigger: "deadman",
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
IsStateChangesOnly: true,
|
IsStateChangesOnly: true,
|
||||||
Slack: []*chronograf.Slack{
|
Slack: []*chronograf.Slack{
|
||||||
{},
|
{},
|
||||||
|
@ -1526,7 +1526,7 @@ trigger
|
||||||
Every: "",
|
Every: "",
|
||||||
Message: "",
|
Message: "",
|
||||||
Details: "",
|
Details: "",
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
IsStateChangesOnly: true,
|
IsStateChangesOnly: true,
|
||||||
},
|
},
|
||||||
Query: &chronograf.QueryConfig{
|
Query: &chronograf.QueryConfig{
|
||||||
|
|
|
@ -316,7 +316,7 @@ trigger
|
||||||
Operator: "greater than",
|
Operator: "greater than",
|
||||||
Value: "90000",
|
Value: "90000",
|
||||||
},
|
},
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
IsStateChangesOnly: true,
|
IsStateChangesOnly: true,
|
||||||
},
|
},
|
||||||
Query: &chronograf.QueryConfig{
|
Query: &chronograf.QueryConfig{
|
||||||
|
@ -641,7 +641,7 @@ trigger
|
||||||
Operator: "greater than",
|
Operator: "greater than",
|
||||||
Value: "90000",
|
Value: "90000",
|
||||||
},
|
},
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
IsStateChangesOnly: true,
|
IsStateChangesOnly: true,
|
||||||
},
|
},
|
||||||
Query: &chronograf.QueryConfig{
|
Query: &chronograf.QueryConfig{
|
||||||
|
|
|
@ -13,7 +13,7 @@ func TestGenerate(t *testing.T) {
|
||||||
alert := chronograf.AlertRule{
|
alert := chronograf.AlertRule{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
Trigger: "relative",
|
Trigger: "relative",
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
Slack: []*chronograf.Slack{{}},
|
Slack: []*chronograf.Slack{{}},
|
||||||
VictorOps: []*chronograf.VictorOps{{}},
|
VictorOps: []*chronograf.VictorOps{{}},
|
||||||
Email: []*chronograf.Email{{}},
|
Email: []*chronograf.Email{{}},
|
||||||
|
@ -69,7 +69,7 @@ func TestThreshold(t *testing.T) {
|
||||||
alert := chronograf.AlertRule{
|
alert := chronograf.AlertRule{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
Trigger: "threshold",
|
Trigger: "threshold",
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
Slack: []*chronograf.Slack{{}},
|
Slack: []*chronograf.Slack{{}},
|
||||||
VictorOps: []*chronograf.VictorOps{{}},
|
VictorOps: []*chronograf.VictorOps{{}},
|
||||||
Email: []*chronograf.Email{{}},
|
Email: []*chronograf.Email{{}},
|
||||||
|
@ -222,7 +222,7 @@ func TestThresholdStringCrit(t *testing.T) {
|
||||||
alert := chronograf.AlertRule{
|
alert := chronograf.AlertRule{
|
||||||
Name: "haproxy",
|
Name: "haproxy",
|
||||||
Trigger: "threshold",
|
Trigger: "threshold",
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
Email: []*chronograf.Email{{}},
|
Email: []*chronograf.Email{{}},
|
||||||
},
|
},
|
||||||
TriggerValues: chronograf.TriggerValues{
|
TriggerValues: chronograf.TriggerValues{
|
||||||
|
@ -368,7 +368,7 @@ func TestThresholdStringCritGreater(t *testing.T) {
|
||||||
alert := chronograf.AlertRule{
|
alert := chronograf.AlertRule{
|
||||||
Name: "haproxy",
|
Name: "haproxy",
|
||||||
Trigger: "threshold",
|
Trigger: "threshold",
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
Email: []*chronograf.Email{{}},
|
Email: []*chronograf.Email{{}},
|
||||||
},
|
},
|
||||||
TriggerValues: chronograf.TriggerValues{
|
TriggerValues: chronograf.TriggerValues{
|
||||||
|
@ -512,7 +512,7 @@ func TestThresholdDetail(t *testing.T) {
|
||||||
alert := chronograf.AlertRule{
|
alert := chronograf.AlertRule{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
Trigger: "threshold",
|
Trigger: "threshold",
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
Slack: []*chronograf.Slack{{}},
|
Slack: []*chronograf.Slack{{}},
|
||||||
VictorOps: []*chronograf.VictorOps{{}},
|
VictorOps: []*chronograf.VictorOps{{}},
|
||||||
Email: []*chronograf.Email{{}},
|
Email: []*chronograf.Email{{}},
|
||||||
|
@ -669,7 +669,7 @@ func TestThresholdInsideRange(t *testing.T) {
|
||||||
alert := chronograf.AlertRule{
|
alert := chronograf.AlertRule{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
Trigger: "threshold",
|
Trigger: "threshold",
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
Slack: []*chronograf.Slack{{}},
|
Slack: []*chronograf.Slack{{}},
|
||||||
VictorOps: []*chronograf.VictorOps{{}},
|
VictorOps: []*chronograf.VictorOps{{}},
|
||||||
Email: []*chronograf.Email{{}},
|
Email: []*chronograf.Email{{}},
|
||||||
|
@ -825,7 +825,7 @@ func TestThresholdOutsideRange(t *testing.T) {
|
||||||
alert := chronograf.AlertRule{
|
alert := chronograf.AlertRule{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
Trigger: "threshold",
|
Trigger: "threshold",
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
Slack: []*chronograf.Slack{{}},
|
Slack: []*chronograf.Slack{{}},
|
||||||
VictorOps: []*chronograf.VictorOps{{}},
|
VictorOps: []*chronograf.VictorOps{{}},
|
||||||
Email: []*chronograf.Email{{}},
|
Email: []*chronograf.Email{{}},
|
||||||
|
@ -981,7 +981,7 @@ func TestThresholdNoAggregate(t *testing.T) {
|
||||||
alert := chronograf.AlertRule{
|
alert := chronograf.AlertRule{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
Trigger: "threshold",
|
Trigger: "threshold",
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
Slack: []*chronograf.Slack{{}},
|
Slack: []*chronograf.Slack{{}},
|
||||||
VictorOps: []*chronograf.VictorOps{{}},
|
VictorOps: []*chronograf.VictorOps{{}},
|
||||||
Email: []*chronograf.Email{{}},
|
Email: []*chronograf.Email{{}},
|
||||||
|
@ -1120,7 +1120,7 @@ func TestRelative(t *testing.T) {
|
||||||
alert := chronograf.AlertRule{
|
alert := chronograf.AlertRule{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
Trigger: "relative",
|
Trigger: "relative",
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
Slack: []*chronograf.Slack{{}},
|
Slack: []*chronograf.Slack{{}},
|
||||||
VictorOps: []*chronograf.VictorOps{{}},
|
VictorOps: []*chronograf.VictorOps{{}},
|
||||||
Email: []*chronograf.Email{{}},
|
Email: []*chronograf.Email{{}},
|
||||||
|
@ -1287,7 +1287,7 @@ func TestRelativeChange(t *testing.T) {
|
||||||
alert := chronograf.AlertRule{
|
alert := chronograf.AlertRule{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
Trigger: "relative",
|
Trigger: "relative",
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
Slack: []*chronograf.Slack{{}},
|
Slack: []*chronograf.Slack{{}},
|
||||||
VictorOps: []*chronograf.VictorOps{{}},
|
VictorOps: []*chronograf.VictorOps{{}},
|
||||||
Email: []*chronograf.Email{{}},
|
Email: []*chronograf.Email{{}},
|
||||||
|
@ -1454,7 +1454,7 @@ func TestDeadman(t *testing.T) {
|
||||||
alert := chronograf.AlertRule{
|
alert := chronograf.AlertRule{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
Trigger: "deadman",
|
Trigger: "deadman",
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
Slack: []*chronograf.Slack{{}},
|
Slack: []*chronograf.Slack{{}},
|
||||||
VictorOps: []*chronograf.VictorOps{{}},
|
VictorOps: []*chronograf.VictorOps{{}},
|
||||||
Email: []*chronograf.Email{{}},
|
Email: []*chronograf.Email{{}},
|
||||||
|
|
|
@ -358,111 +358,111 @@ func newAlertResponse(task *kapa.Task, srcID, kapaID int) *alertResponse {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.AlertHandlers.Alerta == nil {
|
if res.AlertNodes.Alerta == nil {
|
||||||
res.AlertHandlers.Alerta = []*chronograf.Alerta{}
|
res.AlertNodes.Alerta = []*chronograf.Alerta{}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, a := range res.AlertHandlers.Alerta {
|
for i, a := range res.AlertNodes.Alerta {
|
||||||
if a.Service == nil {
|
if a.Service == nil {
|
||||||
a.Service = []string{}
|
a.Service = []string{}
|
||||||
res.AlertHandlers.Alerta[i] = a
|
res.AlertNodes.Alerta[i] = a
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.AlertHandlers.Email == nil {
|
if res.AlertNodes.Email == nil {
|
||||||
res.AlertHandlers.Email = []*chronograf.Email{}
|
res.AlertNodes.Email = []*chronograf.Email{}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, a := range res.AlertHandlers.Email {
|
for i, a := range res.AlertNodes.Email {
|
||||||
if a.To == nil {
|
if a.To == nil {
|
||||||
a.To = []string{}
|
a.To = []string{}
|
||||||
res.AlertHandlers.Email[i] = a
|
res.AlertNodes.Email[i] = a
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.AlertHandlers.Exec == nil {
|
if res.AlertNodes.Exec == nil {
|
||||||
res.AlertHandlers.Exec = []*chronograf.Exec{}
|
res.AlertNodes.Exec = []*chronograf.Exec{}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, a := range res.AlertHandlers.Exec {
|
for i, a := range res.AlertNodes.Exec {
|
||||||
if a.Command == nil {
|
if a.Command == nil {
|
||||||
a.Command = []string{}
|
a.Command = []string{}
|
||||||
res.AlertHandlers.Exec[i] = a
|
res.AlertNodes.Exec[i] = a
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.AlertHandlers.HipChat == nil {
|
if res.AlertNodes.HipChat == nil {
|
||||||
res.AlertHandlers.HipChat = []*chronograf.HipChat{}
|
res.AlertNodes.HipChat = []*chronograf.HipChat{}
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.AlertHandlers.Log == nil {
|
if res.AlertNodes.Log == nil {
|
||||||
res.AlertHandlers.Log = []*chronograf.Log{}
|
res.AlertNodes.Log = []*chronograf.Log{}
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.AlertHandlers.OpsGenie == nil {
|
if res.AlertNodes.OpsGenie == nil {
|
||||||
res.AlertHandlers.OpsGenie = []*chronograf.OpsGenie{}
|
res.AlertNodes.OpsGenie = []*chronograf.OpsGenie{}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, a := range res.AlertHandlers.OpsGenie {
|
for i, a := range res.AlertNodes.OpsGenie {
|
||||||
if a.Teams == nil {
|
if a.Teams == nil {
|
||||||
a.Teams = []string{}
|
a.Teams = []string{}
|
||||||
res.AlertHandlers.OpsGenie[i] = a
|
res.AlertNodes.OpsGenie[i] = a
|
||||||
}
|
}
|
||||||
|
|
||||||
if a.Recipients == nil {
|
if a.Recipients == nil {
|
||||||
a.Recipients = []string{}
|
a.Recipients = []string{}
|
||||||
res.AlertHandlers.OpsGenie[i] = a
|
res.AlertNodes.OpsGenie[i] = a
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.AlertHandlers.PagerDuty == nil {
|
if res.AlertNodes.PagerDuty == nil {
|
||||||
res.AlertHandlers.PagerDuty = []*chronograf.PagerDuty{}
|
res.AlertNodes.PagerDuty = []*chronograf.PagerDuty{}
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.AlertHandlers.Posts == nil {
|
if res.AlertNodes.Posts == nil {
|
||||||
res.AlertHandlers.Posts = []*chronograf.Post{}
|
res.AlertNodes.Posts = []*chronograf.Post{}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, a := range res.AlertHandlers.Posts {
|
for i, a := range res.AlertNodes.Posts {
|
||||||
if a.Headers == nil {
|
if a.Headers == nil {
|
||||||
a.Headers = map[string]string{}
|
a.Headers = map[string]string{}
|
||||||
res.AlertHandlers.Posts[i] = a
|
res.AlertNodes.Posts[i] = a
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.AlertHandlers.Pushover == nil {
|
if res.AlertNodes.Pushover == nil {
|
||||||
res.AlertHandlers.Pushover = []*chronograf.Pushover{}
|
res.AlertNodes.Pushover = []*chronograf.Pushover{}
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.AlertHandlers.Sensu == nil {
|
if res.AlertNodes.Sensu == nil {
|
||||||
res.AlertHandlers.Sensu = []*chronograf.Sensu{}
|
res.AlertNodes.Sensu = []*chronograf.Sensu{}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, a := range res.AlertHandlers.Sensu {
|
for i, a := range res.AlertNodes.Sensu {
|
||||||
if a.Handlers == nil {
|
if a.Handlers == nil {
|
||||||
a.Handlers = []string{}
|
a.Handlers = []string{}
|
||||||
res.AlertHandlers.Sensu[i] = a
|
res.AlertNodes.Sensu[i] = a
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.AlertHandlers.Slack == nil {
|
if res.AlertNodes.Slack == nil {
|
||||||
res.AlertHandlers.Slack = []*chronograf.Slack{}
|
res.AlertNodes.Slack = []*chronograf.Slack{}
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.AlertHandlers.Talk == nil {
|
if res.AlertNodes.Talk == nil {
|
||||||
res.AlertHandlers.Talk = []*chronograf.Talk{}
|
res.AlertNodes.Talk = []*chronograf.Talk{}
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.AlertHandlers.TCPs == nil {
|
if res.AlertNodes.TCPs == nil {
|
||||||
res.AlertHandlers.TCPs = []*chronograf.TCP{}
|
res.AlertNodes.TCPs = []*chronograf.TCP{}
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.AlertHandlers.Telegram == nil {
|
if res.AlertNodes.Telegram == nil {
|
||||||
res.AlertHandlers.Telegram = []*chronograf.Telegram{}
|
res.AlertNodes.Telegram = []*chronograf.Telegram{}
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.AlertHandlers.VictorOps == nil {
|
if res.AlertNodes.VictorOps == nil {
|
||||||
res.AlertHandlers.VictorOps = []*chronograf.VictorOps{}
|
res.AlertNodes.VictorOps = []*chronograf.VictorOps{}
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Query != nil {
|
if res.Query != nil {
|
||||||
|
|
|
@ -114,7 +114,7 @@ func Test_KapacitorRulesGet(t *testing.T) {
|
||||||
Type: "stream",
|
Type: "stream",
|
||||||
DBRPs: []chronograf.DBRP{{DB: "telegraf", RP: "autogen"}},
|
DBRPs: []chronograf.DBRP{{DB: "telegraf", RP: "autogen"}},
|
||||||
TICKScript: tickScript,
|
TICKScript: tickScript,
|
||||||
AlertHandlers: chronograf.AlertHandlers{
|
AlertNodes: chronograf.AlertNodes{
|
||||||
Posts: []*chronograf.Post{},
|
Posts: []*chronograf.Post{},
|
||||||
TCPs: []*chronograf.TCP{},
|
TCPs: []*chronograf.TCP{},
|
||||||
Email: []*chronograf.Email{},
|
Email: []*chronograf.Email{},
|
||||||
|
|
Loading…
Reference in New Issue