Skip to main content

Bulk ingest

Server-side batch ingest for high-throughput data loading from edge devices, microservices, or protocol adapters.

ingest_batch(p_table_name, p_data, p_schema_name)

Inserts multiple rows from a JSONB array. Designed for edge devices or microservices that batch measurements.

ParameterTypeDefaultDescription
p_table_nameTEXTTarget ChronoTable
p_dataJSONBArray of row objects
p_schema_nameTEXT'public'Schema

Returns: INT — number of rows inserted

SELECT lakets.ingest_batch('sensor_data', '[
{"time": "2026-04-09T10:00:00Z", "device_id": "d1", "temperature": 22.5, "humidity": 60},
{"time": "2026-04-09T10:00:01Z", "device_id": "d2", "temperature": 23.1, "humidity": 58},
{"time": "2026-04-09T10:00:02Z", "device_id": "d3", "temperature": 21.8, "humidity": 62}
]');
-- Returns: 3

Bulk inserts trigger LakeTS's statement-level invalidation, so RollUps that depend on this ChronoTable have the affected buckets marked dirty automatically.

ingest_prometheus(p_table_name, p_metric_name, p_labels, p_value, p_timestamp, p_schema_name)

Inserts a single Prometheus-style metric. The target table must have columns: time, metric_name, labels (JSONB), value.

ParameterTypeDefaultDescription
p_table_nameTEXTTarget table
p_metric_nameTEXTMetric name
p_labelsJSONBLabel key-value pairs
p_valueDOUBLE PRECISIONMetric value
p_timestampTIMESTAMPTZnow()Observation timestamp
p_schema_nameTEXT'public'Schema

Returns: VOID

SELECT lakets.ingest_prometheus(
'prom_metrics',
'http_requests_total',
'{"method": "GET", "path": "/api/v1/data", "status": "200"}'::JSONB,
1542.0
);