Search code examples
monitoringinfluxdb-2

InfluxDB V2 OSS Alerts : capturing the metric value in notification message


We are monitoring a bunch of IoT Devices using TIG stack and are trying to configure alerts using InfluxDB V2's inbuilt Alerts feature. We have configured the slack notification channel and we would like to capture the metric value as part of the message. Here is a sample status message template:

The memory utilization is *${ r._level }* 
On Device Name: *${ r.host }*
Polled At: *${ r._time}*

This shows the alert like this:

Memory Alert  The memory utilization is crit
On Device Name: Device-dev-02
Polled At: 2021-09-16T06:41:15.000000000Z

The actual value is in the field _value, when I try to capture this as part of the message

The memory utilization is *${ r._level }* 
On Device Name: *${ r.host }*
Polled At: *${ r._time}*
Current Memory: *${ r._value}*

The notification check fails. I read in the documentation that Flux only interpolates string values, I tried to convert the _value to string

The memory utilization is *${ r._level }* 
On Device Name: *${ r.host }*
Polled At: *${ r._time}*
Current Memory: *${string(v: r._value)}*

Still the notification check fails.

Are we missing something?


Solution

  • I was able to get this question answered, thanks to Jay from Influxdata community. Posting the answer here, hopefully someone might find it useful.

    When creating a check the _value field is automatically pivoted. In short this means instead of using the _value field you should use the _fieldname.

    For example:

    Check: ${ r._check_name } is: ${ r._level } ${string(v: r.used_percent)} 
    

    Where by used_percent was the _field name.