Integral functions - Amazon Timestream

Integral functions

You can use integrals to find the area under the curve per unit of time for your time series events. As an example, suppose you're tracking the volume of requests received by your application per unit of time. In this scenario, you can use the integral function to determine the total volume of requests served per specified interval over a specific time period.

Amazon Timestream supports one variant of integral functions. This section provides usage information for the Timestream for LiveAnalytics integral function, as well as sample queries.

Usage information

Function Output data type Description

integral_trapezoidal(timeseries(double))

integral_trapezoidal(timeseries(double), interval day to second)

integral_trapezoidal(timeseries(bigint))

integral_trapezoidal(timeseries(bigint), interval day to second)

integral_trapezoidal(timeseries(integer), interval day to second)

integral_trapezoidal(timeseries(integer))

double

Approximates the integral per the specified interval day to second for the timeseries provided, using the trapezoidal rule. The interval day to second parameter is optional and the default is 1s. For more information about intervals, see Interval and duration.

Query examples

Calculate the total volume of requests served per five minutes over the past hour by a specific host:

SELECT INTEGRAL_TRAPEZOIDAL(CREATE_TIME_SERIES(time, measure_value::double), 5m) AS result FROM sample.DevOps WHERE measure_name = 'request' AND hostname = 'host-Hovjv' AND time > ago (1h) GROUP BY hostname, measure_name