Skip to main content

Monitoring

Three SQL views give you operational visibility into ChronoTables, RollUps, and query workload. No external metrics service required — the same data can be scraped by sql_exporter for Prometheus.

lakets_metrics()

Returns every LakeTS operational metric as key-value rows. Prometheus-compatible.

Returns: TABLE — metric_name, metric_value, labels (JSONB)

Metrics include total ChronoTables, total chunks by status, RollUp refresh lag, policy-execution stats, and more.

SELECT * FROM lakets.lakets_metrics();
-- lakets_chronotables_total | 5 | {}
-- lakets_chunks_total | 127 | {"status": "active"}
-- lakets_chunks_total | 340 | {"status": "tiered"}
-- lakets_rollup_refresh_lag_seconds | 45.2 | {"rollup": "hourly_sensors"}

Chunk counts are emitted as a single lakets_chunks_total metric labelled by status (one row per status), and RollUp lag is emitted as two metrics: lakets_rollup_watermark_lag_seconds and lakets_rollup_refresh_lag_seconds.

Tiering metrics

lakets_metrics() emits three per-table tiering metrics (labelled by table):

MetricMeaning
lakets_tiering_pending_chunks{table}Aged-out chunks not yet validated durable in UC
lakets_tiering_tiered_chunks_total{table}Chunks validated durable in UC and flagged tiered (still resident in Lakebase)
lakets_tiering_caught_up{table}1 when the durability gate currently passes for all pending chunks, else 0

chunk_health()

Per-ChronoTable chunk-health breakdown.

Returns: TABLE — chronotable, total_chunks, active_chunks, tiered_chunks, dropped_chunks, oldest_active, newest_active

show_tiering_status(p_table_name, p_schema_name)

Per-ChronoTable view of tiering progress and CDF durability — the function to reach for when chunks aren't being flagged or dropped. Both parameters are optional; with no arguments it reports every table that has a tiering policy.

Returns: TABLE

ColumnTypeDescription
schema_nameTEXTSchema of the ChronoTable
table_nameTEXTChronoTable name
afterTEXTTiering threshold (e.g. 7 days)
active_chunksINTResident, not yet validated durable in UC
tiered_chunksINTValidated durable in UC, still resident in Lakebase (ready to drop)
pending_chunksINTAged past tier_after, awaiting validation
reclaimable_bytesBIGINTLakebase storage held by tiered chunks (droppable at drop_after)
reclaimed_bytesBIGINTLakebase storage already freed by dropped chunks
cdf_statusTEXTSTREAMING, SKIPPED, or NONE
cdf_lag_bytesBIGINTHow far CDF must still flush before the gate passes
caught_upBOOLEANTRUE when the gate passes for all pending chunks
last_run_atTIMESTAMPTZLast time the tiering job ran for this table

Read cdf_status as:

  • NONE — sync was never enabled for this table (lakets.enable_sync() not called).
  • SKIPPED — the shadow exists but isn't streaming (e.g. missing REPLICA IDENTITY FULL).
  • STREAMING — CDF is healthy; validation and gated drops can proceed once caught_up is TRUE.

query_stats(p_limit)

Top queries by total execution time. Wraps pg_stat_statements; returns empty if the extension is unavailable.

ParameterTypeDefaultDescription
p_limitINT20Number of top queries to return

Returns: TABLE — query, calls, total_time_ms, mean_time_ms, rows_returned