npx skills add ...
npx skills add signoz/agent-skills --skill signoz-writing-clickhouse-queries
npx skills add signoz/agent-skills --skill signoz-writing-clickhouse-queries
Write raw ClickHouse SQL for a SigNoz dashboard panel — timeseries, value, or table widgets that the builder UI cannot express (custom joins, window functions, regex extraction over log bodies, aggregations beyond builder syntax). Trigger when the user explicitly asks for a "ClickHouse query", a "raw SQL panel", a "custom SQL widget", or describes a SigNoz dashboard panel whose query needs SQL the builder cannot produce. Anchored to dashboard-panel SQL specifically. For ad-hoc data exploration that does not need to land in a panel, use `signoz-generating-queries` instead.
Use this skill when the user asks for SigNoz queries involving:
If the user asks for a dashboard panel but does not mention ClickHouse, still use this skill.
Identify whether the request is about logs or traces.
If the request is ambiguous, ask the user to clarify.
references/clickhouse-logs-reference.md
before writing any query.references/clickhouse-traces-reference.md
before writing any query.Each reference covers table schemas, optimization patterns, attribute access syntax, dashboard templates, query examples, and a validation checklist.
(ts, value) for a chart over time.value for a stat or counter widget.UInt64 in nanoseconds.$start_timestamp_nano and $end_timestamp_nano.$start_timestamp and $end_timestamp.fromUnixTimestamp64Nano(timestamp).signoz_logs.distributed_logs_v2.signoz_logs.distributed_logs_v2_resource.DateTime64(9).$start_datetime and $end_datetime.$start_timestamp and $end_timestamp.signoz_traces.distributed_signoz_index_v3.signoz_traces.distributed_traces_v3_resource.ts_bucket_start BETWEEN $start_timestamp - 1800 AND $end_timestamp.IN / JOIN whose subquery reads a distributed table: with
distributed_product_mode='deny' it fails. Prefer the time-bounded fingerprint
GLOBAL IN pattern or a local subquery table. Use GLOBAL JOIN only for a
demonstrably small, bounded RHS; it broadcasts that dataset to every shard.GROUP BY, including computed
projections such as JSONExtractString(body, ...).$start_datetime or $end_datetime.$start_timestamp_nano or $end_timestamp_nano.signoz_logs.logs, bare logs, or distributed_logs;
always use signoz_logs.distributed_logs_v2.resources_string['service.name'] instead of
resource_string_service$$name.Every generated query MUST end with a SETTINGS clause for monitoring:
Replace YYYY-MM-DD with today's date (e.g., 2026-04-03). If the query
already has a SETTINGS clause, append log_comment to it with a comma.
SETTINGS log_comment attribution clause.