অবজারভেবিলিটি
metrics, logs, traces, SLO/error budget আর symptom-based alert।
Start with the production incident, then the design decision that fixes it.
বৃহস্পতিবার রাতে ইউজাররা "ride book হচ্ছে না" বলছে, কিন্তু ড্যাশবোর্ডে CPU ৩৫%, memory ৪০%, সব সবুজ। নুসরাত ৪০ মিনিট ধরে log grep করছে; শেষে দেখা গেল payment service-এর p99 ৮ সেকেন্ড, কিন্তু কোনো alert ছিল না—শুধু CPU alert ছিল। মাহিন বলল, "আমরা সিস্টেমের স্বাস্থ্য দেখছি, ইউজারের ব্যথা দেখছি না।"
Observability মানে বাইরে থেকে ভিতরের অবস্থা বোঝার ক্ষমতা—শুধু "সার্ভার বেঁচে আছে" নয়, "কোন request কেন ধীর, কোথায় আটকেছে, কতজনের ক্ষতি হচ্ছে"। তিনটা স্তম্ভ: metrics (সংখ্যা), logs (ঘটনা), traces (এক request-এর path)। alert ইউজারের SLO-তে বসাও, CPU-তে নয়।
Metrics। Counter (request total), gauge (queue depth), histogram (latency distribution)। p50/p95/p99 percentile histogram থেকে; average নয়। Cardinality বিপদ—user_id দিয়ে label করলে metric explode করবে; bounded label (route, status, region) রাখো।
Logs। Structured JSON, request_id/trace_id সহ; error log-এ stack, input, user impact। Log volume বাজেট রাখো; debug log production-এ নয়।
Traces। Distributed tracing এক request-এর service-to-service span দেখায়; কোন hop ৮ সেকেন্ড নিল তৎক্ষণাৎ বোঝা যায়। Sampling (১–১০%) খরচ কমায়, কিন্তু ১০০% error trace রাখো।
RED/USE। Service-এর জন্য RED: Rate, Errors, Duration। Resource-এর জন্য USE: Utilization, Saturation, Errors। প্রতি service-এ RED, প্রতি host/DB-তে USE।
SLO/error budget। SLO ৯৯.৯% মানে মাসে ~৪৩ মিনিট। Error budget শেষ হলে feature freeze; alert burn-rate-এ (১ ঘণ্টায় ১৪.৪x burn) দাও, শুধু "p95 > ৫০০ms একবার" নয়।
Alerting। Symptom-based: 5xx rate, p99 latency, queue oldest age, payment failure। Cause-based (CPU high) শুধু capacity planning-এ। প্রতিটা alert-এ runbook/link থাকুক, নইলে on-call অন্ধ।
| সংকেত | প্রশ্নের উত্তর | উদাহরণ |
|---|---|---|
| Metric | কতটা/কত দ্রুত? | RPS, p99, error % |
| Log | কী ঘটল? | timeout, stack, input |
| Trace | কোথায় সময় গেল? | DB span ৪.২s |
| SLO | ইউজার খুশি? | ৯৯.৯% success |
| Alert | কে এখনই কাজ করবে? | burn-rate ১৪x |
Prometheus-ধাঁচের SLO query আর error-budget হিসাব:
# success ratio over 30 days
sum(rate(http_requests_total{status!~"5.."}[30d]))
/
sum(rate(http_requests_total[30d]))
# p99 latency
histogram_quantile(0.99,
sum by (le, route) (rate(http_request_duration_seconds_bucket[5m]))
)
SLO = 0.999
window_seconds = 30 * 24 * 3600
allowed_bad = window_seconds * (1 - SLO)
observed_bad = 1200 # 5xx + timeouts in the window
print("budget_seconds", allowed_bad, "bad_seconds", observed_bad)
print("burn_rate", observed_bad / allowed_bad)
Burn rate ১-এর নিচে থাকলে SLO ঠিক; ১৪.৪x এক ঘণ্টায় মানে বাজেট শেষ হবে ~২ দিনে। Alert burn-rate-এ, শুধু raw 5xx count-এ নয়।
১. SLO লিখো। কোন user journey, কত % success, p95 কত ms, ৩০ দিনে। "দ্রুত" নয়, সংখ্যা।
২. RED metric বসাও। প্রতি route-এ rate/errors/duration histogram; bounded labels; trace_id log-এ।
৩. Trace sampling। ১–১০% normal, ১০০% error/slow; tail-based sampling হলে ভালো।
৪. Dashboard সাজাও। প্রথম row: SLO burn, p99, 5xx, queue oldest; নিচে resource USE। এক পাতায় ৫০ গ্রাফ নয়।
৫. Alert + runbook। Burn-rate, queue age, payment failure; প্রতিটায় owner, link, first action। Alert fatigue এড়াতে cause-based alert কমাও।
৯৯.৯% SLO, ৩০ দিনে allowed bad = ২,৫৯২ সেকেন্ড। চলো-তে observed bad ১,২০০ সেকেন্ড। burn rate কত? ১ ঘণ্টায় ৫,০০০ bad request এলে বাজেট কত দ্রুত শেষ হবে? কাগজে হিসাব করো, তারপর ঠিক করো alert কোন threshold-এ বসবে।
Log-এ PII/secret লিখো না; trace_id দিয়ে correlate করো। Metric cardinality প্রতি user_id-তে বাড়ালে Prometheus মরে যাবে—bounded label রাখো। Alert-এর সংখ্যা কমাও, কিন্তু queue oldest age আর payment failure কখনো বাদ দিও না; এগুলোই আসল ইউজার-ব্যথা।
See the mental model first — the animation and the steps below it say the same thing.
Concept visual
লেবেলের কার্ডিনালিটি বাড়লে খরচ O(n²)-এ বাড়ে, তাই SLO-তে alert আর লেবেল ছোট রাখো।
Write a short design on paper or in a note, then compare it with the rubric. This is not a judge submission.
Design practice
CPU ৩৫%, কিন্তু payment p99 ৮s; কোনো alert নেই।
One timed attempt. Solve every problem to earn the module badge.
Final checkpoint
Ready to prove this module?
Ask questions, share an approach or leave a study tip for this lesson.
Was this lesson helpful?
Your reaction helps other learners judge these notes.
0 comments
Sign in to ask a question or share an approach.
Sign in to commentNo comments yet
Be the first to ask a question or leave a study tip.
| প্রশ্ন | উত্তর |
|---|
| Latency? | p95/p99 histogram |
| Service health? | RED |
| Resource? | USE |
| Error budget? | (1-SLO) × window |
| Alert? | burn-rate + symptom |
| Trace? | sample + 100% errors |