How to get a Tag into influxDBOut()

Still trying to get my head round Kapacitor syntax…

I have created a template TICK script. A snippet of it is below. My GroupBy clause is on a Tag called DeviceId i.e. [‘DeviceId’]
I want to push the DeviceId into another Measurement using InfluxDBOut. It works but I can’t get the DeviceId when defining the Tag on the InfluxDBOut node. In this part of the script…

.tag(‘DeviceId’, ‘NeedTheDeviceIdHere’)

TICK script:
var data = stream
|from()
.database(db).retentionPolicy(rp).measurement(measurement)
.groupBy(groupBy)
.where(whereFilter)

var trigger = data
|alert()
.crit(lambda: “Value” == ‘true’).stateChangesOnly().message(message)
.id(idVar).idTag(idTag).levelTag(levelTag).messageField(messageField).durationField(durationField)
.slack().channel(‘alerts-UIEvents’)

trigger
|influxDBOut()
.create().database(outputDB).retentionPolicy(outputRP).measurement(outputMeasurement)
.tag(‘DeviceId’, ‘NeedTheDeviceIdHere’).tag(‘Severity’, ‘Information’)

1 Like

Ah, the Measurement’s Tags and Fields are already present so no need to add them explicitly.

Looks like you figured it out. Yes, the .tag() method is for adding static tags for example you could add a tag that the data came from Kapacitor if you wished. Tags already on the data will be preserved.