Intro to RedisTimeSeries
Kyle Davis
Head of Developer Advocacy, Redis Labs
What is Time Series Data?
2
• Data that simply has time as an index
• Each recorded time numeric value.
• Time + Value = Sample
• Analyze using time-bounded ranges
–Separate into time units
–Example: Averages in each hour
Time Series data is…
3
Common Examples of Time Series Data
4
Redis and Time Series
5
• Member + Sort Order
–ZADD mySortedSet 1559938522 1000
• Get by ranges, not much else
• Duplicate Member Problem
–ZADD mySortedSet 1559938522 1000
–ZADD mySortedSet 1559938524 1000 <- Upsert instead of insert
–Hacky solution:
• ZADD mySortedSet 1559938522 1000:<random value>
• ZADD mySortedSet 1559938524 1000:<random value>
It all started with sorted sets…
6
• Designed to solve similar problems
–Unified log
–Messaging
• Allows for auto-generated IDs, no duplicates, and per-sample field/value pairs
–XADD myStream * myValue 1000
–XADD myStream * myValue 1000 anotherField hello
• Get by ranges, not much else
Then came Redis Streams
7
Modules API enables adding additional commands & data types
8
RedisTimeSeries implements an a time series database as a
module in Redis
9
How does RedisTimeSeries
work?
10
00 00 00 00 00 00 03 E800 00 00 00 5C FA C5 DD
11
PREVIOUSPOINTER
NEXTPOINTER
Timestamps Sample Values
Timestamp: 1559938525
Value: 1000
12
Oldest
13
Oldest
Creating a Time Series Key
TS.CREATE myTS
14
Oldest
Labels (Optional)
TS.CREATE myTS LABELS plant cabbage-47 location greenhouse-
4
plant : cabbage-47,
location : greenhouse-4
field value field value
15
Retention (Optional)
TS.CREATE myTS RETENTION 60 …
61 seconds old 50 seconds old 20 seconds old
58 · · · · 59 · · · · 60 · · · · 61
16
Oldest
Adding Values
TS.ADD myTS * 834
17
Oldest
Adding Values
TS.ADD myTS 1559938526 1000
18
Oldest
Getting Values
TS.RANGE myTS 1559938522 1559939000
1) 1) (integer) 1559938526
2) "834"
2) 1) (integer) 1559938524
2) "1000"
19
Oldest
Getting Values
TS.RANGE myTS 1559938522 1559939000 AGGREGATION avg 30
1) 1) (integer) 1559938520
2) "917"
20
0-10s ago
11-20s ago
21-30s ago
TS.CREATERULE myTS myTS2 AGGREGATION 30avgsumminmaxrangecountfirstlast
myTS
myTS2
What else can you do with
RedisTimeSeries?
21
• TS.INCRBY / TS.DECRBY for counting over time
• TS.GET to grab the most recent sample
• TS.ALTER to change your meta data
• TS.MRANGE and TS.MGET to query across time series keys
Additional Commands
• Use it with Prometheus and Grafana for monitoring dashboards
• Use it as part of Redis Edge in IoT situations
• Cache your most used time series data in RedisTimeSeries
Connect it with other parts of your infrastructure
• Go to http://redistimeseries.io/ to explore
–Launch it using Docker
–Build it yourself
–Look at the commands
• Checkout the GitHub Org: https://github.com/RedisTimeSeries
Next Steps
Thank you!
Thank you!

Intro to Redis TimeSeries

  • 1.
    Intro to RedisTimeSeries KyleDavis Head of Developer Advocacy, Redis Labs
  • 2.
    What is TimeSeries Data? 2
  • 3.
    • Data thatsimply has time as an index • Each recorded time numeric value. • Time + Value = Sample • Analyze using time-bounded ranges –Separate into time units –Example: Averages in each hour Time Series data is… 3
  • 4.
    Common Examples ofTime Series Data 4
  • 5.
  • 6.
    • Member +Sort Order –ZADD mySortedSet 1559938522 1000 • Get by ranges, not much else • Duplicate Member Problem –ZADD mySortedSet 1559938522 1000 –ZADD mySortedSet 1559938524 1000 <- Upsert instead of insert –Hacky solution: • ZADD mySortedSet 1559938522 1000:<random value> • ZADD mySortedSet 1559938524 1000:<random value> It all started with sorted sets… 6
  • 7.
    • Designed tosolve similar problems –Unified log –Messaging • Allows for auto-generated IDs, no duplicates, and per-sample field/value pairs –XADD myStream * myValue 1000 –XADD myStream * myValue 1000 anotherField hello • Get by ranges, not much else Then came Redis Streams 7
  • 8.
    Modules API enablesadding additional commands & data types 8
  • 9.
    RedisTimeSeries implements ana time series database as a module in Redis 9
  • 10.
  • 11.
    00 00 0000 00 00 03 E800 00 00 00 5C FA C5 DD 11 PREVIOUSPOINTER NEXTPOINTER Timestamps Sample Values Timestamp: 1559938525 Value: 1000
  • 12.
  • 13.
    13 Oldest Creating a TimeSeries Key TS.CREATE myTS
  • 14.
    14 Oldest Labels (Optional) TS.CREATE myTSLABELS plant cabbage-47 location greenhouse- 4 plant : cabbage-47, location : greenhouse-4 field value field value
  • 15.
    15 Retention (Optional) TS.CREATE myTSRETENTION 60 … 61 seconds old 50 seconds old 20 seconds old 58 · · · · 59 · · · · 60 · · · · 61
  • 16.
  • 17.
  • 18.
    18 Oldest Getting Values TS.RANGE myTS1559938522 1559939000 1) 1) (integer) 1559938526 2) "834" 2) 1) (integer) 1559938524 2) "1000"
  • 19.
    19 Oldest Getting Values TS.RANGE myTS1559938522 1559939000 AGGREGATION avg 30 1) 1) (integer) 1559938520 2) "917"
  • 20.
    20 0-10s ago 11-20s ago 21-30sago TS.CREATERULE myTS myTS2 AGGREGATION 30avgsumminmaxrangecountfirstlast myTS myTS2
  • 21.
    What else canyou do with RedisTimeSeries? 21
  • 22.
    • TS.INCRBY /TS.DECRBY for counting over time • TS.GET to grab the most recent sample • TS.ALTER to change your meta data • TS.MRANGE and TS.MGET to query across time series keys Additional Commands
  • 23.
    • Use itwith Prometheus and Grafana for monitoring dashboards • Use it as part of Redis Edge in IoT situations • Cache your most used time series data in RedisTimeSeries Connect it with other parts of your infrastructure
  • 24.
    • Go tohttp://redistimeseries.io/ to explore –Launch it using Docker –Build it yourself –Look at the commands • Checkout the GitHub Org: https://github.com/RedisTimeSeries Next Steps
  • 25.

Editor's Notes

  • #10 used in our own software