Hello,
I’m having trouble converting a value from a decimal (formatted like 0.35
) to a percentage (formatted like 35
). It works when I set the crit = 0.5
dbrp "telegraf"."autogen"
var db = 'telegraf'
var rp = 'autogen'
var measurement = 'mesos'
var groupBy = ['datacenter']
var whereFilter = lambda: TRUE
var period = 10s
var every = 30s
var name = 'Mesos Slave Pool CPU'
var idVar = name + '-{{.Group}}'
var message = 'Mesos CPU pool low on `{{ index .Tags "datacenter" }}` (Current value: {{ index .Fields "value" }})'
var idTag = 'alertID'
var levelTag = 'level'
var messageField = 'message'
var durationField = 'duration'
var outputDB = 'chronograf'
var outputRP = 'autogen'
var outputMeasurement = 'alerts'
var triggerType = 'threshold'
var crit = 0.5
var data = stream
|from()
.database(db)
.retentionPolicy(rp)
.measurement(measurement)
.groupBy(groupBy)
.where(whereFilter)
|window()
.period(period)
.every(every)
.align()
|last('master/cpus_percent')
.as('value')
var trigger = data
|alert()
.crit(lambda: "value" > crit)
.stateChangesOnly()
.message(message)
.id(idVar)
.idTag(idTag)
.levelTag(levelTag)
.messageField(messageField)
.durationField(durationField)
.slack()
.workspace('myworkspace')
.channel('@me')
trigger
|eval(lambda: float("value"))
.as('value')
.keep()
|influxDBOut()
.create()
.database(outputDB)
.retentionPolicy(outputRP)
.measurement(outputMeasurement)
.tag('alertName', name)
.tag('triggerType', triggerType)
trigger
|httpOut('output')
However, I’d really like to be able to set crit = 50
and convert the value
to a whole number. I have tried setting it in the data
portion
|eval(lambda: last('master/cpus_percent') * 100)
.as('value')
as well as the trigger
portion, but it doesn’t work
trigger
|eval(lambda: float("value") * 100)
.as('value')
.keep()
|influxDBOut()
Is this possible? Cheers