DECAYED_SUM
Performs a sum of decayed values. That sum is based on the decay factor and the age of the original data.
Syntax
DECAYED_SUM (DECAY FACTOR, DECAY_INTERVAL, VALUE, TIME)
Arguments
DECAY FACTOR:
Percentage decay for each time interval.
DECAY_INTERVAL:
Length of time between decays.
(In the example below, the entries are one minute apart, but the time interval
is every 30 seconds.)
VALUE:
The field being aggregated.
TIME:
The time field.
Returns
A decimal value.
Example
Data
"time":1628894940000,
"cpuUsage":12.3
},
{
"serverIp":"10.0.0.1",
"time":1628895000000,
"cpuUsage":55
},
{
"serverIp":"10.0.0.2",
"time":1628894700000,
"cpuUsage":2.3
},
{
"serverIp":"10.0.0.2",
"time":1628894760000
},
{
"serverIp":"10.0.0.2",
"time":1628894820000,
"cpuUsage":9.3
},
{
"serverIp":"10.0.0.2",
"time":1628894880000,
"cpuUsage":9.6
},
{
"serverIp":"10.0.0.2",
"time":1628894940000,
"cpuUsage":2.3
}
]
Query
For each server, calculate the decayed sum of CPU usage, with 30 second decay intervals and 5% decay per decay interval:
SELECT
DECAYED_SUM(0.95, 30000, data.cpuUsage, data.time) AS decayed_sum_data_cpuusage__data_time:DOUBLE,
data.serverIp AS serverip:STRING
FROM
"TIME_SERIES_DATA_w_NULL"
GROUP BY
data.serverIp
Results
{
"decayed_sum_data_cpuusagedata_time":20.064775116964842,
"serverip":"10.0.0.2"
}{
"decayed_sum_data_cpuusagedata_time":253.12634819632348,
"serverip":"10.0.0.1"
}
Related Functions
Dialog

Last updated
Was this helpful?