Time Series
TensorDB’s time series facet provides efficient storage and querying of timestamped metric data.
Storing Metrics
use tensordb::Value;
// Store a metric data pointdb.put_temporal( "metrics/cpu/host-1", Value::Real(72.5), 1718409600, // valid_from: timestamp 1718409660, // valid_to: +60s (1-minute bucket))?;Bucketed Aggregation
Query metrics with time buckets:
-- Average CPU per 5-minute bucketSELECT (valid_from / 300) * 300 as bucket, AVG(CAST(value AS REAL)) as avg_cpuFROM __keys__WHERE key LIKE 'metrics/cpu/%'GROUP BY bucketORDER BY bucket;Use Cases
- Infrastructure monitoring: CPU, memory, disk usage over time
- Application metrics: Request latency, error rates, throughput
- IoT data: Sensor readings with temporal bucketing
- Financial data: Price history with business-time semantics
Bitemporal Advantage
Unlike traditional time-series databases, TensorDB’s bitemporal model lets you:
- Backfill data: Write historical metrics without disrupting the timeline
- Correct errors: Write a correction for past data while preserving the original
- Audit changes: See what metrics were known at any point in system time