Automated summary
Writes, reviews, and migrates SQL queries against Supabase's ClickHouse-backed `logs` table (the `logs.all.otel` endpoint), including BigQuery translation and Studio codebase wiring.
Strengths
- Documents the column model precisely (`source`, `log_attributes`, microsecond UTC `timestamp`) along with the available log sources such as edge_logs, postgres_logs, and auth_logs
- Ships a dedicated reference for translating legacy BigQuery `cross join unnest(metadata)` queries into ClickHouse
- Covers both real use cases: authoring a Logs Explorer query and wiring analytics SQL into `apps/studio/data/logs` and the Settings/Logs components
- Enforces clear conventions: a leading comment naming the query, filtering on `source`, and always limiting results
Limitations
- The per-source field list is not exhaustive, so keys must be confirmed via the Field Reference drawer or by discovering them from real data
- Tightly scoped to Supabase logs and its analytics endpoint, so it transfers poorly to a generic ClickHouse cluster
- The Logs Explorer applies the selected time range automatically, so hand-written `timestamp` filters are often unnecessary and not representative outside that UI
Reach for it whenever a task involves Logs Explorer SQL, the `log_attributes` map, a log `source`, or converting an existing BigQuery logs query.
Avoid it for designing a general-purpose ClickHouse schema or for logging stacks other than Supabase's.
Security analysis
SafeThis is pure documentation/instructional content: SQL examples, schema tables, and guidance on ClickHouse field access for Supabase logs. There is no executable tooling, no shell commands, no network calls, no credential handling, and no obfuscated payloads. The only tools implied are read-only SQL queries against a logs table, and the examples are non-destructive (selects with limits). No declared allowed-tools, so no privileged capability is being granted.
No concerns found
How this analysis is madeExamples
Write me a Logs Explorer query that returns the 100 most recent postgres_logs entries with their timestamp and event_message, newest first.Convert this old BigQuery logs query to ClickHouse for the Supabase logs table: select timestamp, event_message, m.severity from edge_logs cross join unnest(metadata) as m limit 100.Add a branded analytics logs query for auth_logs in apps/studio/data/logs and hook it up in the Settings/Logs interface.name: clickhouse-logs-queries
description: >-
Write, review, and migrate Supabase logs queries against the ClickHouse-backed
logs table (the logs.all.otel analytics endpoint). Use this whenever a task
involves Logs Explorer SQL, the log_attributes map, querying a log source
(edge_logs, postgres_logs, auth_logs, etc.), translating an old BigQuery
cross join unnest(metadata) logs query to ClickHouse, or wiring analytics log
SQL in apps/studio/data/logs and apps/studio/components/interfaces/Settings/Logs.
Reach for it even when the user just says "logs query", "Logs Explorer", or
pastes a BigQuery logs query to convert, not only when they name ClickHouse.
Querying Supabase logs (ClickHouse)
Supabase logs live in a single ClickHouse logs table, served by the
logs.all.otel analytics endpoint. Every log line from every part of the stack
is one row in this table, tagged by a source column. This replaces the older
BigQuery model, where each service had its own table and fields were reached
through cross join unnest(metadata).
Two kinds of work use this skill, and they share the same SQL model:
- Writing or reviewing a logs query (in the Logs Explorer or anywhere a raw ClickHouse logs query is needed). Start here in this file.
- Wiring a logs query in the Studio codebase (branded analytics SQL, the endpoint picker, the OTEL query builders). Read references/codebase-integration.md.
If you are converting an existing BigQuery logs query, read references/bigquery-migration.md for the full translation table.
The logs table
Each row has a small set of real columns. Everything specific to a service lives
in log_attributes.
| Column | Type | Notes |
| ---------------- | --------------------- | ----------------------------------------------------- |
| id | String | Unique log identifier. |
| timestamp | DateTime64 (UTC) | When the log was produced. Order/compare it directly. |
| event_message | String | The raw log line. |
| severity_text | String | Log level, when the source sets one. |
| source | String | The service the log came from. Always filter on this. |
| log_attributes | Map(String, String) | Structured per-source fields, keyed by a dotted path. |
timestamp is formatted like 2026-06-22T09:34:06.215000 (ISO 8601, microsecond
precision, no trailing Z). In the Logs Explorer the selected time range is
applied for you, so you rarely need to write a timestamp filter by hand.
A minimal, well-formed query. Lead with a comment naming the query, filter by
source, and always limit:
-- recent edge requests
select timestamp, event_message
from logs
where source = 'edge_logs'
order by timestamp desc
limit 100;
Sources
source selects the service. The common ones:
edge_logs— API gateway requests and responsespostgres_logs— database statements and errors (also where pg_cron logs live)auth_logs— authentication and authorization activityfunction_edge_logs— edge function requests and responsesfunction_logs—consoleoutput from inside edge functionsstorage_logs— object upload and retrieval activityrealtime_logs— Realtime client connectionspostgrest_logs,supavisor_logs,pgbouncer_logs— mostlyid,timestamp,event_message
The Logs Explorer Field Reference drawer lists every source and the fields it actually sets. When in doubt about a key, discover it from real data rather than guessing (see below).
Reading fields from log_attributes
log_attributes maps a string key to a string value. Read a field with bracket
access. There are no unnesting joins:
select
log_attributes['request.method'] as method,
log_attributes['request.path'] as path,
log_attributes['response.status_code'] as status
from logs
where source = 'edge_logs'
The key keeps the dotted path that BigQuery expressed through nested structs, with
the metadata root dropped: BigQuery metadata.request.method becomes
log_attributes['request.method']. Keep the full prefix — request.cf.country
is log_attributes['request.cf.country'], not log_attributes['cf.country'].
Common keys by source:
edge_logs:request.method,request.path,request.search,response.status_code,identifierpostgres_logs:parsed.error_severity,parsed.detail,parsed.hint,parsed.query,identifierauth_logs:level,status,path,msg,errorfunction_edge_logs:response.status_code,request.method,request.pathname,function_id,execution_id,execution_time_msfunction_logs:event_type,function_id,execution_id,level
Numeric fields are strings
Map values are always strings. To compare or aggregate a numeric field, wrap it in
toInt32OrZero, which returns 0 for missing or non-numeric values so it never
errors on partial data:
select count() as server_errors
from logs
where source = 'edge_logs'
and toInt32OrZero(log_attributes['response.status_code']) between 500 and 599
Discover the keys a source sets
Read mapKeys from recent rows rather than guessing key names:
select arrayJoin(mapKeys(log_attributes)) as key, count() as n
from logs
where source = 'postgres_logs'
group by key
order by n desc
limit 100;
arrayJoin(mapKeys(...)) flattens the map keys into one row per key so you can
rank them by frequency. (The Studio codebase does exactly this for the Field
Reference drawer and to feed real keys to the AI rewrite.)
ClickHouse vs BigQuery functions
These are the substitutions that trip people up most:
| Need | BigQuery | ClickHouse |
| ------------------ | ----------------------------- | -------------------------------------------- |
| Count rows | count(*) | count() |
| Regex match | regexp_contains(x, 'p') | match(x, 'p') |
| Substring match | x like '%p%' | x ilike '%p%' (case-insensitive) or like |
| Numeric coercion | cast(x as int64) | toInt32OrZero(x) |
| Read the timestamp | cast(timestamp as datetime) | timestamp (use the column directly) |
| Map keys | n/a (used unnest) | mapKeys(log_attributes) |
The logs.all.otel analytics endpoint (and the Logs Explorer on top of it)
rejects count(*) and select * — use count() and list the columns you need.
(Raw ClickHouse supports both; this is a constraint of the logs query surface.)
Best practices
These keep queries correct and cheap. Log tables are large; an unbounded scan reads far more data than you need.
- Start every query with an identifying comment (e.g.
-- errors since last deploy). It labels the query in logs and review, and makes each of several queries in a file easy to tell apart. - Always include a
LIMIT. Even for aggregates while you iterate. - Always query
from logs where source = '...'. There is no per-service table (noedge_logs,postgres_logs, etc. table) — there is onelogstable, andsourcescopes it to a service. Filtering bysourceis required, not just an optimization. - Keep the time range tight. A smaller window returns results faster.
- Filter on the real columns (
source,timestamp) before reaching intolog_attributes. - Order by
timestamp descto see the most recent logs first. - Use
count(), notcount(*)orselect *.
Worked examples
Requests by status code:
select
toInt32OrZero(log_attributes['response.status_code']) as status,
count() as count
from logs
where source = 'edge_logs'
group by status
order by count desc
limit 50
Auth errors:
select timestamp, event_message, log_attributes['msg'] as message
from logs
where source = 'auth_logs'
and log_attributes['level'] in ('error', 'fatal')
order by timestamp desc
limit 100
Search the raw message:
select timestamp, event_message
from logs
where source = 'postgres_logs'
and event_message ilike '%deadlock%'
order by timestamp desc
limit 100
Postgres errors grouped by severity (the canonical unnest-to-map conversion):
select log_attributes['parsed.error_severity'] as severity, count() as count
from logs
where source = 'postgres_logs'
and log_attributes['parsed.error_severity'] in ('ERROR', 'FATAL', 'PANIC')
group by severity
order by count desc
limit 100
When the user pastes a BigQuery query
Convert it rather than running it as-is. The mechanical steps (drop the
per-service table for from logs where source = ..., remove every
cross join unnest(...), rewrite unnest-alias columns as log_attributes['...']
lookups, swap the functions above) are spelled out with a full before/after in
references/bigquery-migration.md. The Logs
Explorer also has a built-in Rewrite to ClickHouse action that does this with
AI; point users to it for one-off conversions in the dashboard.
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/supabase-logs-queries-clickhouse-mte1lfx2/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/supabase-logs-queries-clickhouse-mte1lfx2' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/supabase-logs-queries-clickhouse-mte1lfx2/download' --output '.skill-downloads/supabase-logs-queries-clickhouse-mte1lfx2/SKILL.md.part' && mv '.skill-downloads/supabase-logs-queries-clickhouse-mte1lfx2/SKILL.md.part' '.skill-downloads/supabase-logs-queries-clickhouse-mte1lfx2/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/supabase-logs-queries-clickhouse-mte1lfx2/SKILL.md' && test -s '.skill-downloads/supabase-logs-queries-clickhouse-mte1lfx2/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/clickhouse-logs-queries' && cp -R '.skill-downloads/supabase-logs-queries-clickhouse-mte1lfx2' '.claude/skills/clickhouse-logs-queries'Cursor
test -f '.skill-downloads/supabase-logs-queries-clickhouse-mte1lfx2/SKILL.md' && test -s '.skill-downloads/supabase-logs-queries-clickhouse-mte1lfx2/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/clickhouse-logs-queries' && cp -R '.skill-downloads/supabase-logs-queries-clickhouse-mte1lfx2' '.cursor/skills/clickhouse-logs-queries'Codex
test -f '.skill-downloads/supabase-logs-queries-clickhouse-mte1lfx2/SKILL.md' && test -s '.skill-downloads/supabase-logs-queries-clickhouse-mte1lfx2/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/clickhouse-logs-queries' && cp -R '.skill-downloads/supabase-logs-queries-clickhouse-mte1lfx2' '.agents/skills/clickhouse-logs-queries'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/supabase-logs-queries-clickhouse-mte1lfx2'openskills read 'supabase-logs-queries-clickhouse-mte1lfx2'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/supabase-logs-queries-clickhouse-mte1lfx2/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
Configure a Chat Channel with SecretRefs
DevOps
Set up chat channels using non-interactive commands, with secrets only as SecretRefs. Covers gather, mutate, repair, and prove steps for reliable delivery.
Investigate ClickHouse CI Failures
DevOps
Investigate a ClickHouse CI failure end-to-end from a PR or S3 report URL. Fetches failed tests, classifies flaky vs real regression, and checks for existing issues/fixes.
Ansible PR Review
DevOps
Reviews an Ansible PR following the project's standardized process, including changelog checks, test coverage validation, and feedback tracking.