SUM_TIME_SERIES

The sum of the values per time interval.

Syntax

SUM_TIME_SERIES ([MAX POINTS, INTERVAL, ]TIME, VALUE)]

Arguments

MAX POINTS: The maximum amount of points to hold before reducing the resolution to the next interval size. Default Value: 300 INTERVALS: An array of integers representing the time interval buckets to return data for. If the aggregation has more than MAX POINTS values in the given window it will use the next interval from this array to reduce the amount of points to comply with MAX POINTS . Default: [60000, 300000, 600000, 1800000, 3600000, 10800000, 21600000, 43200000, 86400000] TIME: An expression returning the time value that the VALUE is to be associated with. VALUE: An expression returning the value to aggregate in the provided TIME bucket.

Notes

The time series is calculated from the start of Unix Time.

Returns

The sum of the values per time interval. The interval are based on Unix Time that starts at a point before the first data entry time.

Example

Data

[
   {
      "serverIp":"10.0.0.1",
      "time":1628894700000,
      "cpuUsage":52.3
   },
   {
      "serverIp":"10.0.0.1",
      "time":1628894760000,
      "cpuUsage":2.4
   },
   {
      "serverIp":"10.0.0.1",
      "time":1628894820000,
      "cpuUsage":99.3
   },
   {
      "serverIp":"10.0.0.1",
      "time":1628894880000,
      "cpuUsage":99.6
   },
   {
      "serverIp":"10.0.0.1",
      "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

How much cpu is used for each time period:

SELECT 
   data.serverIp AS serverip:STRING,
   SUM_TIME_SERIES(2, [60000, 300000], data.time, data.cpuUsage) AS sum_cpu
FROM 
   TIME_SERIES_DATA_w_NULL
GROUP BY 
   data.serverIp      

Results

{
   "serverip":"10.0.0.2",
   "sum_cpu":[
      {
         "value":23.500000000000004,
         "key":1628894700000
      }
   ]
}{
   "serverip":"10.0.0.1",
   "sum_cpu":[
      {
         "value":265.9,
         "key":1628894700000
      },
      {
         "value":55,
         "key":1628895000000
      }
   ]
}

SUM LAST_TIME_SERIES MAX_TIME_SERIES MIN_TIME_SERIES

Dialog

Last updated