Hi all,
here’s the case I’m trying to implement:
I have two different measurements, and when the value in both measurements remains above a given threshold, for more than 20 seconds, send an alert.
So, for example, if measurement_1 is above 0.1 and measurement_2 above 1.0, both for 20 seconds, or more, send an alert. So I came up with this:
var cpu_stuff = stream
|from()
.database('telegraf')
.retentionPolicy('autogen')
.measurement('cpu')
.groupBy(*)
|stateDuration(lambda: "usage_user" >= 0.1)
.as('cpu_dur')
var other_stuff = stream
|from()
.database('telegraf')
.retentionPolicy('autogen')
.measurement('influxdb_database')
|where(lambda: "database" == 'telegraf')
|stateDuration(lambda: "numSeries" >= 1.0)
.as('numSeries_dur')
var third_one = cpu_stuff
|join(other_stuff)
.as('cpu_q', 'other_q')
.tolerance(20s)
.streamName('multi_stuff')
|eval(lambda: "cpu_q.cpu_dur" > 20 AND "other_q.numSeries_dur" > 20)
.as('both_conditions')
|alert()
.message('cpu_q:{{ index .Fields "cpu_q.cpu_dur" }} other_q:{{ index .Fields "other_q.numSeries_dur" }}')
.warn(lambda: "both_conditions" == TRUE)
.slack()
But nothing is being sent, does anybody know what I’m doing wrong here?