[Solved]Performing math functions in Kapacitor


I have this script (this is part of it)

var data = stream
    // |mean('mem_active_maximum')
    //     .as('value')

    |eval(lambda: 'mem_active_maximum' / 100)
var trigger = data
        .crit(lambda: "percent" > crit)

I am trying to divide the value from mem_active_maxiumum by 100. When I define the script i get this:

Failed to compile 0 expression: invalid math operator / for type string

The documentation would suggest that should work. It doesnt, why?

EDIT: the values in the database are 6000%. I’m dividing by 100 to get the same result as i get in Grafana.

Figured it out with fresh eyes. Bloody quotes :slight_smile:

1 Like