Create databases, ingest line protocol data, and query with TimeseriesQL.
Before writing data, create a database:
curl -sS -XPOST 'http://localhost:8086/query' \
--data-urlencode 'q=CREATE DATABASE mydb'Every database gets a default retention policy named autogen with infinite duration.
curl -sS -G 'http://localhost:8086/query' \
--data-urlencode 'q=SHOW DATABASES'curl -sS -XPOST 'http://localhost:8086/query' \
--data-urlencode 'q=DROP DATABASE mydb'HyperbyteDB accepts data via the InfluxDB line protocol on the /write endpoint.
measurement,tag1=val1,tag2=val2 field1=1.0,field2="str",field3=true 1609459200000000000
| Component | Description |
|---|---|
measurement |
Name of the measurement (like a table) |
tag1=val1,... |
Optional comma-separated tag key-value pairs (indexed, string-only) |
field1=1.0,... |
Required comma-separated field key-value pairs (the actual data) |
1609459200000000000 |
Optional timestamp (nanoseconds since Unix epoch by default) |
curl -sS -XPOST 'http://localhost:8086/write?db=mydb' \
--data-binary 'cpu,host=server01,region=us-west usage_idle=95.2,usage_user=4.8'If no timestamp is provided, HyperbyteDB uses the current server time.
Send multiple lines separated by newlines:
curl -sS -XPOST 'http://localhost:8086/write?db=mydb&precision=s' \
--data-binary 'cpu,host=server01 usage_idle=95.2 1609459200
cpu,host=server02 usage_idle=87.1 1609459200
mem,host=server01 used_percent=42.3 1609459200'The precision query parameter controls timestamp interpretation:
| Value | Unit | Example Timestamp |
|---|---|---|
ns (default) |
Nanoseconds | 1609459200000000000 |
us or u |
Microseconds | 1609459200000000 |
ms |
Milliseconds | 1609459200000 |
s |
Seconds | 1609459200 |
HyperbyteDB accepts gzip-compressed payloads for efficient network transfer:
gzip -c data.txt | curl -sS -XPOST 'http://localhost:8086/write?db=mydb' \
-H 'Content-Encoding: gzip' --data-binary @-| Code | Meaning |
|---|---|
| 204 | Success (no body) |
| 400 | Parse error, or partial write (points with a field type conflict dropped, the rest stored) |
| 404 | Database not found |
| 422 | Cardinality limit exceeded |
HyperbyteDB supports TimeseriesQL queries via the /query endpoint.
Important: Data must be flushed from the WAL into chDB MergeTree tables before it becomes queryable. The default flush interval is 10 seconds. Wait briefly after writing before querying.
curl -sS -G 'http://localhost:8086/query' \
--data-urlencode 'db=mydb' \
--data-urlencode 'q=SELECT * FROM cpu'curl -sS -G 'http://localhost:8086/query' \
--data-urlencode 'db=mydb' \
--data-urlencode 'q=SELECT * FROM cpu WHERE time > now() - 1h'curl -sS -G 'http://localhost:8086/query' \
--data-urlencode 'db=mydb' \
--data-urlencode 'q=SELECT mean("usage_idle") FROM cpu WHERE time > now() - 24h GROUP BY time(1h), "host"'By default, timestamps are returned as RFC3339 strings. Use the epoch parameter for numeric timestamps:
# Timestamps as nanosecond integers
curl -sS -G 'http://localhost:8086/query' \
--data-urlencode 'db=mydb' \
--data-urlencode 'q=SELECT * FROM cpu' \
--data-urlencode 'epoch=ns'epoch value |
Format |
|---|---|
| (empty) | RFC3339 ("2024-01-15T10:00:00Z") |
ns |
Nanosecond integer |
us or u |
Microsecond integer |
ms |
Millisecond integer |
s |
Second integer |
Separate multiple statements with semicolons. Each gets its own statement_id in the response:
curl -sS -G 'http://localhost:8086/query' \
--data-urlencode 'db=mydb' \
--data-urlencode 'q=SELECT * FROM cpu LIMIT 5; SELECT * FROM mem LIMIT 5'Substitute $param placeholders with a JSON params object:
curl -sS -G 'http://localhost:8086/query' \
--data-urlencode 'db=mydb' \
--data-urlencode "q=SELECT mean(\"value\") FROM \"cpu\" WHERE \"host\" = \$host AND time > now() - \$interval GROUP BY time(\$bucket)" \
--data-urlencode 'params={"host":"server01","interval":"1h","bucket":"5m"}'Queries can also be sent as POST with form-encoded body:
curl -sS -XPOST 'http://localhost:8086/query' \
-d 'db=mydb' \
-d 'q=SELECT * FROM cpu WHERE time > now() - 1h'{
"results": [
{
"statement_id": 0,
"series": [
{
"name": "cpu",
"tags": {"host": "server01"},
"columns": ["time", "usage_idle"],
"values": [
["2024-01-15T10:00:00Z", 95.2],
["2024-01-15T10:05:00Z", 93.8]
]
}
]
}
]
}Request CSV format via the Accept header:
curl -sS -G 'http://localhost:8086/query' \
-H 'Accept: text/csv' \
--data-urlencode 'db=mydb' \
--data-urlencode 'q=SELECT * FROM cpu LIMIT 5'SHOW MEASUREMENTS [ON mydb]SHOW TAG KEYS FROM cpuSHOW TAG VALUES FROM cpu WITH KEY = "host"
SHOW TAG VALUES FROM cpu WITH KEY IN ("host", "region")
SHOW TAG VALUES FROM cpu WITH KEY =~ /^h.*/SHOW FIELD KEYS FROM cpuSHOW SERIES FROM cpuRetention policies control how long data is kept before automatic deletion.
CREATE RETENTION POLICY "30_days" ON "mydb" DURATION 30d REPLICATION 1 DEFAULTDURATION— how long data is retained. UseINFfor infinite retention.REPLICATION— replication factor (informational in HyperbyteDB).DEFAULT— makes this the default RP for writes that don't specify one.
ALTER RETENTION POLICY "30_days" ON "mydb" DURATION 60d DEFAULTSHOW RETENTION POLICIES ON "mydb"A background service runs every 12 hours (by default) and issues ALTER TABLE … DELETE for rows outside each retention policy's duration window.
DELETE removes the matching rows from storage. The statement waits for points still in the WAL to be written first (up to 15 s), so a point written before the DELETE is removed and one written after it is kept.
A node keeps the WAL entries behind its last flush for crash recovery and writes them again when it restarts. Each DELETE is recorded with the point the WAL had reached, and a restarted node applies it again at that point, so deleted rows stay deleted.
In a cluster, a write that reaches a replica after the replica applied the DELETE (from the replication queue or hinted handoff) is not removed. Avoid deleting data that is still being written.
-- Delete all data older than 30 days
DELETE FROM "cpu" WHERE time < now() - 30d
-- Delete data for a specific host
DELETE FROM "cpu" WHERE "host" = 'decommissioned-01' AND time < '2024-06-01'To remove an entire measurement and all its metadata:
DROP MEASUREMENT "cpu"- Advanced features — Clustering, continuous queries, TLS, auth
- API & TimeseriesQL Reference — Complete syntax reference