0Pricing
Supabase Backend as a Service · درس

المراقبة والتسجيل وقابلية الرصد

حافظ على صحة واجهة Supabase الخلفية في بيئة الإنتاج عبر قراءة السجلات، وتتبع المقاييس الأساسية، وإضافة أدوات القياس إلى Edge Functions، وإعداد التنبيهات قبل أن تتحول المشكلات الصغيرة إلى أعطال.

المراقبة والتسجيل وقابلية الرصد درس مجاني في Supabase Backend as a Service على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في 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.

  • 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

الأسئلة الشائعة

هل درس «المراقبة والتسجيل وقابلية الرصد» مجاني؟

نعم — نص درس «المراقبة والتسجيل وقابلية الرصد» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Supabase Backend as a Service، انتقل إلى CoddyKit PRO. تتضمن دورة Supabase Backend as a Service 4 دروس في المجموع.

ماذا ستتعلم في «المراقبة والتسجيل وقابلية الرصد»؟

حافظ على صحة واجهة Supabase الخلفية في بيئة الإنتاج عبر قراءة السجلات، وتتبع المقاييس الأساسية، وإضافة أدوات القياس إلى Edge Functions، وإعداد التنبيهات قبل أن تتحول المشكلات الصغيرة إلى أعطال. تتمرن على Supabase Backend as a Service مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Supabase Backend as a Service؟

لا تُشترط خبرة سابقة. Supabase Backend as a Service على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.

كم من الوقت يستغرق درس «المراقبة والتسجيل وقابلية الرصد»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Supabase Backend as a Service هذا؟

نعم. كل درس في Supabase Backend as a Service يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. إدارة البيئات وCI/CD
  2. النسخ الاحتياطي والاستعادة والتعافي من الكوارث
  3. تدقيق الأمان وأفضل الممارسات
  4. المراقبة والتسجيل وقابلية الرصد
← العودة إلى Supabase Backend as a Service