Kapacitor v. 1.5
Theres a long day and alot of code that has brought me to this point. I am trying to get alerts for a large series of metrics and have created a test tickscript to discover how this may be accomplished.
Goal: if a metric has a value of 0 for 5 minutes, send an alert for that metric. Edit: Also, if no points are sent for those 5 minutes send the same deadman alert. The following tickscript code provides this without the time, instead immediately reporting a value of 0 when it occurs.
Note: I have tried using deadman(threshold, time) method. This fails every time because for some reason it doesnât report for a 0 value, it only reports when the metric no longer updates to influxDB.
I have also tried creating my own deadman with several combinations of stats() and derivative() with and without each other.
I have tried using chronograf generated deadman and threshold. Threshold doesnât provide time, deadman doesnât actually work for a attrValue of 0 which is being submitted as a field as a double and I have tried casting it as such into a deadman node to be safe.
My question, what needs to be added to the script below to discover the value being 0 for 5 minutes and trigger alert only then?
var db = âstreamDBâ
var rp = âretentionâ
var measurement = âmeasurementâ
var groupBy = [âhostâ, âtopicâ]
var whereFilter = lambda: (âtopicâ == âtest_testâ)
var name = âstestâ
var idVar = name + â-{{.Group}}â
var message = '{{.ID}} {{.Level}} @ {{.Time}} for {{.Tags}} {{.Fields}} â
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 = 0
var data = stream
|from()
.database(db)
.retentionPolicy(rp)
.measurement(measurement)
.groupBy(groupBy)
.where(whereFilter)
|eval(lambda: âattrValueâ)
.as(âvalueâ)var trigger = data
|alert()
.crit(lambda: âvalueâ <= crit)
.message(message)
.id(idVar)
.idTag(idTag)
.levelTag(levelTag)
.messageField(messageField)
.durationField(durationField)
.stateChangesOnly()
.slack()
.channel(â#channelâ)trigger
|eval(lambda: float(âvalueâ))
.as(âvalueâ)
.keep()
|influxDBOut()
.create()
.database(outputDB)
.retentionPolicy(outputRP)
.measurement(outputMeasurement)
.tag(âalertNameâ, name)
.tag(âtriggerTypeâ, triggerType)trigger
|httpOut(âoutputâ)
Showing the task:
DOT:
digraph chronograf-v1-0adab7bf-a05f-483b-8936-9115c5e4ca61 {
stream0 â from1;
from1 â eval2;
eval2 â http_out3;
http_out3 â derivative4;
derivative4 â http_out5;
http_out5 â alert6;
alert6 â eval7;
alert6 â http_out9;
eval7 â influxdb_out8;