Upsolver
Search…
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. D‌ECAY_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

1
"time":1628894940000,
2
"cpuUsage":12.3
3
},
4
{
5
"serverIp":"10.0.0.1",
6
"time":1628895000000,
7
"cpuUsage":55
8
},
9
{
10
"serverIp":"10.0.0.2",
11
"time":1628894700000,
12
"cpuUsage":2.3
13
},
14
{
15
"serverIp":"10.0.0.2",
16
"time":1628894760000
17
},
18
{
19
"serverIp":"10.0.0.2",
20
"time":1628894820000,
21
"cpuUsage":9.3
22
},
23
{
24
"serverIp":"10.0.0.2",
25
"time":1628894880000,
26
"cpuUsage":9.6
27
},
28
{
29
"serverIp":"10.0.0.2",
30
"time":1628894940000,
31
"cpuUsage":2.3
32
}
33
]
Copied!
Query For each server, calculate the decayed sum of CPU usage, with 30 second decay intervals and 5% decay per decay interval:
1
SELECT
2
DECAYED_SUM(0.95, 30000, data.cpuUsage, data.time) AS decayed_sum_data_cpuusage__data_time:DOUBLE,
3
data.serverIp AS serverip:STRING
4
FROM
5
"TIME_SERIES_DATA_w_NULL"
6
GROUP BY
7
data.serverIp
Copied!

Results

1
{
2
"decayed_sum_data_cpuusagedata_time":20.064775116964842,
3
"serverip":"10.0.0.2"
4
}{
5
"decayed_sum_data_cpuusagedata_time":253.12634819632348,
6
"serverip":"10.0.0.1"
7
}
Copied!
SUM

Dialog