Files
supabase/apps/docs/content/guides/storage/debugging/logs.mdx
T
Ali WaseemandJordi Enric 01d12e83c1 docs: migrate logs queries to ClickHouse and link to the SQL Editor (#49273)
The 47 BigQuery-era logs queries across these 20 pages error on the
ClickHouse-backed logs engine ("Backend error! Retry your query."). This
converts them per the rules in `apps/studio/lib/ai/clickhouse-logs.ts`
and repoints every Logs Explorer link at the SQL Editor with the query
source set to **Logs**, since the Logs Explorer is being retired. Also
fixes two stale PostgreSQL 12 links in the tables guide.

Each of the 14 prefilled links was verified to decode back to exactly
the SQL shown on its page. One caveat for review:
`response.headers.proxy_status` in `postgrest-error-codes.mdx` is
unverified — it isn't in the published field reference, and the test
project had no `edge_logs` traffic to confirm against.

Fixes DOCS-1331

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Documentation**
- Updated database, storage, API, and Edge Function logging guides to
use the SQL Editor and current Logs interface.
- Replaced legacy Log Explorer and BigQuery examples with current query
syntax and structured log fields.
- Refreshed troubleshooting queries for error diagnosis, filtering,
aggregation, and performance analysis.
- Improved examples with clearer source filters, status handling,
request details, joins, and result limits.
- Updated PostgreSQL documentation links and clarified how API error
codes appear in responses.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Jordi Enric <jordi.err@gmail.com>
2026-08-20 17:07:25 +02:00

75 lines
2.1 KiB
Plaintext

---
id: 'storage-logs'
title: 'Logs'
description: 'Learn how to check Storage Logs'
sidebar_label: 'Debugging'
---
The [Storage Logs](/dashboard/project/_/logs/storage-logs) provide a convenient way to examine all incoming request logs to your Storage service. You can filter by time and keyword searches.
For more advanced filtering needs, use the [SQL Editor](/dashboard/project/_/sql/new?skip=true&source=logs) with the query source set to **Logs** to query the Storage logs directly. A Logs query runs ClickHouse SQL rather than Postgres SQL. Every log line is a row in the `logs` table, tagged by a `source` column, with structured fields in a `log_attributes` map.
<Admonition type="note">
For more details on filtering the log tables, see [Advanced Log Filtering](/docs/guides/monitoring-and-debugging/advanced-log-filtering)
</Admonition>
## Example Storage queries
### Filter by status 5XX error
```sql
select
id,
timestamp,
event_message,
toInt32OrZero(log_attributes['res.statusCode']) as statusCode,
log_attributes['error.message'] as errorMessage,
log_attributes['error.raw'] as rawError
from logs
where source = 'storage_logs'
and toInt32OrZero(log_attributes['res.statusCode']) >= 500
order by timestamp desc
limit 100;
```
### Filter by status 4XX error
```sql
select
id,
timestamp,
event_message,
toInt32OrZero(log_attributes['res.statusCode']) as statusCode,
log_attributes['error.message'] as errorMessage,
log_attributes['error.raw'] as rawError
from logs
where source = 'storage_logs'
and toInt32OrZero(log_attributes['res.statusCode']) between 400 and 499
order by timestamp desc
limit 100;
```
### Filter by method
```sql
select id, timestamp, event_message, log_attributes['req.method'] as method
from logs
where source = 'storage_logs'
and log_attributes['req.method'] in ('POST')
order by timestamp desc
limit 100;
```
### Filter by IP address
```sql
select id, timestamp, event_message, log_attributes['req.remoteAddress'] as remoteAddress
from logs
where source = 'storage_logs'
and log_attributes['req.remoteAddress'] in ('IP_ADDRESS')
order by timestamp desc
limit 100;
```