EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login
Home Software Development Software Development Tutorials Redis Tutorial RedisTimeSeries
Secondary Sidebar
Redis Tutorial
  • Redis
    • Redis Pubsub
    • Redis GUI
    • Redis Database
    • Redis Get All Keys
    • Redis TTL
    • Redis EXPIRE
    • Redis Version
    • Redis EXPIRE
    • Redis List
    • Redis CLI Commands
    • Redis HSET
    • Redis FLUSHDB
    • Redis Key
    • Redis Persistence
    • Redis FLUSHALL
    • Redis pipeline
    • Redis SADD
    • Redis ZADD
    • Redis ZSET
    • Redis Get
    • Redis Replication
    • Redis Delete All Keys
    • Redis Use Cases
    • Redis HMSET
    • Redis Transactions
    • Redis Monitor
    • Redis HGET
    • Redis SETEX
    • Redis Rails
    • RedisJSON
    • Redis Get Key
    • Redis Auth
    • Redis gem
    • Redis Key Count
    • RedisTimeSeries
    • Redis Timeout
    • Redis LPUSH
    • Redis Architecture
    • Redis API
    • Redis Message Queue
    • Redis RPUSH
    • Redis Protocol
    • Redis Data Types
    • Redis Namespace
    • Redis ZRANGE
    • Redis Master Slave
    • Redis Memory Usage
    • Redis WATCH
    • Redis URL
    • Redis Key Value
    • Redis INCR
    • Redis EXISTS
    • Redis INFO
    • Redis HMGET
    • Redis Operator
    • Redis NOAUTH Authentication Required
    • Redis LRANGE
    • Redis RDB
    • Redis TLS
    • Redis HDEL
    • Redis WebSocket
    • Redis HGETALL
    • Redis GETSET
    • Node-RED WebSocket

RedisTimeSeries

Introduction to RedisTimeSeries

RedisTimeSeries is a redis module that was used to add the data structure name as time series into the redis. It simplifies the use of Redis for time series use cases such as stock prices, IoT, and telemetry. By using it we can ingest the query in millions of events and samples at redis speed. The RedisTimeSeries is used in advanced tooling.

RedisTimeSeries

Key Takeaways

  • We can use RedisTimeSeries advanced tools such as aggregation and down sampling to ensure a small memory footprint without affecting performance.
  • We are using the time series module in redis for adding the module or data structure into our code.

What is RedisTimeSeries?

We are using multiple queries for monitoring and visualization of built-in connections. It is a more efficient way for storing data of time series into the redis. The retention rule will query the multi-key if possible by using simple redis commands.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

It will work well with the redis gears and redis API which were used to enable advanced use cases such as detection in anomaly and predictive maintenance. It will rapidly integrate with the tools like grafana, data migration, and visualization. It will automatically execute the retention rules and downsampling by using double data compression for storing datasets of large time series.

How to Install RedisTimeSeries?

We are downloading the repository of RedisTimeSeries by using git.

1. In the below example we can see that we are downloading the repository of RedisTimeSeries by using git as follows. We are cloning the RedisTimeSeries repository.

Code:

# git clone --recursive ….git

Output:

Repository RedisTimeSeries

2. After cloning the directory now in this step, we are changing the directory of the RedisTimeSeries setup.

Code:

# cd RedisTimeSeries/

Output:

RedisTimeSeries Directory

3. After changing the directory, now in this step we are using the make setup command to set up the redis time change as follows.

Code:

# make setup

Output:

using make setup command

4. After setting up the RedisTimeSeries, now we are starting the redis server by using the below command.

Code:

# redis-server

Output:

Starting RedisTimeSeries Server

5. After starting the service, now we are checking the service and RedisTimeSeries installation while login in the redis server by using the redis cli command.

Code:

# redis-cli

Output:

redis cli command

RedisTimeSeries Datastore

The data is modeled in RedisTimeSeries according to the application model. It is dependent on the power of redis, as well as redis json and redis search. While storing data on the cloud and local machine, all redis commands are identical.

The following example shows how we can store data using RedisTimeSeries:

