TS.CREATE temperature_sensor1
TS.ADD temperature_sensor1 '*' 22.5
Topics
40
Caching Patterns
Cluster Sharding & Hash Slots
Clustering
Connection Pooling & Client Libraries
Data Types
Distributed Locks with Redis
Expiration & Eviction
Geospatial Data in Redis
Hashes in Redis
HyperLogLog in Redis
Keyspace Notifications
Leaderboards with Sorted Sets
Lists in Redis
Lua Scripting
Persistence (RDB/AOF)
Pub/Sub
Rate Limiting with Redis
Redis Architecture & Installation
Redis as a Message Queue
Redis Backup & Disaster Recovery
Redis CLI & Basic Commands
Redis Memory Optimization
Redis Modules Overview
Redis Monitoring & Observability
Redis Performance Tuning & Benchmarking
Redis Replication
Redis Security & ACL
Redis Sentinel & High Availability
Redis vs Memcached
Redis with Docker & Kubernetes
RedisBloom (Probabilistic Data Structures)
RedisJSON
RedisSearch (Full Text Search)
RedisTimeSeries
Session Management with Redis
Sets & Sorted Sets in Redis
Streams
Strings & Bitmaps in Redis
TLS & Encryption in Redis
Transactions
RedisTimeSeries
7 questions found
RedisTimeSeries is a module specifically designed for efficiently storing and querying time stamped data, such as sensor readings, application metrics, or stock prices, providing specialized commands for adding data points, querying ranges of time, and automatically aggregating or downsampling data over time.
Real-world example
An industrial monitoring system uses RedisTimeSeries to efficiently store temperature readings from thousands of sensors, taking advantage of its specialized time based querying and aggregation capabilities.
Redis Modules Overview;Sets & Sorted Sets in Redis
How do you add a new data point to a Redis time series, and how do you query a range of recent data?
BeginnerYou use TS.ADD to add a new value with either a specific timestamp or an asterisk to automatically use the current time, and TS.RANGE to retrieve all data points falling within a specified time range, letting you easily query for something like all readings from the last hour.
TS.ADD temperature_sensor1 '*' 23.1
TS.RANGE temperature_sensor1 - +
Real-world example
A weather monitoring dashboard adds new temperature readings as they arrive and queries the full range of recent readings using TS.RANGE to display a chart of temperature over time.
Data Types;Sets & Sorted Sets in Redis
How do you configure automatic downsampling in RedisTimeSeries, where detailed recent data is aggregated into coarser summaries over time?
IntermediateYou create a compaction rule using TS.CREATERULE, specifying a source time series, a destination time series, an aggregation type like average or maximum, and a bucket duration, which automatically creates aggregated data points in the destination series as new raw data arrives in the source, letting you keep detailed recent data while automatically summarizing older data into less granular form.
TS.CREATE temperature_hourly_avg
TS.CREATERULE temperature_sensor1 temperature_hourly_avg AGGREGATION avg 3600000
Real-world example
A sensor monitoring system keeps detailed second by second readings for the past day, while automatically maintaining an hourly average time series for long term historical trend analysis, without needing to manually calculate and store these aggregates.
RedisTimeSeries;Redis Modules Overview
How do you configure a retention period for a Redis time series so old data is automatically removed after a certain amount of time?
IntermediateYou set a retention period, specified in milliseconds, either when creating the time series or by altering it afterward, and Redis automatically removes any data points older than that configured retention window, keeping the time series from growing indefinitely while retaining only the recent history your application actually needs.
TS.CREATE sensor_data RETENTION 86400000
-- Keeps only the last 24 hours of raw data
Real-world example
A high frequency sensor monitoring system configures a twenty four hour retention period for its raw data time series, automatically discarding older detailed readings while relying on downsampled aggregates for longer term historical analysis.
Expiration & Eviction;Redis Modules Overview
How would you design a monitoring system architecture using RedisTimeSeries that efficiently handles both high frequency raw data ingestion and long term historical trend analysis?
AdvancedYou would configure a short retention period for high frequency raw data optimized for immediate alerting and detailed recent analysis, set up multiple compaction rules creating progressively coarser aggregated time series such as hourly, daily, and monthly summaries, and configure appropriately longer retention periods for each of those aggregated series based on how far back you actually need historical trend visibility.
TS.CREATE raw_metrics RETENTION 3600000
TS.CREATE hourly_metrics RETENTION 604800000
TS.CREATERULE raw_metrics hourly_metrics AGGREGATION avg 3600000
Real-world example
A large scale infrastructure monitoring platform maintains raw metrics for just one hour for immediate alerting, hourly aggregates for a week of detailed trend analysis, and monthly aggregates retained indefinitely for long term capacity planning, all automatically maintained through RedisTimeSeries compaction rules.
Redis Memory Optimization;Redis Modules Overview
How does RedisTimeSeries handle labels and how can you use them to query across multiple related time series at once?
AdvancedYou can attach labels, which are key value metadata pairs, to a time series when creating it, and use TS.MRANGE with a label based filter expression to query across all time series matching those labels simultaneously, which is especially useful when you have many similar time series, such as one per server or sensor, and need to analyze them together.
TS.CREATE cpu_usage:server1 LABELS region 'us-east' role 'web'
TS.MRANGE - + FILTER region=us-east
Real-world example
A cloud infrastructure monitoring system labels each server's CPU usage time series with its region and role, letting an operator query the combined CPU usage trend across every web server in a specific region with a single command.
Redis Modules Overview;Data Types
What aggregation functions are available when querying a range of data from a Redis time series, and how do you apply one during a query?
IntermediateRedisTimeSeries supports aggregation functions including avg, sum, min, max, count, and several others, which you apply to a TS.RANGE query using the AGGREGATION clause along with a specified time bucket duration, letting you retrieve summarized data, such as the average value per hour, directly from a query rather than needing to calculate it yourself afterward.
TS.RANGE temperature_sensor1 - + AGGREGATION avg 3600000
Real-world example
A dashboard displaying a chart of average hourly temperature over the past week retrieves this exact summarized data directly from a single TS.RANGE query using the avg aggregation, without needing any additional calculation in the application code.
RedisTimeSeries;Data Types