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

fix: .Details should be avaliable inside AlertTemplates #2395

Merged
merged 2 commits into from
Sep 3, 2020
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [#2351](https://github.com/influxdata/kapacitor/pull/2351): Upgraded github.com/gorhill/cronexpr, thanks @wuguanyu!
### Bugfixes
- [#2201](https://github.com/influxdata/kapacitor/pull/2201): Added missing err check of a buf scanner, thanks @johncming!
- [#2395](http://github.com/influxdata/kapacitor/pull/2395): Added missing .Details to AlertTemplate.

## v1.5.6 [2020-07-17]

Expand Down
4 changes: 4 additions & 0 deletions alert/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func (e Event) TemplateData() TemplateData {
Level: e.State.Level.String(),
Time: e.State.Time,
Duration: e.State.Duration,
Details: e.State.Details,
Name: e.Data.Name,
TaskName: e.Data.TaskName,
Group: e.Data.Group,
Expand Down Expand Up @@ -106,6 +107,9 @@ type TemplateData struct {
// Duration of the event
Duration time.Duration

// Details
Details string

// Measurement name
Name string

Expand Down
7 changes: 7 additions & 0 deletions integrations/streamer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10561,6 +10561,7 @@ stream
.info(lambda: "count" > 6.0)
.warn(lambda: "count" > 7.0)
.crit(lambda: "count" > 8.0)
.details('{{ "here" }}/{{ .Name }}')
.snmpTrap('1.1.1')
.data('1.1.1.2', 'c', '1')
.data('1.1.1.2', 's', 'SNMP ALERT')
Expand All @@ -10569,6 +10570,7 @@ stream
.data('1.1.2.3', 'i', '10')
.data('1.1.2.3', 'n', '')
.data('1.1.2.3', 't', '20000')
.data('1.1.2.3', 's', '{{ .Details }}')
`

expTraps := []interface{}{
Expand Down Expand Up @@ -10635,6 +10637,11 @@ stream
Value: "20000",
Type: "TimeTicks",
},
{
Oid: "1.1.2.3",
Value: "here/cpu",
Type: "OctetString",
},
},
},
},
Expand Down