Timeseries

What is Epoch Time?

TS.CREATE sensor1

type sensor1

DEL sensor1

## Keep 1 month of data

TS.CREATE sensor1 RETENTION 2678400000

TS.ADD sensor1 * 50

(* tells Redis to use the server's current time), 

TS.RANGE sensor1 - +

LABELS:

Organization

Querying

Filtering

Efficiency

TS.CREATE sensor1:32 RETENTION 2678400000

TS.CREATE sensor2:33 RETENTION 2678400000

TS.ADD sensor1:32 * 51 LABELS area_id 32 sensor_id 1
TS.ADD sensor1:32 * 52 LABELS area_id 32 sensor_id 1
TS.ADD sensor1:32 * 50 LABELS area_id 32 sensor_id 1
TS.ADD sensor1:32 * 55 LABELS area_id 32 sensor_id 1

TS.RANGE sensor1:32 <start_timestamp> <end_timestamp>

TS.RANGE sensor1:32 - +

TS.RANGE sensor1:32 - + FILTER_BY_VALUE 45 51
TS.ADD sensor1:32 * 60 LABELS area_id 32 sensor_id 1


TS.ADD sensor2:33 * 25 LABELS area_id 33 sensor_id 2
TS.ADD sensor2:33 * 22 LABELS area_id 33 sensor_id 2
TS.ADD sensor2:33 * 24 LABELS area_id 33 sensor_id 2


## Find the Avg value in 60000 milliseconds (10 min)
TS.RANGE sensor2:33 - + AGGREGATION AVG 60000 

## Find the Avg value in 36000 milliseconds (36 min)
TS.RANGE sensor2:33 - + AGGREGATION AVG 36000 

TS.CREATE sensor1:32:avg_hourly
TS.CREATE sensor2:33:avg_hourly

TS.CREATERULE sensor2:33 sensor2:33:avg_hourly AGGREGATION avg 3600000

Last updated