Hello,
I’m working on a tick script (batch) to get data relating to two locations but am having problems with the with the eval node.
Script:
var data = batch
|query(’’'
SELECT last(“Success”)
FROM “ClientName”.“year”.citrixLoginSimulation
WHERE “ServerTagName” = ‘Manchester’ OR “ServerTagName” = ‘Newcastle’
''')
.groupBy('ServerTagName')
.every(5m)
.period(10m)
|eval(lambda: if("Success" != 0 AND "ServerTagName" == 'Newcastle' OR "ServerTagName" == 'Manchester', 'fail', 'pass'))
.as('last_attempt')
.keep()
var alert = data
|alert()
.crit("last_attempt" == 'fail')
.email('pb@myemail.co.uk')
I’m following the documentation regarding lambda expressions but when i define the script i get the error message:
name “last_attempt” is undefined. Names in scope:
The value i need isn’t set in a variable at the top of the script, I was under the impression that the variable of ‘last_attempt’ is created when i run the evaluation node which would allow me to work with that variable. Now I’m not sure.
Influx version: v1.3.8-c1.3.8 - Enterprise.
Kapacitor: Kapacitor 1.3.3
I have other scripts that give me a value from the |eval node but they don’t contain any IF statements so I don’t know if that is the issue or not.
Can anyone spot any mistakes or offer any help on this? This option seemed easier than using subqueries but would sub queries be the best way to go?
Thanks,
PhilB