I'm not aware of a way to check for null values in a lambda, however you
can default
<https://docs.influxdata.com/kapacitor/v1.0//nodes/default_node/#main-nav>
the field to a nonsense value (-1, for example) to get the same effect. For
example, changing your script to:

```
var data = stream
|from()
.database('telegraf')
.retentionPolicy('telegraf_01')
.measurement('mysql')
.groupBy('host')
|window()
.period(10s)
.every(10s)
|default()
.field('slave_Slave_SQL_Running', -1)
```

Where 'slave_Slave_SQL_Running' is defaulted to the -1 integer value if it
is not present in the stream. Once defaulted, a -1 value essentially means
it was null, allowing you to check for any value that is != 1 or < 1 to
signal failure.

I hope that helps!

Thanks,
Ross

On Mon, Sep 19, 2016 at 9:35 PM, 'so...@aliyun.com' via InfluxDB <
influxdb@googlegroups.com> wrote:

> I want to monitor the slave status of the MySQL ,when the state is normal,
> the value is 1, but not in normal state for null, I want to know the value
> of null, how can I judge through the script:
> [image: image]
> <https://cloud.githubusercontent.com/assets/18021407/18620368/cf4a394e-7e43-11e6-843b-fd362372825b.png>
>
> The following is my script:
>
> var crit_threshold = 1
> var data = stream
> |from()
> .database('telegraf')
> .retentionPolicy('telegraf_01')
> .measurement('mysql')
> .groupBy('host')
> |window()
> .period(10s)
> .every(10s)
> data
> |alert()
> .id('{{ index .Tags "host"}} | {{ index .Tags "slave_Slave_SQL_Running"}}')
> .message('{{ .ID }} is {{ .Level }} value:{{ index .Fields
> "slave_Slave_SQL_Running" }}')
> .crit(lambda: "slave_Slave_SQL_Running" != 1)
> .stateChangesOnly()
> .log('/tmp/alert.log')
>
> Please help me.
>
> telegraf+kapacitor+infuxDB
>
> ------------------------------
> so...@aliyun.com
>
> --
> Remember to include the InfluxDB version number with all issue reports
> ---
> You received this message because you are subscribed to the Google Groups
> "InfluxDB" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to influxdb+unsubscr...@googlegroups.com.
> To post to this group, send email to influxdb@googlegroups.com.
> Visit this group at https://groups.google.com/group/influxdb.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/influxdb/201609201035106520980%40aliyun.com
> <https://groups.google.com/d/msgid/influxdb/201609201035106520980%40aliyun.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Remember to include the InfluxDB version number with all issue reports
--- 
You received this message because you are subscribed to the Google Groups 
"InfluxDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to influxdb+unsubscr...@googlegroups.com.
To post to this group, send email to influxdb@googlegroups.com.
Visit this group at https://groups.google.com/group/influxdb.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/influxdb/CAD8sRLDndojEAdbMvMttYWQRyo38oc2wZJs6UA3ggcXcDJmfrA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
  • [influxdb] bug 'so...@aliyun.com' via InfluxDB
    • Re: [influxdb] bug Ross McDonald

Reply via email to