k***@gmail.com
2018-01-05 18:15:32 UTC
I created a simple alert rule using chronograf UI to alert on disk used percent. The chronograf UI didnt ask me to enter duration anywhere but in the tick script created it refers to duration. I can probably overwrite duration with some value in seconds by editing tick script but may be there is an easier way to set duration while creating alert. Can any one help?
My Alert Rule Tick Script created by chronograf.
=================================================
var db = 'telegraf'
var rp = 'autogen'
var measurement = 'disk'
var groupBy = ['AppId', 'InstanceId', 'StackName', 'VPC', 'fstype', 'host', 'path']
var whereFilter = lambda: TRUE
var name = 'SampleDiskAlert'
var idVar = name + ':{{.Group}}'
var message = 'Disk Used Percent Above Threshold - {{.Tags}} {{.Time}}'
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 = 6
var data = stream
|from()
.database(db)
.retentionPolicy(rp)
.measurement(measurement)
.groupBy(groupBy)
.where(whereFilter)
|eval(lambda: "used_percent")
.as('value')
var trigger = data
|alert()
.crit(lambda: "value" > crit)
.stateChangesOnly()
.message(message)
.id(idVar)
.idTag(idTag)
.levelTag(levelTag)
.messageField(messageField)
.durationField(durationField)
.exec('/etc/kapacitor/scripts/pub2sns.py')
trigger
|influxDBOut()
.create()
.database(outputDB)
.retentionPolicy(outputRP)
.measurement(outputMeasurement)
.tag('alertName', name)
.tag('triggerType', triggerType)
trigger
|httpOut('output')
My Alert Rule Tick Script created by chronograf.
=================================================
var db = 'telegraf'
var rp = 'autogen'
var measurement = 'disk'
var groupBy = ['AppId', 'InstanceId', 'StackName', 'VPC', 'fstype', 'host', 'path']
var whereFilter = lambda: TRUE
var name = 'SampleDiskAlert'
var idVar = name + ':{{.Group}}'
var message = 'Disk Used Percent Above Threshold - {{.Tags}} {{.Time}}'
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 = 6
var data = stream
|from()
.database(db)
.retentionPolicy(rp)
.measurement(measurement)
.groupBy(groupBy)
.where(whereFilter)
|eval(lambda: "used_percent")
.as('value')
var trigger = data
|alert()
.crit(lambda: "value" > crit)
.stateChangesOnly()
.message(message)
.id(idVar)
.idTag(idTag)
.levelTag(levelTag)
.messageField(messageField)
.durationField(durationField)
.exec('/etc/kapacitor/scripts/pub2sns.py')
trigger
|influxDBOut()
.create()
.database(outputDB)
.retentionPolicy(outputRP)
.measurement(outputMeasurement)
.tag('alertName', name)
.tag('triggerType', triggerType)
trigger
|httpOut('output')
--
Remember to include the version number!
---
You received this message because you are subscribed to the Google Groups "InfluxData" group.
To unsubscribe from this group and stop receiving emails from it, send an email to influxdb+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/influxdb.
To view this discussion on the web visit https://groups.google.com/d/msgid/influxdb/8f47a593-63cd-49e8-b76c-6700300b5724%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Remember to include the version number!
---
You received this message because you are subscribed to the Google Groups "InfluxData" group.
To unsubscribe from this group and stop receiving emails from it, send an email to influxdb+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/influxdb.
To view this discussion on the web visit https://groups.google.com/d/msgid/influxdb/8f47a593-63cd-49e8-b76c-6700300b5724%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.