Skip to main content

sources

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

Overview

Namesources
TypeResource
Idclickhouse.clickstack.sources

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringUnique source ID. Server-generated; ignored if sent in create/update requests. (example: 507f1f77bcf86cd799439011)
namestringDisplay name for the source. (example: Logs)
log_source_idstringHyperDX Source for logs associated with traces. Optional (example: 507f1f77bcf86cd799439011) (wire: logSourceId)
metric_source_idstringHyperDX Source for metrics associated with logs. Optional (example: 507f1f77bcf86cd799439013) (wire: metricSourceId)
session_source_idstringHyperDX Source for sessions associated with traces. Optional (example: 507f1f77bcf86cd799439031) (wire: sessionSourceId)
trace_source_idstringHyperDX Source for traces associated with logs. Optional (example: 507f1f77bcf86cd799439014) (wire: traceSourceId)
body_expressionstringExpression to extract the log message body. (example: Body) (wire: bodyExpression)
connectionstringID of the ClickHouse connection used by this source. (example: 507f1f77bcf86cd799439012)
default_table_select_expressionstringDefault columns selected in search results (this can be customized per search later) (example: Timestamp, ServiceName, SeverityText, Body) (wire: defaultTableSelectExpression)
disabledbooleanWhen true, the source is hidden from source selectors in the UI. Defaults to false.
displayed_timestamp_value_expressionstringThis DateTime column is used to display and order search results. (example: TimestampTime) (wire: displayedTimestampValueExpression)
duration_expressionstringExpression to extract span duration. (example: Duration) (wire: durationExpression)
duration_precisionintegerNumber of decimal digits in the duration value (e.g., 3 for milliseconds, 6 for microseconds, 9 for nanoseconds). (wire: durationPrecision)
event_attributes_expressionstringExpression to extract event-level attributes. (example: LogAttributes) (wire: eventAttributesExpression)
filter_settingsobject (wire: filterSettings)
fromobject
highlighted_row_attribute_expressionsarrayExpressions defining row-level attributes which are displayed in the row side panel for the selected row. (wire: highlightedRowAttributeExpressions)
highlighted_trace_attribute_expressionsarrayExpressions defining trace-level attributes which are displayed in the trace view for the selected trace. (wire: highlightedTraceAttributeExpressions)
implicit_column_expressionstringColumn used for full text search if no property is specified in a Lucene-based search. Typically the message body of a log. (example: Body) (wire: implicitColumnExpression)
kindstringSource kind discriminator. Must be "log" for log sources. (log) (example: log)
known_columns_list_expressionstringFor Distributed table sources whose target tables have non-matching column sets. A list of columns supported across all target tables, used instead of SELECT * when fetching full row data. Leave blank to select all columns. (example: Timestamp, Body, ServiceName) (wire: knownColumnsListExpression)
materialized_viewsarrayConfigure materialized views for query optimization. These pre-aggregated views can significantly improve query performance on aggregation queries. (wire: materializedViews)
metadata_materialized_viewsobject (wire: metadataMaterializedViews)
metric_tablesobject (wire: metricTables)
parent_span_id_expressionstringExpression to extract the parent span ID. (example: ParentSpanId) (wire: parentSpanIdExpression)
query_settingsarrayOptional ClickHouse query settings applied when querying this source. (wire: querySettings)
resource_attributes_expressionstringExpression to extract resource-level attributes. (example: ResourceAttributes) (wire: resourceAttributesExpression)
sectionstringOptional grouping label used to organize sources in the source selector. Sources that share a section value are displayed together. (example: Billing)
service_name_expressionstringExpression to extract the service name from log rows. (example: ServiceName) (wire: serviceNameExpression)
severity_text_expressionstringExpression to extract the severity/log level text. (example: SeverityText) (wire: severityTextExpression)
span_events_value_expressionstringExpression to extract span events. Used to capture events associated with spans. Expected to be Nested ( Timestamp DateTime64(9), Name LowCardinality(String), Attributes Map(LowCardinality(String), String) (example: Events) (wire: spanEventsValueExpression)
span_id_expressionstringExpression to extract the span ID for correlating logs with traces. (example: SpanId) (wire: spanIdExpression)
span_kind_expressionstringExpression to extract the span kind (e.g., client, server, internal). (example: SpanKind) (wire: spanKindExpression)
span_name_expressionstringExpression to extract the span name. (example: SpanName) (wire: spanNameExpression)
status_code_expressionstringExpression to extract the span status code. (example: StatusCode) (wire: statusCodeExpression)
status_message_expressionstringExpression to extract the span status message. (example: StatusMessage) (wire: statusMessageExpression)
timestamp_value_expressionstringDateTime column or expression that is part of your table's primary key. (example: Timestamp) (wire: timestampValueExpression)
trace_id_expressionstringExpression to extract the trace ID for correlating logs with traces. (example: TraceId) (wire: traceIdExpression)
use_text_index_for_implicit_columnstringControls whether lucene rendering uses ClickHouse text indices via hasAllTokens() against the implicit column. "auto" detects a covering index at query time, "enabled" forces text index usage, "disabled" forces a LIKE/hasToken fallback. (auto, enabled, disabled) (example: auto) (wire: useTextIndexForImplicitColumn)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectservice_id, click_stack_source_id, organization_idThis endpoint is in beta. API contract is stable, and no breaking changes are expected in the future. <br /><br /> ClickStack: Retrieves a specific source by ID
listselectservice_id, organization_idThis endpoint is in beta. API contract is stable, and no breaking changes are expected in the future. <br /><br /> ClickStack: Retrieves a list of all sources for the authenticated team
createinsertservice_id, organization_id, name, kind, connection, from, default_table_select_expression, timestamp_value_expression, duration_expression, duration_precision, trace_id_expression, span_id_expression, parent_span_id_expression, span_name_expression, span_kind_expression, metric_tables, resource_attributes_expression, trace_source_idThis endpoint is in beta. API contract is stable, and no breaking changes are expected in the future. <br /><br /> ClickStack: Creates a new source. The request body is a source object without the id field. If an id is sent anyway it is silently ignored (stripped before validation — the request is never rejected because of it). Granularity fields (materializedViews&#91;&#93;.minGranularity and metadataMaterializedViews.granularity) accept the same short format the API returns (e.g. 5m, 15s, 1h, 1d).
updateupdateservice_id, click_stack_source_id, organization_id, name, kind, connection, from, default_table_select_expression, timestamp_value_expression, duration_expression, duration_precision, trace_id_expression, span_id_expression, parent_span_id_expression, span_name_expression, span_kind_expression, metric_tables, resource_attributes_expression, trace_source_idThis endpoint is in beta. API contract is stable, and no breaking changes are expected in the future. <br /><br /> ClickStack: Updates an existing source. The full source object must be provided; this is a replace, not a patch. The request body is a source object without the id field. If an id is sent anyway it is silently ignored (stripped before validation — never a 400); the path parameter alone identifies the source. Granularity fields (materializedViews&#91;&#93;.minGranularity and metadataMaterializedViews.granularity) accept the same short format the API returns (e.g. 5m, 15s, 1h, 1d).
deletedeleteservice_id, click_stack_source_id, organization_idThis endpoint is in beta. API contract is stable, and no breaking changes are expected in the future. <br /><br /> ClickStack: Deletes a source

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
click_stack_source_idstringSource ID (wire: clickStackSourceId)
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)
service_idstring (uuid)ID of the ClickStack service. (wire: serviceId)

SELECT examples

This endpoint is in beta. API contract is stable, and no breaking changes are expected in the future. <br /><br /> ClickStack: Retrieves a specific source by ID

SELECT
id,
name,
log_source_id,
metric_source_id,
session_source_id,
trace_source_id,
body_expression,
connection,
default_table_select_expression,
disabled,
displayed_timestamp_value_expression,
duration_expression,
duration_precision,
event_attributes_expression,
filter_settings,
from,
highlighted_row_attribute_expressions,
highlighted_trace_attribute_expressions,
implicit_column_expression,
kind,
known_columns_list_expression,
materialized_views,
metadata_materialized_views,
metric_tables,
parent_span_id_expression,
query_settings,
resource_attributes_expression,
section,
service_name_expression,
severity_text_expression,
span_events_value_expression,
span_id_expression,
span_kind_expression,
span_name_expression,
status_code_expression,
status_message_expression,
timestamp_value_expression,
trace_id_expression,
use_text_index_for_implicit_column
FROM clickhouse.clickstack.sources
WHERE service_id = '{{ service_id }}' -- required
AND click_stack_source_id = '{{ click_stack_source_id }}' -- required
AND organization_id = '{{ organization_id }}' -- required unless CLICKHOUSE_ORG_ID is set
;

INSERT examples

This endpoint is in beta. API contract is stable, and no breaking changes are expected in the future. <br /><br /> ClickStack: Creates a new source. The request body is a source object without the id field. If an id is sent anyway it is silently ignored (stripped before validation — the request is never rejected because of it). Granularity fields (materializedViews&#91;&#93;.minGranularity and metadataMaterializedViews.granularity) accept the same short format the API returns (e.g. 5m, 15s, 1h, 1d).

INSERT INTO clickhouse.clickstack.sources (
id,
name,
section,
disabled,
kind,
connection,
from,
query_settings,
filter_settings,
default_table_select_expression,
timestamp_value_expression,
service_name_expression,
severity_text_expression,
body_expression,
event_attributes_expression,
resource_attributes_expression,
displayed_timestamp_value_expression,
metric_source_id,
trace_source_id,
trace_id_expression,
span_id_expression,
implicit_column_expression,
known_columns_list_expression,
use_text_index_for_implicit_column,
highlighted_trace_attribute_expressions,
highlighted_row_attribute_expressions,
materialized_views,
metadata_materialized_views,
duration_expression,
duration_precision,
parent_span_id_expression,
span_name_expression,
span_kind_expression,
log_source_id,
session_source_id,
status_code_expression,
status_message_expression,
span_events_value_expression,
metric_tables,
service_id,
organization_id
)
SELECT
'{{ id }}',
'{{ name }}' /* required */,
'{{ section }}',
{{ disabled }},
'{{ kind }}' /* required */,
'{{ connection }}' /* required */,
'{{ from }}' /* required */,
'{{ query_settings }}',
'{{ filter_settings }}',
'{{ default_table_select_expression }}' /* required */,
'{{ timestamp_value_expression }}' /* required */,
'{{ service_name_expression }}',
'{{ severity_text_expression }}',
'{{ body_expression }}',
'{{ event_attributes_expression }}',
'{{ resource_attributes_expression }}' /* required */,
'{{ displayed_timestamp_value_expression }}',
'{{ metric_source_id }}',
'{{ trace_source_id }}' /* required */,
'{{ trace_id_expression }}' /* required */,
'{{ span_id_expression }}' /* required */,
'{{ implicit_column_expression }}',
'{{ known_columns_list_expression }}',
'{{ use_text_index_for_implicit_column }}',
'{{ highlighted_trace_attribute_expressions }}',
'{{ highlighted_row_attribute_expressions }}',
'{{ materialized_views }}',
'{{ metadata_materialized_views }}',
'{{ duration_expression }}' /* required */,
{{ duration_precision }} /* required */,
'{{ parent_span_id_expression }}' /* required */,
'{{ span_name_expression }}' /* required */,
'{{ span_kind_expression }}' /* required */,
'{{ log_source_id }}',
'{{ session_source_id }}',
'{{ status_code_expression }}',
'{{ status_message_expression }}',
'{{ span_events_value_expression }}',
'{{ metric_tables }}' /* required */,
'{{ service_id }}',
'{{ organization_id }}'
RETURNING
request_id,
result,
status
;

UPDATE examples

This endpoint is in beta. API contract is stable, and no breaking changes are expected in the future. <br /><br /> ClickStack: Updates an existing source. The full source object must be provided; this is a replace, not a patch. The request body is a source object without the id field. If an id is sent anyway it is silently ignored (stripped before validation — never a 400); the path parameter alone identifies the source. Granularity fields (materializedViews&#91;&#93;.minGranularity and metadataMaterializedViews.granularity) accept the same short format the API returns (e.g. 5m, 15s, 1h, 1d).

UPDATE clickhouse.clickstack.sources
SET
id = '{{ id }}',
name = '{{ name }}',
section = '{{ section }}',
disabled = {{ disabled }},
kind = '{{ kind }}',
connection = '{{ connection }}',
from = '{{ from }}',
query_settings = '{{ query_settings }}',
filter_settings = '{{ filter_settings }}',
default_table_select_expression = '{{ default_table_select_expression }}',
timestamp_value_expression = '{{ timestamp_value_expression }}',
service_name_expression = '{{ service_name_expression }}',
severity_text_expression = '{{ severity_text_expression }}',
body_expression = '{{ body_expression }}',
event_attributes_expression = '{{ event_attributes_expression }}',
resource_attributes_expression = '{{ resource_attributes_expression }}',
displayed_timestamp_value_expression = '{{ displayed_timestamp_value_expression }}',
metric_source_id = '{{ metric_source_id }}',
trace_source_id = '{{ trace_source_id }}',
trace_id_expression = '{{ trace_id_expression }}',
span_id_expression = '{{ span_id_expression }}',
implicit_column_expression = '{{ implicit_column_expression }}',
known_columns_list_expression = '{{ known_columns_list_expression }}',
use_text_index_for_implicit_column = '{{ use_text_index_for_implicit_column }}',
highlighted_trace_attribute_expressions = '{{ highlighted_trace_attribute_expressions }}',
highlighted_row_attribute_expressions = '{{ highlighted_row_attribute_expressions }}',
materialized_views = '{{ materialized_views }}',
metadata_materialized_views = '{{ metadata_materialized_views }}',
duration_expression = '{{ duration_expression }}',
duration_precision = {{ duration_precision }},
parent_span_id_expression = '{{ parent_span_id_expression }}',
span_name_expression = '{{ span_name_expression }}',
span_kind_expression = '{{ span_kind_expression }}',
log_source_id = '{{ log_source_id }}',
session_source_id = '{{ session_source_id }}',
status_code_expression = '{{ status_code_expression }}',
status_message_expression = '{{ status_message_expression }}',
span_events_value_expression = '{{ span_events_value_expression }}',
metric_tables = '{{ metric_tables }}'
WHERE
service_id = '{{ service_id }}' --required
AND click_stack_source_id = '{{ click_stack_source_id }}' --required
AND organization_id = '{{ organization_id }}' --required unless CLICKHOUSE_ORG_ID is set
AND name = '{{ name }}' --required
AND kind = '{{ kind }}' --required
AND connection = '{{ connection }}' --required
AND from = '{{ from }}' --required
AND default_table_select_expression = '{{ default_table_select_expression }}' --required
AND timestamp_value_expression = '{{ timestamp_value_expression }}' --required
AND duration_expression = '{{ duration_expression }}' --required
AND duration_precision = '{{ duration_precision }}' --required
AND trace_id_expression = '{{ trace_id_expression }}' --required
AND span_id_expression = '{{ span_id_expression }}' --required
AND parent_span_id_expression = '{{ parent_span_id_expression }}' --required
AND span_name_expression = '{{ span_name_expression }}' --required
AND span_kind_expression = '{{ span_kind_expression }}' --required
AND metric_tables = '{{ metric_tables }}' --required
AND resource_attributes_expression = '{{ resource_attributes_expression }}' --required
AND trace_source_id = '{{ trace_source_id }}' --required
RETURNING
request_id,
result,
status;

DELETE examples

This endpoint is in beta. API contract is stable, and no breaking changes are expected in the future. <br /><br /> ClickStack: Deletes a source

DELETE FROM clickhouse.clickstack.sources
WHERE service_id = '{{ service_id }}' --required
AND click_stack_source_id = '{{ click_stack_source_id }}' --required
AND organization_id = '{{ organization_id }}' --required unless CLICKHOUSE_ORG_ID is set
;