Failed to handle right node

kapacitor

#1

I’m trying to create a template which will serve as my “base” for other alerts:

// the database
var outputDB = 'telegraf'
// the retention policy
var outputRP = 'autogen'
// output measurement
var outputMeasurement = 'alerts'
var triggerType = 'threshold'
// The name of the alert
var name = 'Alert'
// Which measurement to consume
var measurement string
// Optional where filter
var where_filter = lambda: TRUE
// Optional list of group by dimensions
var groups = [*]
// Which field to process
var field string
// Information criteria, has access to 'mean' field
var info lambda
// Warning criteria, has access to 'mean' field
var warn lambda
// Critical criteria, has access to 'mean' field
var crit lambda
// How much data to window
var window = 5m
// The slack channel for alerts
var message = 'This is an alert.'

// Sigma
var infoSig = 2.5
var warnSig = 3
var critSig = 3.5

var data = stream
    |from()
        .measurement(measurement)
        .where(where_filter)
        .groupBy(groups)
    |window()
        .period(window)
        .every(window)
    |mean(field)
    |eval(lambda: sigma("mean"))
        .as('sigma')
        .keep()
    |alert()
        .info(info)
        .warn(warn)
        .crit(crit)
        .opsGenie2()
        .teams()
        .recipients()

var trigger = data
    |eval(lambda: float("value"))
        .as('value')
        .keep()
    |influxDBOut()
        .create()
        .database(outputDB)
        .retentionPolicy(outputRP)
        .measurement(outputMeasurement)
        .tag('alertName', name)
        .tag('triggerType', triggerType)

And here’s the generic alert (YAML format):

template-id: generic_alert
dbrps:
- db: telegraf
  rp: autogen
vars:
  name:
    type: string
    value: CPU Alert
  measurement:
    type: string
    value: cpu
  groups:
    type: list
    value:
    - type: string
      value: "host"
  field:
    type: string
    value: cpu-total
  message:
    type: string
    value: "This is test alert."
  info:
    type: lambda
    value: '"mean" > 50.0 OR "sigma" > infoSig'
  warn:
    type: lambda
    value: '"mean" > 80.0 OR "sigma" > warnSig'
  crit:
    type: lambda
    value: '"mean" > 90.0 OR "sigma" > critSig'
  window:
    type: duration
    value: 10m

I am able to “define” this in kapacitor but I’m getting this error when I try to enable it:
Error: Failed to compile stateful expression for info: Failed to handle right node: Failed to handle right node: Given node type is not valid evaluation node: *ast.IdentifierNod