Time-series database implementation for metrics, IoT, financial data, and observability backends. Use when building dashboards, monitoring systems, IoT platforms, or financial applications. Covers TimescaleDB (PostgreSQL), InfluxDB, ClickHouse, QuestDB, continuous aggregates, downsampling (LTTB), and retention policies.
Production-ready Claude Skill for implementing time-series databases in metrics, IoT, financial, and observability systems.
This skill guides implementation of time-series databases optimized for:
Use this skill when:
using-timeseries-databases/
├── SKILL.md # Main skill file (230 lines, <500 limit)
├── init.md # Master plan and research
├── README.md # This file
├── references/ # Detailed documentation (4 files)
│ ├── timescaledb.md # TimescaleDB guide (850 lines)
│ ├── influxdb.md # InfluxDB guide (600 lines)
│ ├── clickhouse.md # ClickHouse guide (700 lines)
│ └── downsampling-strategies.md # LTTB algorithm (400 lines)
├── examples/ # Working code examples (2 complete projects)
│ ├── metrics-dashboard-backend/ # TimescaleDB + FastAPI
│ │ ├── schema.sql # Hypertables, continuous aggregates
│ │ ├── api.py # REST API with LTTB downsampling
│ │ └── README.md # Setup and usage guide
│ └── iot-data-pipeline/ # InfluxDB + Go + MQTT
│ ├── main.go # MQTT → InfluxDB pipeline
│ └── README.md # Architecture and deployment
└── scripts/ # Token-free utility scripts (2 scripts)
├── setup_hypertable.py # Create TimescaleDB hypertables
└── generate_retention_policy.py # Generate retention recommendations
Automatic time-based partitioning:
Pre-computed rollups for fast dashboards:
Query strategy: Short ranges use raw data, long ranges use rollups.
Automatic data expiration:
Largest-Triangle-Three-Buckets algorithm:
Time-series databases are the primary data source for real-time dashboards:
Application Metrics
↓
TimescaleDB Hypertables
↓
Continuous Aggregates (1min, 1hour, daily)
↓
REST API with LTTB Downsampling
↓
React Dashboard (Recharts/visx)
cd examples/metrics-dashboard-backend/
# Start TimescaleDB
docker run -d --name timescaledb -p 5432:5432 \
-e POSTGRES_PASSWORD=password \
timescale/timescaledb:latest-pg16
# Create schema
psql -h localhost -U postgres -f schema.sql
# Run API
pip install fastapi uvicorn psycopg2-binary
python api.py
# Test
curl "http://localhost:8000/api/metrics/cpu_usage?start=1h&points=1000"
cd examples/iot-data-pipeline/
# Start infrastructure
docker run -d --name mosquitto -p 1883:1883 eclipse-mosquitto
docker run -d --name influxdb -p 8086:8086 influxdb:3.0-alpine
# Run pipeline
export INFLUX_TOKEN="your-token"
go run main.go
# Simulate sensors
python sensor_simulator.py
python scripts/setup_hypertable.py \
--table metrics \
--partition-interval "7 days" \
--compress-after "7 days" \
--retention "90 days" \
--segment-by "host,metric_name"
python scripts/generate_retention_policy.py \
--table metrics \
--daily-rows 1000000 \
--use-case devops \
--budget-gb 500
The skill follows Anthropic's best practices for progressive disclosure:
Claude loads files on-demand as needed, minimizing token usage.
| Database | Write Throughput | Query Latency (1h) | Compression | |-------------|------------------|--------------------|-------------| | TimescaleDB | 100K-1M/sec | <100ms | 10-20x | | InfluxDB | 500K-1M/sec | <50ms | 8-15x | | ClickHouse | 1M-10M/sec | <50ms | 15-30x | | QuestDB | 4M+/sec | <10ms | 10-15x |
| Use Case | Recommended Database | Key Features | |---------------------------|---------------------------|---------------------------------------| | DevOps Monitoring | InfluxDB or TimescaleDB | Prometheus integration, Grafana | | IoT Sensor Networks | QuestDB or TimescaleDB | High write throughput, MQTT support | | Financial Tick Data | QuestDB or ClickHouse | Sub-ms queries, OHLC aggregates | | User Analytics | ClickHouse | Fastest aggregations, event tracking | | Real-time Dashboards | Any + Continuous Aggs | Pre-computed rollups, LTTB downsampling |
pip install psycopg2-binary fastapi uvicorn
go get github.com/eclipse/paho.mqtt.golang
go get github.com/influxdata/influxdb-client-go/v2
npm install pg @influxdata/influxdb-client @clickhouse/client
| Skill | Integration Pattern | |----------------------|----------------------------------------------------------| | dashboards | Primary data source for KPI cards, trend charts | | data-viz | Provides pre-aggregated data for line/area charts | | feedback | Powers alerting thresholds (CPU > 80%, latency > 500ms) | | ai-chat | Enables "Show me last hour's error rate" queries | | observability | Stores Prometheus metrics, traces, logs | | api-patterns | Exposes time-series data via REST/GraphQL | | realtime-sync | Streams live metrics via WebSocket/SSE |
This skill is part of the ai-design-components repository and follows the repository's license.
For issues or questions:
npx skills add ancoleman/using-timeseries-databases下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer