Choose a time-series database appropriate for your scale: InfluxDB OSS or Cloud for moderate workloads, TimescaleDB (PostgreSQL extension) for SQL familiarity, or Apache IoTDB for high-throughput industrial scenarios
Write telemetry from the MQTT broker or stream processor to the DB using its native line protocol or REST API; for InfluxDB use the /api/v2/write endpoint with line protocol format: measurement,tag1=v1 field1=1.0 <nanosecond-timestamp>
Define a downsampling task or continuous aggregate: in InfluxDB use a Flux task that runs every 5 minutes to calculate mean, min, max of raw data and write to a separate measurement; in TimescaleDB use CREATE MATERIALIZED VIEW with WITH (timescaledb.continuous)
Set a retention policy on the raw data bucket to expire high-resolution data after a shorter window (e.g., 7 days) while retaining downsampled hourly or daily aggregates indefinitely or for a longer period
Index on device ID (tag in InfluxDB, indexed column in TimescaleDB) to ensure per-device queries do not perform full table scans; partition time-series tables by time range to keep query performance stable as data volume grows
Monitor write throughput, cardinality (number of unique tag value combinations), and query latency; high cardinality (millions of unique tag sets) is the most common cause of memory exhaustion in time-series DBs
Known gotchas
In InfluxDB, tags are indexed and fields are not; putting high-cardinality values (UUIDs, raw sensor readings) into tags instead of fields causes exponential index bloat and severe memory pressure
Continuous aggregates and downsampling tasks operate on data already written; data that arrives late (out-of-order timestamps from delayed devices) may fall outside the aggregate window and be missed unless the task is re-run with a backfill
Timestamps must be in the expected precision; sending millisecond timestamps to an endpoint expecting nanoseconds results in data appearing at year 1970 or far in the future depending on the magnitude
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp