# Timeseries

What is Epoch Time?

{% embed url="<https://www.epochconverter.com/>" %}

```
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&#x20;

Querying&#x20;

Filtering&#x20;

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
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gchandra.gitbook.io/big-data-and-tools-with-nosql/nosql/redis/timeseries.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
