Skip to content

Commit

Permalink
fix: .Details should be avaliable inside AlertTemplates
Browse files Browse the repository at this point in the history
  • Loading branch information
docmerlin committed Sep 2, 2020
1 parent dadbf87 commit f372f70
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
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

0 comments on commit f372f70

Please sign in to comment.