influxdata / influxdata/kapacitor

{{.Tags}} is empty when querying InfluxDB populated by Collectd

Open
#1,502 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.4k
Forks
479
Avg merge
4d 16h
Merged PRs (30d)
4

Description

I'm using a setup where Collectd is pushing metrics into InfluxDB with alerts via Kapacitor and Chronograf on top. Influxdb is version 1.2 and Kapacitor and Chronograf is version 1.3. I can successfully create alerts via TICK files or via Chronograf and they get triggered appropriately, however when I try to format my message I don't seem to be able to get access to the relevant tag_keys and tag_values via the {{.Tags}} map. I use the following message in Chronograf

` {{ index .Tags "host" }}:{{ .Name }}:{{ index .Tags "type_instance" }} is {{.Level}} value: {{ index .Fields "value" }} @ {{.Time}} {{.Tags}}`

and receive the following message on Slack as a result:

`:cpu_value: is CRITICAL value: 47.12757803790413 @ 2017-07-28 13:21:00 +0000 UTC map[]`

The map of tags appears empty.

This is the TICK script that gets generated by Chronograf:

`var db = 'metrics'

var rp = 'default'

var measurement = 'cpu_value'

var groupBy = []

var whereFilter = lambda: ("host" == 'salt-master') AND ("type_instance" == 'idle')

var period = 10s

var every = 30s

var name = 'Salt Master CPU'

var idVar = name + ':{{.Group}}'

var message = ' {{ index .Tags "host" }}:{{ .Name }}:{{ index .Tags "type_instance" }} is {{.Level}} value: {{ index .Fields "value" }} @ {{.Time}} {{.Tags}}'

var idTag = 'alertID'

var levelTag = 'level'

var messageField = 'message'

var durationField = 'duration'

var outputDB = 'chronograf'

var outputRP = 'autogen'

var outputMeasurement = 'alerts'

var triggerType = 'threshold'

var crit = 70

var data = stream
|from()
.database(db)
.retentionPolicy(rp)
.measurement(measurement)
.groupBy(groupBy)
.where(whereFilter)
|window()
.period(period)
.every(every)
.align()
|mean('value')
.as('value')

var trigger = data
|alert()
.crit(lambda: "value" < crit)
.stateChangesOnly()
.message(message)
.id(idVar)
.idTag(idTag)
.levelTag(levelTag)
.messageField(messageField)
.durationField(durationField)
.slack()
.channel('#embassyalerts')

trigger
|influxDBOut()
.create()
.database(outputDB)
.retentionPolicy(outputRP)
.measurement(outputMeasurement)
.tag('alertName', name)
.tag('triggerType', triggerType)

trigger
|httpOut('output')`

Contributor guide

Open the contributing guide

Research direction

Reproduce the alert using the supplied Collectd/InfluxDB setup and generated TICK script, starting with the alert() message template and the stream's groupBy, whereFilter, window, and mean stages. Trace where the tags disappear; done means explaining the empty .Tags map and identifying the required behavior for this alert path.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
observability
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.