Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Recoverable field to alert JSON response #1828

Merged
merged 5 commits into from
Mar 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Features

- [#1828](https://github.com/influxdata/kapacitor/pull/1828): Add recoverable field to JSON alert response to indicate whether the
alert will auto-recover.
- [#1823](https://github.com/influxdata/kapacitor/pull/1823): Update OpsGenie integration to use the v2 API.
To upgrade to using the new API simply update your config and TICKscripts to use opsgenie2 instead of opsgenie.
If your `opsgenie` config uses the `recovery_url` option, for `opsgenie2` you will need to change it to the `recovery_action` option.
Expand Down
13 changes: 7 additions & 6 deletions alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,12 +725,13 @@ func (n *AlertNode) event(
Level: level,
},
Data: alert.EventData{
Name: name,
TaskName: n.et.Task.ID,
Group: string(group),
Tags: tags,
Fields: fields,
Result: result,
Name: name,
TaskName: n.et.Task.ID,
Group: string(group),
Tags: tags,
Fields: fields,
Result: result,
Recoverable: !n.a.NoRecoveriesFlag,
},
}
return event, nil
Expand Down
4 changes: 4 additions & 0 deletions alert/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func (e Event) AlertData() Data {
Level: e.State.Level,
Data: e.Data.Result,
PreviousLevel: e.previousState.Level,
Recoverable: e.Data.Recoverable,
}
}

Expand Down Expand Up @@ -80,6 +81,8 @@ type EventData struct {
// Fields of alerting data point.
Fields map[string]interface{}

Recoverable bool

Result models.Result
}

Expand Down Expand Up @@ -179,4 +182,5 @@ type Data struct {
Level Level `json:"level"`
Data models.Result `json:"data"`
PreviousLevel Level `json:"previousLevel"`
Recoverable bool `json:"recoverable"`
}
5 changes: 5 additions & 0 deletions integrations/batcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,7 @@ func TestBatch_AlertStateChangesOnly(t *testing.T) {
Time: time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC),
Level: alert.Critical,
PreviousLevel: alert.OK,
Recoverable: true,
}
ad.Data = models.Result{}
if eq, msg := compareAlertData(expAd, ad); !eq {
Expand All @@ -1467,6 +1468,7 @@ func TestBatch_AlertStateChangesOnly(t *testing.T) {
Duration: 38 * time.Second,
Level: alert.OK,
PreviousLevel: alert.Critical,
Recoverable: true,
}
ad.Data = models.Result{}
if eq, msg := compareAlertData(expAd, ad); !eq {
Expand Down Expand Up @@ -1527,6 +1529,7 @@ func TestBatch_AlertStateChangesOnlyExpired(t *testing.T) {
Duration: time.Duration(rc-1) * 20 * time.Second,
Level: alert.Critical,
PreviousLevel: alert.OK,
Recoverable: true,
}
case 2:
expAd = alert.Data{
Expand All @@ -1536,6 +1539,7 @@ func TestBatch_AlertStateChangesOnlyExpired(t *testing.T) {
Duration: time.Duration(rc-1) * 20 * time.Second,
Level: alert.Critical,
PreviousLevel: alert.Critical,
Recoverable: true,
}
case 3:
expAd = alert.Data{
Expand All @@ -1545,6 +1549,7 @@ func TestBatch_AlertStateChangesOnlyExpired(t *testing.T) {
Duration: 38 * time.Second,
Level: alert.OK,
PreviousLevel: alert.Critical,
Recoverable: true,
}
}
if eq, msg := compareAlertData(expAd, ad); !eq {
Expand Down
Loading