In the below example, we are creating the rb file to execute the RedisTimeSeries data store as follows.

Code:

require 'redis-time-series'
time_series = Redis::TimeSeries.new('RedisTimeSeries')
time_series.add 2341
time_series.add 45
time_series.add 65
time_series.range (Time.now.to_i - 200)..Time.now.to_i * 1000

Output:

 Datastore

We create the time series as a variable and assign it throughout the code. In the following example, we are creating a time series that represents the temperature for the specified measurement. Following the creation of the temperature measurement, we query the data for the specified time range for the aggregation rule, as shown below. We create the rb file for the same as follows.

Code:

require 'redis-time-series'
time_series.CREATE temp:3:11 RETENTION 30 LABELS s_id 4 a_id 16
time_series.ADD temp:2:13 181 10
time_series.ADD temp:2:13 154 22
time_series.RANGE temp:2:13 150 190 AGGREGATION avg 4

Output:

RedisTimeSeries - rb file

RedisTimeSeries Model

The RedisTimeSeries model is used to implement the timeseries data by using a rich set of commands. It will maintain the linked list which was used to core that specified lightweight node. Every node from the linked list will consist of two corresponding arrays with a size of 128 bits. The single array is used to store the timestamps and the other array is used to store the sample values. The redis time stamp and its value are called a sample.

Below figure shows how the RedisTimeSeries model will work as follows:

RedisTimeSeries Model

From the above model, we can see that first, we are creating new time series. In the below example, we are creating the time series of redis_temp. After creating the time series, we need to add the new sample to the time series. We can add any sample to the time series. After adding the sample, we need to range the query across the time series which we have defined.

Below example shows how the RedisTimeSeries module will work as follows:

Code:

require 'redis-time-series'
t_ser.CREATE redis_temp:3:11 RETENTION 15 LABELS s_id 2 a_id 8
t_ser.ADD redis_temp:1:7 181 10
t_ser.ADD redis_temp:1:7 154 22
t_ser.RANGE redis_temp:1:7 150 190 AGGREGATION avg 2

Output:

Working of module

RedisTimeSeries Features

RedisTimeSeries contains multiple features.

  • It is used to read the low latency and used in a high-volume insertion of data.
  • We can query into the redis database as per start and end time by using it.
  • We can use the aggregated query like avg, min, sum, max Var.P, Var.S, and many more. This query is used for a specified time of bucket.
  • While using it we can configure the retention period which was maximum.
  • We can use it to perform down sampling. We are using down sampling for aggregated time series.
  • We can use the secondary indexes for entries that contain the time series. Every time series contain the labels.
  • By using the redis time scale we can ingest the data fastly by using the infinite scale onto the dataset of time series.
  • By using it we can automatically execute the retention rules and the down sampling.
  • We can easily detect the anomaly that occurred in our program by using it.
  • We can collect the telemetry type of data from multiple devices which was located remotely by using RedisTimeSeries.
  • Application monitory is very while using time series in redis. We can gain deep insights of the application.

FAQ

Given below are the FAQs mentioned:

Q1. What is the use of RedisTimeSeries?

Answer: It is nothing but the module which is used to load the data structure of the time series.

Q2. How can we use RedisTimeSeries with redis-cli?

Answer: To use it with redis cli, first load the RedisTimeSeries module, then connect to the Redis server using redis cli. After connecting to redis-cli, we can run the command.

Q3. Which configuration parameter we are using at the time of loading the RedisTimeSeries module?

Answer: We are using the configuration parameter name as num threads, compaction policy, retention policy, duplicate policy, and chunk type parameter while using it.

Conclusion

RedisTimeSeries will work well with Redis Gears and the Redis API, which were used to enable advanced use cases such as anomaly detection and predictive maintenance. It simplifies the use of Redis for time series use cases such as stock prices, IoT, and telemetry.

Recommended Articles

This is a guide to RedisTimeSeries. Here we discuss the introduction, how to install redisTimeSeries? datastore, model, and features. You may also have a look at the following articles to learn more –

  1. Redis Get All Keys
  2. Redis GUI
  3. Redis Pubsub
  4. Redis Version
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2023 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more