Skip to main content

logs

Creates, updates, deletes, gets or lists a logs resource.

Overview

Namelogs
TypeResource
Idclickhouse.postgres.logs

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
bodystringRaw log entry body as emitted by PostgreSQL. Structured bodies are returned as a JSON-encoded string.
severitystringPostgreSQL severity of the entry (for example, LOG, WARNING, ERROR, FATAL, PANIC).
timestampstring (date-time)Time the entry was logged (RFC 3339).

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
listselectpostgres_id, from_date, to_date, organization_idbody_contains, severity, sort_order, limit, offsetThis endpoint is in beta. API contract is stable, and no breaking changes are expected in the future. <br /><br /> Returns PostgreSQL server log entries for a Postgres service within the given time window, most recent first by default (override with sort_order). Results are paginated with limit/offset; advance offset until a page returns fewer than limit entries to read the full window. The time range must not exceed 30 days, and to_date must be after from_date.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
from_datestring (date-time)Inclusive start of the time window (RFC 3339 date-time).
organization_idstringClickHouse Cloud organization ID. Resolved from the CLICKHOUSE_ORG_ID environment variable when it is set (x-stackQL-envVar); otherwise it must be supplied on every query as WHERE organization_id = <uuid>. A WHERE value always takes precedence over the environment. (x-stackQL-envVar: CLICKHOUSE_ORG_ID)
postgres_idstring (uuid)ID of the requested Postgres service. (wire: postgresId)
to_datestring (date-time)Inclusive end of the time window (RFC 3339 date-time).
body_containsstringCase-sensitive substring the log body must contain.
limitintegerMaximum number of results to return.
offsetintegerNumber of results to skip before returning.
severitystringFilter to log entries with this PostgreSQL severity (for example, ERROR, WARNING, LOG).
sort_orderstringSort order. One of asc or desc.

SELECT examples

This endpoint is in beta. API contract is stable, and no breaking changes are expected in the future. <br /><br /> Returns PostgreSQL server log entries for a Postgres service within the given time window, most recent first by default (override with sort_order). Results are paginated with limit/offset; advance offset until a page returns fewer than limit entries to read the full window. The time range must not exceed 30 days, and to_date must be after from_date.

SELECT
body,
severity,
timestamp
FROM clickhouse.postgres.logs
WHERE postgres_id = '{{ postgres_id }}' -- required
AND from_date = '{{ from_date }}' -- required
AND to_date = '{{ to_date }}' -- required
AND organization_id = '{{ organization_id }}' -- required unless CLICKHOUSE_ORG_ID is set
AND body_contains = '{{ body_contains }}'
AND severity = '{{ severity }}'
AND sort_order = '{{ sort_order }}'
AND limit = '{{ limit }}'
AND offset = '{{ offset }}'
;