Trouble with non_negative_difference()

influxdb

#1

I have a measurement where I want to extract the difference between the low and high values when I aggregate/group over 1m time periods. I have a query using the difference() function that works except when value wraps from high back to low – in which case I get an unwanted negative number.
I thought I could use non_negative_difference() in place of difference, but I get errors as shown below. Any suggestions or guidance on using this function in place of difference()?

thanks…gregj

I am using influx version 1.5.3

select difference(min(monSecs)) as monSecs from rp_1.progAlarmSummary where flowid=‘2’ and programNum=‘1248’ and time>=1528489274000000000 and time<=1528489489000000000 GROUP BY time(1m), flowid, programNum

name: progAlarmSummary
tags: flowid=2, programNum=1248

time monSecs


1528489260000000000 60
1528489320000000000 60
1528489380000000000 60
1528489440000000000 -840

select non_negative_difference(min(monSecs)) as monSecs from rp_1.progAlarmSummary where flowid=‘2’ and programNum=‘1248’ and time>=1528489274000000000 and time<=1528489489000000000 GROUP BY time(1m), flowid, programNum

ERR: error parsing query: expected field argument in non_negative_difference()

select non_negative_difference(monSecs) as monSecs from rp_1.progAlarmSummary where time>=1528489274000000000 and time<=1528489489000000000 GROUP BY time(1m), flowid, programNum

ERR: unsupported call: non_negative_difference