# Get conditions from different nodes to trigger alert

**URL:** https://community.influxdata.com/t/get-conditions-from-different-nodes-to-trigger-alert/2732
**Category:** Kapacitor
**Tags:** influxdb, kapacitor
**Created:** [October 12, 2017, 8:40pm UTC](https://community.influxdata.com/t/get-conditions-from-different-nodes-to-trigger-alert/2732 "2017-10-12T20:40:26Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![samygp](https://avatars.discourse-cdn.com/v4/letter/s/94ad74/32.png) [@samygp](https://community.influxdata.com/u/samygp)
#### Post date: [October 12, 2017, 8:40pm UTC](https://community.influxdata.com/t/get-conditions-from-different-nodes-to-trigger-alert/2732/1 "2017-10-12T20:40:26Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![absolutejam](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/absolutejam/32/1832_2.png) [@absolutejam](https://community.influxdata.com/u/absolutejam)
#### Post date: [October 14, 2017, 6:03pm UTC](https://community.influxdata.com/t/get-conditions-from-different-nodes-to-trigger-alert/2732/2 "2017-10-14T18:03:40Z")

</div>

I think alert needs a crit, warn or info parameter.

You can use `.crit(lambda: TRUE)` to trigger on all points.

---

<div class="post-metadata">

### Author: ![samygp](https://avatars.discourse-cdn.com/v4/letter/s/94ad74/32.png) [@samygp](https://community.influxdata.com/u/samygp)
#### Post date: [October 16, 2017, 5:11pm UTC](https://community.influxdata.com/t/get-conditions-from-different-nodes-to-trigger-alert/2732/3 "2017-10-16T17:11:53Z")

</div>

I tried that as well, but something seems to be wrong with the way I join both streams.

---

<div class="post-metadata">

### Author: ![arturo-mondelo](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/arturo-mondelo/32/1039_2.png) [@arturo-mondelo](https://community.influxdata.com/u/arturo-mondelo)
#### Post date: [February 24, 2018, 12:15pm UTC](https://community.influxdata.com/t/get-conditions-from-different-nodes-to-trigger-alert/2732/4 "2018-02-24T12:15:24Z")

</div>

Hi,

If you try to do the eval over each one separately, saving .as condition1 and condition2, and also the true check on the warn property twice (both true) is working?

Is just check if the whole sentence comparison is not well evaluated!

If neither works, debug with log() and ser whats going under…
