Back to results for “RedisTimeSeries”
Redis › RedisTimeSeries

How does RedisTimeSeries handle labels and how can you use them to query across multiple related time series at once?

Advanced

Answer

You 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.

Common follow-ups: How many labels can reasonably be attached to a single time series?;What is the performance difference between querying a single series versus using MRANGE across many labeled series?