0Pricing
Supabase Backend as a Service · Lección

Monitorización, registros y observabilidad

Mantenga saludable un backend de Supabase en producción leyendo registros, siguiendo métricas clave, instrumentando Edge Functions y configurando alertas antes de que pequeños problemas se conviertan en interrupciones del servicio.

Monitorización, registros y observabilidad es una lección gratuita de Supabase Backend as a Service en CoddyKit. Esta es la lección 4 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Supabase Backend as a Service, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Supabase Backend as a Service incluye 4 lecciones en total.

Partes de esta lección aún no han sido traducidas y se muestran en inglés.

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.

  • debug for development detail
  • info for normal events
  • warn for recoverable problems
  • error for 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_statements for performance triage
  • Never log secrets; set alerts and a retention policy

Preguntas frecuentes

¿La lección «Monitorización, registros y observabilidad» es gratis?

Sí — el texto completo de «Monitorización, registros y observabilidad» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Supabase Backend as a Service, actualiza a CoddyKit PRO. El curso de Supabase Backend as a Service incluye 4 lecciones en total.

¿Qué aprenderé en «Monitorización, registros y observabilidad»?

Mantenga saludable un backend de Supabase en producción leyendo registros, siguiendo métricas clave, instrumentando Edge Functions y configurando alertas antes de que pequeños problemas se conviertan… Practicas Supabase Backend as a Service con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.

¿Necesito experiencia previa para empezar Supabase Backend as a Service?

No se requiere experiencia previa. Supabase Backend as a Service en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 4 de 4.

¿Cuánto tiempo toma la lección «Monitorización, registros y observabilidad»?

La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.

¿Puedo escribir y ejecutar código en esta lección de Supabase Backend as a Service?

Sí. Cada lección de Supabase Backend as a Service incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.

Todas las lecciones de este curso

  1. Gestión de entornos y CI/CD
  2. Copias de seguridad, restauración y recuperación ante desastres
  3. Auditoría de seguridad y buenas prácticas
  4. Monitorización, registros y observabilidad
← Volver a Supabase Backend as a Service