モニタリング、ロギング、オブザーバビリティ
ログを読み取り、主要なメトリクスを追跡し、Edge Functionsに計測を組み込み、アラートを設定して、小さな問題が障害になる前に本番Supabaseバックエンドを健全に保ちます。
「モニタリング、ロギング、オブザーバビリティ」はCoddyKit上の無料Supabase Backend as a Serviceレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはSupabase Backend as a Service学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Supabase Backend as a Serviceコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
Why Observability Matters
Deploying is only half the job. Once your backend serves real traffic you need to see what it is doing. Observability is the practice of understanding system state from its outputs.
- Logs tell you what happened
- Metrics tell you how much and how fast
- Traces tell you where time was spent
The Supabase Logs Explorer
Supabase exposes logs for every service in the dashboard under Logs: API gateway, Postgres, Auth, Storage, and Edge Functions. Each is queryable with SQL-like syntax.
Filtering by status code and path quickly surfaces failing requests.
Querying Logs
The Logs Explorer accepts SQL over structured log events. Here we count API errors grouped by path over the last hour.
select path, count(*) as errors
from edge_logs
where status_code >= 500
group by path
order by errors desc;Structured Logging in Edge Functions
Inside Edge Functions, prefer structured JSON logs over plain strings. They are far easier to filter and aggregate later.
console.log(JSON.stringify({
level: 'info',
event: 'order_created',
orderId: order.id,
userId: user.id,
durationMs: Date.now() - start
}));Log Levels
Use consistent levels so you can filter noise from signal.
debugfor development detailinfofor normal eventswarnfor recoverable problemserrorfor failures needing attention
In production, avoid logging at debug to control cost and volume.
Key Database Metrics
Watch a handful of Postgres metrics closely:
- Active connections vs the pool limit
- Cache hit ratio (aim above 99%)
- Slow query count
- Disk and CPU usage
Supabase surfaces these on the Reports page.
Finding Slow Queries
Enable pg_stat_statements to see which queries consume the most total time. This is the single most useful tool for performance triage.
select query, calls, mean_exec_time, total_exec_time
from pg_stat_statements
order by total_exec_time desc
limit 10;Never Log Secrets
Logs are persisted and often shared. Never write passwords, tokens, full card numbers, or service-role keys into logs.
- Redact sensitive fields before logging
- Log identifiers, not raw payloads
- Treat log access as a security boundary
Correlating Requests
Attach a request ID to every log line in a function so you can reconstruct a single request's full journey across logs.
const requestId = crypto.randomUUID();
console.log(JSON.stringify({ requestId, event: 'start' }));
// ... work ...
console.log(JSON.stringify({ requestId, event: 'done' }));Alerting
Logs you never look at help no one. Set up alerts for the conditions that matter: error-rate spikes, connection exhaustion, disk nearing capacity.
Forward logs to an external sink (e.g. via webhooks or a log drain) when you need richer alerting than the dashboard provides.
Retention and Cost
Logs cost money and storage. Decide a retention policy deliberately.
- Keep high-value audit logs longer
- Sample or drop chatty debug logs
- Archive to cheap storage before deletion if needed for compliance
Quick Check
Test your observability knowledge.
Recap
You now have a foundation for production observability.
- Use the Logs Explorer and structured JSON logs
- Apply consistent log levels and request IDs
- Track connections, cache hit ratio, and slow queries
- Use
pg_stat_statementsfor performance triage - Never log secrets; set alerts and a retention policy
AI チューターと学ぶ Supabase Backend as a Service — 無料
ブラウザでリアルコードを書いて実行し、24/7 の AI チューターから瞬時にサポートを受け、ウェブまたはアプリで続きから学習できます。
- コース
- 11
- レッスン
- 40
よくある質問
「モニタリング、ロギング、オブザーバビリティ」レッスンは無料ですか?
はい。「モニタリング、ロギング、オブザーバビリティ」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Supabase Backend as a Serviceコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Supabase Backend as a Serviceコースには全4レッスンが含まれています。
「モニタリング、ロギング、オブザーバビリティ」で何を学びますか?
ログを読み取り、主要なメトリクスを追跡し、Edge Functionsに計測を組み込み、アラートを設定して、小さな問題が障害になる前に本番Supabaseバックエンドを健全に保ちます。 ブラウザで直接実行するハンズオンコードでSupabase Backend as a Serviceを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Supabase Backend as a Serviceを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのSupabase Backend as a Serviceは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。
「モニタリング、ロギング、オブザーバビリティ」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このSupabase Backend as a Serviceレッスンでコードを書いて実行できますか?
はい。すべてのSupabase Backend as a Serviceレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- 環境管理とCI/CD
- バックアップ、リストア、ディザスタリカバリ
- セキュリティ監査とベストプラクティス
- モニタリング、ロギング、オブザーバビリティ