Table of contents
1.
Introduction to Setup
1.1.
Redis Cloud
1.2.
Docker
1.3.
Downloading and Running Binaries
1.4.
Build and Run
1.4.1.
Build
1.4.2.
Run
2.
Try With redis-cli.
3.
Creating a Time Series
4.
Adding Data Points
5.
Deleting Data Points
6.
Filtering
6.1.
Filtering by Label
6.2.
Filtering by Value
6.3.
Filtering by Timestamp
7.
Aggregation
8.
Frequently Asked Questions
8.1.
Write down the different methods for setting Redis Time Series.
8.2.
How to set Time Series on Redis Cloud?
8.3.
Write a command to build Redis Time Series.
8.4.
Name the command used to create a new Time Series.
8.5.
Name the command used to add new data points to a Time Series.
9.
Conclusion
Last Updated: Mar 27, 2024

Quickstart in Time Series

Author Prachi Singh
0 upvote

Introduction to Setup

Users can get Redis Time Series either on the cloud, in a Docker container, or on their machines.

Redis Cloud

Redis Time Series is provided by all Redis Cloud-managed Services, comprising the free managed database.

Docker

For a quick try on Redis Time Series, an instance is launched using Docker.

docker run -p 6379:6379 -it --rm redislabs/redistimeseries

Downloading and Running Binaries

The first step is to download the pre-compiled version from the Redis Download Center.

The next step is to run Redis with RedisTimeSeries:

$ Redis-server --loadmodule /path/to/module/redistimeseri

Build and Run

Users can also build and run RedisTimeSeries on their machines

Build

make build

Binary Artifacts are to be placed under the bin directory.

Run

The following piece of code will be run on the Redis server.

loadmodule bin/redistimeseries.so

Try With redis-cli.

Once users are done with the setup, they can interact with it using redis-cli.

$ redis-cli
127.0.0.1:6379> TS.CREATE sensor2
OK

Creating a Time Series

TS.CREATE command is used to create a new time series. 

TS.CREATE sensor2

This will create a time series named sensor2.

Adding Data Points

TS.ADD command is used to add new data points to a time series. 

TS.ADD key timestamp value

value refers to the numeric data value of the sample.

Deleting Data Points

TS.DEL command is used to delete data points from a time series.

TS.DEL key fromTimestamp toTimestamp

Filtering

Redis Time Series allows three different techniques for filtering.

Filtering by Label

Data points can be retrieved from multiple time series using label filters.

TS.MRANGE - + FILTER area_code=44

This query will list data from all sensors (time-series) with a label of area_code with a value of 44.

Filtering by Value

Data points can be retrieved from a single or multiple time series using values.

TS.RANGE sensor2 - + FILTER_BY_VALUE 20 30

This command will list all data points whose value sits between 20 and 30, inclusive.

Filtering by Timestamp

Filter on one Time Series:

TS.RANGE sensor1 - + FILTER_BY_TS 1626435230501 1626443276598

Aggregation

Aggregation functions are used to combine one or more values of time series.

TS.RANGE ... AGGREGATION aggType bucketDuration...

Frequently Asked Questions

Write down the different methods for setting Redis Time Series.

Users can get Redis Time Series either on the cloud, in a Docker container, or on their machines.

How to set Time Series on Redis Cloud?

Redis Time Series is provided by all Redis Cloud-managed Services, comprising the free managed database.

Write a command to build Redis Time Series.

make build

Name the command used to create a new Time Series.

TS.CREATE

Name the command used to add new data points to a Time Series.

TS.ADD

Conclusion

After reading about Redis Time Series are you not feeling excited to read/explore more articles on Quickstart to Time Series? Don't worry; Coding Ninjas has you covered.

However, you may want to pursue our premium courses to give your job an advantage over the competition!

With our Coding Ninjas Studio Guided Path, you may learn about Data Structures and Algorithms, Competitive Programming, JavaScript, System Design, and more! Check out the mock test series and participate in the contests on Coding Ninjas Studio if you want to put your coding talents to the test! However, if you've just started school and are looking for answers to concerns raised by digital behemoths such as Amazon, Microsoft, Uber, and others. As part of your placement preparations, you must evaluate the obstaclesinterview experiences, and interview package in this case. Please vote for our blogs if you find them valuable and exciting.

Happy studying!!

Live masterclass