SUM

The sum of the values in the time window.

Syntax

SUM(VALUE)

Arguments

VALUE: An expression that evaluates to a numeric.

Returns

The sum of the values in the file.

Notes

Sums are rounded down to the closest integer.

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

Find out how much each cpu was used:

SELECT
   SUM(data.cpuUsage) AS sum_data_cpuusage:BIGINT,
   data.serverIp AS serverip:STRING 
FROM
   "TIME_SERIES_DATA_w_NULL" 
GROUP BY
   data.serverIp

Results:

{
   "sum_data_cpuusage":23,
   "serverip":"10.0.0.2"
}{
   "sum_data_cpuusage":320,
   "serverip":"10.0.0.1"
}

AVG SUM_EACH

Dialog

Last updated