Monitoring, Logging und Observability
Halten Sie ein produktives Supabase-Backend gesund, indem Sie Logs auswerten, wichtige Metriken verfolgen, Edge Functions instrumentieren und Alarme einrichten, bevor kleine Probleme zu Ausfällen führen.
Monitoring, Logging und Observability ist eine kostenlose Supabase Backend as a Service-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Supabase Backend as a Service-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Supabase Backend as a Service-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
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
Lerne Supabase Backend as a Service mit einem KI-Tutor — kostenlos
Schreibe und führe echten Code in deinem Browser aus, bekomme sofortige Hilfe von einem 24/7 KI-Tutor und setze dein Lernen im Web oder in der App fort.
- Kurse
- 11
- Lektionen
- 40
Häufig gestellte Fragen
Ist die Lektion „Monitoring, Logging und Observability“ kostenlos?
Ja — der vollständige Text von „Monitoring, Logging und Observability“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Supabase Backend as a Service-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Supabase Backend as a Service-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Monitoring, Logging und Observability“?
Halten Sie ein produktives Supabase-Backend gesund, indem Sie Logs auswerten, wichtige Metriken verfolgen, Edge Functions instrumentieren und Alarme einrichten, bevor kleine Probleme zu Ausfällen füh… Du übst Supabase Backend as a Service mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um Supabase Backend as a Service zu starten?
Keine Vorkenntnisse erforderlich. Supabase Backend as a Service auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.
Wie lange dauert die Lektion „Monitoring, Logging und Observability“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser Supabase Backend as a Service-Lektion Code schreiben und ausführen?
Ja. Jede Supabase Backend as a Service-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Umgebungsverwaltung und CI/CD
- Backup, Wiederherstellung und Disaster Recovery
- Sicherheitsaudits und Best Practices
- Monitoring, Logging und Observability