Kapacitor batch task using Flux

I am using Kapacitor batchnode for flux query. I want to extract the min value of all values i get and basically raise alert based on some condition. Following is the tickscript i wrote:

var data = batch
              |queryFlux('''
                from(bucket: "bucket")
                |> range(start: -60m)
                |> filter(fn: (r) => r["_measurement"] == "measurement")
                |> filter(fn: (r) => r["_field"] == "_field" and r["_value"] > 0)
                |> keep(columns: ["tag1","_time","_value","_field"])
                |> last()
              ''')
               .every(1h)
               |min('_value')

var alert = data
    |alert()
        .crit(lambda: "_value" >= 0)
        .message('Testing alert')
        .log('/tmp/alerts.log')

However, i am not able to get any logs even after condition being satisfied. Can someone help me here.

Hello @Pratik_Das_Baghel,
What version of InfluxDB are you using?
Why use Kapacitor for this instead of a Flux task which is a batch task to begin with?
I’d recommend just using a task and not using kapacitor.

Actually i wanted to raise alerts, hence wanted to use kapacitor. It can be done be using flux right? By using Ses

Hello @Pratik_Das_Baghel,
Yes you can use Flux to raise alerts. Where do you want to send the alert to? Flux supports:

Hi @Anaisdg, so is there any other way to do that. Like in Grafana, alerting is managed by Grafana only, we only mention source and destination email address and similarly for Kapacitor using Batch task in influxql, i was able to send alerts. Actually, i would not want currently to use any 3rd party option. Can you help me here?

Thanks

Hello @Pratik_Das_Baghel,
Yes you can send alerts to email.