Unable to get Kapacitor alert details property in Alerta

We are in the process of implementing TICK as a replacement for our current monitoring platform and still getting our feet wet, so bare with me :slight_smile:
We are going to leverage Alerta as our event console so we will send any Kapacitor alerts there for distribution and everything works fine with the integration unless I try to expose the details property to Alerta. We populate that property in the alert with an internal URL that has run book info in it for the on-call engineer to reference as part of our incident management process so would prefer to have this flow into Alerta, but when I configure it that way, I am getting the following in the kapacitor log

ts=2019-01-07T22:35:04.328Z lvl=error msg="failed to evaluate Alerta template" service=alerta handler=alerta topic=services err="template: value:1:3: executing \"value\" at <.Details>: can't evaluate field Details in type alert.TemplateData" value="{{ .Details }}"

The config for our topic handler for alerta looks like this:

topic: services id: alerta kind: alerta options: resource: '{{ .Name }}' event: '{{ .ID }}' environment: '{{ index .Tags "env"}}' group: '{{ .Group }}' origin: 'kapacitor' value: '{{ .Details }}' service: ['Pinger Service']

A typical alert looks like this

`var limit = 1
var escalations = 2

dbrp ā€œtelegrafā€.ā€œautogenā€

var data = stream
|from()
.measurement(ā€˜abuseā€™)
|window()
.period(30s)
.every(30s)
|mean(ā€˜hard_blockā€™)
.as(ā€˜blocksā€™)
|derivative(ā€˜blocksā€™)
.nonNegative()
.unit(1s)
.as(ā€˜blocked_rateā€™)
|stateCount(lambda: ā€œblocked_rateā€ > limit)
.as(ā€˜countā€™)
|log()

data
|alert()
.stateChangesOnly()
.id(ā€˜Too many hard blocked accountsā€™)
.message(ā€˜{{ .Level }} alert: {{ .ID }}: current value {{ index .Fields ā€œblocked_rateā€ | printf ā€œ%0.2fā€ }}ā€™)
.details(ā€˜ā€™ā€˜http://redactedDomainNameHere/display/Ops/Alerts#Alerts-Toomanyhardblockedaccountsā€™ā€˜ā€™)
.crit(lambda: ā€œcountā€ > escalations)
.topic(ā€˜servicesā€™)
`
If I change the topic handler to pass in something like {{ .ID }} or {{ .Message }} as the value option it works, so not sure what Iā€™m doing wrong or if Iā€™m just misunderstanding whether or not itā€™s possible to pass in the details property to Alerta.

We are running the following versions:
InfluxDB - 1.7.1 (OSS)
Kapacitor - 1.5.1

Any help would be greatly appreciated

Hey @Randy_Wolfgram

Iā€™m tryin to understand this issue a bit more. Iā€™m struggling to match up errors with tickscripts. Would it be possible for you to provided the tickscript and the associated error, for each of the things youā€™ve tried. With notes of exactly which things worked and which did not.

Hi @michael, thanks for taking a quick look at this. I can probably make this a bit more clear. The requirement Iā€™m trying to meet is to have the contents of the details property of the alert show up in Alerta.

I think this issue is more with the alerta handler. If I configure the handler like this:

topic: services
id: alerta
kind: alerta
options:
resource: ā€˜{{ .Name }}ā€™
event: ā€˜{{ .ID }}ā€™
environment: ā€˜{{ index .Tags ā€œenvā€}}ā€™
group: ā€˜{{ .Group }}ā€™
origin: ā€˜kapacitorā€™
value: '{{ .Details }}'
service: [ā€˜Pinger Serviceā€™]

I get the error the following error in the kapacitor logs and the alert doesnā€™t make it to Alerta:

ts=2019-01-07T22:35:04.328Z lvl=error msg=ā€œfailed to evaluate Alerta templateā€ service=alerta handler=alerta topic=services err=ā€œtemplate: value:1:3: executing ā€œvalueā€ at <.Details>: canā€™t evaluate field Details in type alert.TemplateDataā€ value="{{ .Details }}"

If I configure the handler something like this:

topic: services
id: alerta
kind: alerta
options:
resource: ā€˜{{ .Name }}ā€™
event: ā€˜{{ .ID }}ā€™
environment: ā€˜{{ index .Tags ā€œenvā€}}ā€™
group: ā€˜{{ .Group }}ā€™
origin: ā€˜kapacitorā€™
value: '{{ .Message }}'
service: [ā€˜Pinger Serviceā€™]

I donā€™t get error and the alert shows up in Alerta, but that doesnā€™t meet the requirement as the content that I need is in the details property. If itā€™s not possible to access the contents of the details property in the handler, then I just need to know that.

Thanks!