Core dataIoTPerformance and Scale plans

IoT and Metrics Time Series

Ingest sensor and metrics samples, keep raw data for as long as you need, copy it to long-retention series, and aggregate into buckets on demand.

per series
Retention
copy rules
Auto
to find series
Labels
Step 1 of 6
Create a series

Keep raw samples for 24 hours and label them by building and type.

Example sessionplaying
# Create a series
hotkv> TS.CREATE temp:b4:f2 RETENTION 86400000 LABELS building b4 type temperature
OK

An animated walkthrough with real HotKV commands and example replies. Click any step to jump to it.

The problem

Thousands of sensors each send a reading every few seconds. Raw data is needed for a few hours for alerting, a year of history for reports, and finding the right series means searching by building, floor or device type. Running a separate time series database for that is one more system to operate.

How HotKV handles it

Time series in HotKV have a retention period and labels. Devices append samples with TS.ADD, a downsampling rule copies every new sample into a series you keep longer, and TS.AGG aggregates any range into fixed-width buckets with avg, min, max and other functions.

Step by step

What happens, command by command

  1. 01

    Create a series

    Keep raw samples for 24 hours and label them by building and type.

    TS.CREATE temp:b4:f2 RETENTION 86400000 LABELS building b4 type temperature
  2. 02

    A long-term series

    A second series that keeps samples for a year.

    TS.CREATE temp:b4:f2:1y RETENTION 31536000000
  3. 03

    Copy samples to it

    Every new sample is also copied to the long-term series. Read it as hourly averages with TS.AGG.

    TS.DOWNSAMPLE temp:b4:f2 temp:b4:f2:1y avg 3600000
  4. 04

    Ingest samples

    Sensors report through the gateway. * uses the server's time.

    TS.ADD temp:b4:f2 * 21.4
  5. 05

    Aggregate for a chart

    Five-minute averages for the last hour, ready to plot.

    TS.AGG temp:b4:f2 1790982000000 1790985600000 300000 avg
  6. 06

    Find series by label

    Every temperature series in building b4.

    TS.LIST LABEL building b4
Where it fits

Real-world scenarios

Smart buildings

Temperature, CO2 and occupancy are stored per floor, with raw data for a day and hourly averages for reports.

Fleet telemetry

Vehicle speed, battery and engine data are ingested continuously and charted per vehicle.

Application metrics

Request latency and error counts per endpoint feed live dashboards without a separate metrics database.

Built in

What you get

Retention per series

Old samples are removed automatically.

TS.CREATETS.RETENTION

Downsampling rules

New samples are copied to a long-retention series, which you aggregate when you read.

TS.DOWNSAMPLE

Bucket aggregation

Aggregate any range into fixed-width buckets.

TS.AGGTS.RANGE

Labels

Find series by label value.

TS.LISTTS.INFO

Common questions

Can I send my own timestamps?

Yes. Pass a Unix time in milliseconds instead of * to TS.ADD.

Which aggregations are available?

See the TS.AGG reference for the full list, including avg, min, max and sum.

Which plans include it?

Time series are part of the Performance and Scale plans.

Related use cases

Try it on your own workload

HotKV speaks the Redis protocol, so you can point an existing client at it and run these same commands.