Split points and alert on each

Hello,
I am stuck with something that seems quite basic.
I have a join of two “batch” datasource with some processing.
At the end I have a bunch of point that enter in an alert node.
I would like to evaluate them separately and eventually emit an alert for each.
I did not find how to do that.
It could be something just before |alert to split the data into multiple flow like groupBy does…
Fabrice

@Fabrice Can you just run 2 seperate tasks? Also would you mind posting your .tick script?

Hello,

Sorry I am quite new and I do not see what will bring two separate task or how you see it.
You mean fill back my nodes on Influx then stream them one per one ?
I am also trying to convert it as a stream to see if there is a better solution in this mode.

I try to detect holes in data flow and alert them with hole length qualification. It looks like this :

var warn = 5
var crit = 30

var message_count = batch
       |query('''
            SELECT SUM("count") AS count FROM telegraf.autogen.message_count
        ''')
        .period(1d)
        .cron('0 0 2 * * * *')
        .groupBy(time(5m), *)
        .fill(0)

var data = message_count
    |stateDuration(lambda: "count" == 0)
             .unit(1m)
    |difference('state_duration')
    |where(lambda: "difference" < 0)
    |eval(lambda: -"difference"-1.0)
        .as('duration')

data
    |alert()
        .message('''{{.Level}} - {{.Time}}
Hole in data of  {{ index .Fields "duration" }} minutes''')
        .warn(lambda: "duration" > warn)
        .crit(lambda: "duration" > crit)
        .topic('issues')

If i log the data just before alert, I have a point per hole with the hole duration but can log only the first one whom is critical in my test case.

Thanks a lot for your support.

1 Like