Ravindra BagaleCourses & study guides English Track your progress

Serverless Observability: X-Ray, Powertools आणि Structured Logs

पार्सल हरवले की प्रत्येक गोदामात tracking number. Serverless observability = structured logs, metrics, X-Ray + correlation id. SSH नाही — hop शोधा.

या chapter मध्ये तुम्ही काय शिकाल

  • JSON logs
  • EMF metrics
  • X-Ray
  • Alarms
  • CW link

1. रोजचे उदाहरण: कुरिअर tracking

Fatima (MAD) tracking. Diego (BRL) checkout: APIGW → Lambda → DDB. Correlation id नसेल तर Black Friday अंधुक.

Depth: CloudWatch; compute: Lambda. इथे serverless observe pattern.

2. का?

हे का लागतं?

SSH नाही. Short-lived. Retries मध्ये failure लपते. Day one observe — 2 AM नंतर नव्हे.

हे काय आहे?

Serverless observability = logs + metrics + traces + alarms + correlation ids.

3. Vertical diagram

Request -> API -> Lambda -> deps -> Telemetry -> Alarmएक correlation id
Alarm + runbook
Client request + correlation id API Gateway access logs Lambda structured logs EMF metrics / Powertools X-Ray service map CloudWatch alarms -> SNS/page Runbook link in alarm description
Telemetry path from edge to page.

4. How: MVO

कसं करायचं (step by step)

  1. JSON fields.
  2. X-Ray on.
  3. Business metrics.
  4. Core alarms.
  5. Runbook in alarm.
  6. Redact PII.

5. Commands + meaning

Tail logs

aws logs tail /aws/lambda/checkout-api --region ap-south-1 --since 10m --format short

अर्थ: Incident साठी जलद view.

X-Ray summary

aws xray get-service-graph --region ap-south-1 \
  --start-time $(date -u -d '30 minutes ago' +%s) \
  --end-time $(date -u +%s) \
  --query 'Services[].{N:Name,E:RootSummaryStatistics.ErrorCount}' 

अर्थ: कुठला hop error.

Alarm sketch

aws cloudwatch describe-alarms --region ap-south-1 \
  --alarm-name-prefix checkout --max-records 10 \
  --query 'MetricAlarms[].{N:AlarmName,S:StateValue}' 

अर्थ: Staging मध्ये alarm state.

Filter orderId

aws logs filter-log-events --region ap-south-1 \
  --log-group-name /aws/lambda/checkout-api \
  --filter-pattern '{ $.orderId = "ord-7841" }' --limit 20 

अर्थ: JSON orderId असेल तरच.

6. Powertools

  • Logger bind.
  • Tracer outbound.
  • Cold start metric.
  • Idempotency util.

7. Alarms

SignalPage?Notes
ErrorsYes userProbes
ThrottlesYesHeadroom
DLQ moneyYesNotify ticket
IteratorAgeYes streamsStale
p99SLOCold link

8. Industries

  • Fintech corr.
  • Ecommerce.
  • PHI redact.
  • Logistics hubs.
  • SaaS tenant.

9. Lab

10. Lab - logs/alarm

Org block नसेल तर ap-south-1 (Mumbai). आधी budget alert.

कसं करायचं (step by step)

  1. JSON log.
  2. X-Ray map.
  3. Alarm+SNS.
  4. Runbook 5 lines.

Cleanup (billing थांबवा)

  1. Cleanup alarm.
  2. X-Ray off.

11. एकाच pattern — वेगवेगळ्या industries

  • Fintech (Aisha, Lagos): payment webhooks → SQS → Lambda.
  • Ecommerce (Rohan, Pune): checkout API; inventory SNS fan-out.
  • Healthcare (Mei, Singapore): SNS SMS; PHI + fine-grained IAM.
  • EdTech (Diego, São Paulo): EventBridge nightly cleanup.
  • Logistics (Fatima, Casablanca): EventBridge + saga.
  • Media (Kenji, Osaka): S3 → Lambda thumbs + fan-out.
  • SaaS (Priya, Bengaluru): Cognito + per-tenant partition.
  • Gov (Omar, Amman): strangler fig per form route.

12. Troubleshooting checklist

  1. Region confirm करा.
  2. CloudWatch Logs + request id.
  3. Execution role permissions.
  4. DLQ + oldest message age.
  5. curl -v + CORS.
  6. SFN event history.
  7. Linked chapter पुन्हा वाचा.
  8. Cost: concurrency/retries.

13. सामान्य errors आणि fixes

प्रत्येक row = खरी चूक. Panic करण्याआधी fix वाचा.

Error / लक्षणFix
Text soupJSON.
X-Ray emptyEnable+IAM.
FlappingPeriod.
PIIRedact.
Lost orderPropagate.
No metricsEMF flush.
Trace costSampling.
Email stormSeverity.
Wrong regionRegion.

14. FAQ

प्र. Powertools must?

Recommended.

प्र. OTel?

One story.

प्र. Retention?

Cost vs compliance.

प्र. CW link?

CW chapter.

प्र. Async?

DLQ+age.

15. Interview Q&A (Beginner / Mid / Senior + MNC)

प्र. Beginner corr

Same id.

प्र. Structured

JSON.

प्र. EMF

Logs→metrics.

प्र. Alarm what

Core four.

प्र. Senior sample

Enough not all.

प्र. MNC

Retention+runbook.

16. Tips — English, मराठी आणि हिंदी

Ravindra Bagale's Tip (EN)

No SSH: your tracking number is the correlation id across logs, metrics and traces.

Ravindra Bagale's Tip (MR)

SSH नाही: tracking = correlation id.

Tip (HI)

SSH नहीं: ट्रैकिंग नंबर = correlation id।

घरी करून बघा

  1. orderId log.
  2. 3 alarms.

थोडक्यात सांगायचं तर

  1. गोष्टी पासून सुरू, मग services.
  2. Existing chapters link — labs copy नको.
  3. Failure साठी design.
  4. Measure → मग पैसे.

17. Architecture decision checklist

  1. User journey 5 bullets, no AWS names.
  2. Sync vs async mark.
  3. Failure mode.
  4. Idempotency key.
  5. Data from access patterns.
  6. Cost 1x and 10x.
  7. Quotas ap-south-1.
  8. Auth decision.
  9. On-call + alarm.
  10. Deep chapter link.
  11. मग console/IaC.

18. Copy-paste quick commands

# Region and identity
aws configure get region
aws sts get-caller-identity

# Lambda landscape
aws lambda list-functions --region ap-south-1 --max-items 20 \
  --query 'Functions[].{N:FunctionName,R:Runtime,T:Timeout,M:MemorySize}' --output table
aws lambda get-account-settings --region ap-south-1

# API Gateway (HTTP APIs)
aws apigatewayv2 get-apis --region ap-south-1 --query 'Items[].{N:Name,Id:ApiId,Ep:ProtocolType}' --output table

# Queues and topics
aws sqs list-queues --region ap-south-1
aws sns list-topics --region ap-south-1 --query 'Topics[].TopicArn'

# Event buses and state machines
aws events list-event-buses --region ap-south-1
aws stepfunctions list-state-machines --region ap-south-1 --query 'stateMachines[].name'

# DynamoDB tables (names only)
aws dynamodb list-tables --region ap-south-1

Sandbox + read-only IAM.

19. अजून industry आणि stack stories

  • Fintech Lagos: webhook → SQS → idempotent ledger.
  • Ecommerce Pune: throttle + fan-out.
  • Healthcare SG: SNS + PHI IAM.
  • EdTech: EventBridge cleanup.
  • Logistics: bus + saga.
  • Media: avoid recursive S3.
  • SaaS: tenant partition.
  • Gov: strangler peel.
  • Startup: Function URL → HTTP API.
  • Retail: FIFO vs Standard.
  • Python: thin handlers.
  • Node: async/await.
  • Java: SnapStart.
  • .NET: package size.
  • Go: static binary.
  • PHP: hybrid.

20. Glossary

Termअर्थ
Cold startपहिल्या invoke ची init
Idempotencyदोनदा = तोच effect
DLQFail झालेले messages
ChoreographyEvents; conductor नाही
OrchestrationSFN central
Fan-outएक → अनेक
Fan-inअनेक → join
Strangler figMonolith peel
SagaSteps + compensate
Provisioned concurrencyWarm N; pay

21. Practice: मोठ्याने explain

  1. 60s: serverless observability गोष्ट.
  2. 60s: sync vs async checkout.
  3. 60s: Lambda नको कधी.
  4. 60s: DLQ + idempotency.
  5. Record ×2.

22. Safe lab hygiene

  • Tag owner+expiry.
  • Budget alarm आधी.
  • Read-only first.
  • Cleanup.
  • No secrets in env/screenshots.
  • No provisioned on hello.

24. Myths

Mythखरं
Servers नाहीतServers आहेत; manage नको
नेहमी स्वस्तSteady वर EC2
No OpsIAM/data/alarms
एक LambdaBounded contexts
Queues optionalLoad leveler

25. Serverless error budget

Checkout error budget 0.1% असेल तर aggressive retries email duplicates देऊन budget जाळू शकतात. Money SLO ≠ notify SLO.

  1. दोन SLOs.
  2. Money retries bounded.
  3. Notify best-effort.
  4. Money page; notify ticket.

26. Regional notes (ap-south-1)

  • Labs Mumbai.
  • Feature availability.
  • Data residency.
  • Latency India.

27. Naming conventions

# Suggested prefixes
# Lambda:  pay-intake-prod, pay-worker-prod
# SQS:     pay-orders.fifo / pay-orders-dlq
# SNS:     pay-order-events
# EB bus:  pay.domain
# SFN:     pay-refund-saga
# DDB:     pay-orders-prod

env + domain नावात ठेवा. CloudWatch grep सोपा.

28. Pre-mortems

  1. Double charge headline.
  2. DLQ drain plan.
  3. Cognito outage mode.
  4. Runbook.

29. Currency / locale

Currencies आणि names rotate करा — global mental model.

30. Aisha ledger

  1. Page.
  2. DDB throttle.
  3. DLQ.
  4. Fix+runbook.

31. Anti-patterns

  • No request id.
  • No runbook.
  • Over-trace.

उजळणी, मुलाखत आणि तुलना cards

हा lesson काही मिनिटांत revise करा. Cards phone वर save करा किंवा PNG download करा. प्रत्येक card वरचा QR हा lesson उघडतो.

उजळणी card: Structured JSON logs. Grep lottery. JSON + corr id. Powertools → Insights. Redact PII.
उजळणी card: Structured JSON logs · PNG download करा · Card page उघडा
उजळणी card: X-Ray across services. Missing hop. Trace the path. Trace → sample → map. Map first.
उजळणी card: X-Ray across services · PNG download करा · Card page उघडा
तुलना: Free-text logs vs Structured JSON. Free-text logs: Sentences. Structured JSON: Fields.
तुलना: Free-text logs vs Structured JSON · PNG download करा · Card page उघडा
तुलना: Logs only vs Logs + X-Ray. Logs only: Local lines. Logs + X-Ray: Full path.
तुलना: Logs only vs Logs + X-Ray · PNG download करा · Card page उघडा
मुलाखत card: Correlation id. No stitch. Propagate corr id. Who generates.
मुलाखत card: Correlation id · PNG download करा · Card page उघडा
मुलाखत card: EMF custom metrics. Per-request PutMetric. EMF from logs. One metric.
मुलाखत card: EMF custom metrics · PNG download करा · Card page उघडा
मुलाखत card: Alarm Errors + Throttles. Duration only. Errors + Throttles. Runbook line.
मुलाखत card: Alarm Errors + Throttles · PNG download करा · Card page उघडा
मुलाखत card: Sample traces for cost. Trace bill. Sample + keep bad. Pick a rate.
मुलाखत card: Sample traces for cost · PNG download करा · Card page उघडा

अजून cards: Ravi Sir's Cards.

सराव Tasks

या scenario बद्दल

Milan Furniture हा मिलान मधला फर्निचर व्यवसाय आहे. Giulia Rossi त्यांचं IT व cloud काम पाहतात. त्यांचे पैसे EUR मध्ये मोजले जातात आणि AWS resources eu-south-1 Region मध्ये चालतात. खालच्या tasks मध्ये तुम्ही या lesson मध्ये शिकलेलं वापरून त्यांची खरी कामं करता. सगळी नावं, account IDs, IP addresses व numbers सरावासाठी काल्पनिक आहेत.

0 / 16

सोपं XRay

का: Trace.

काय करायचं: Trace तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

सोपं JSON

का: Logs.

काय करायचं: JSON logs तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

सोपं Corr

का: Link.

काय करायचं: Correlation तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

सोपं PT

का: Lib.

काय करायचं: Powertools तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

सोपं List-logs

का: CLI.

काय करायचं: list.

कसं करायचं:
  1. Task वाचा आणि ते कोणत्या AWS service बद्दल आहे ते ठरवा.
  2. aws लिहा, मग service चं नाव, मग operation (action शब्द).
  3. प्रत्येक आवश्यक flag (--name) व त्यापुढे task मधली value लिहा.
  4. Flags कोणत्याही क्रमाने चालतात. Check answer दाबा.

सोपं Stack

का: Map.

काय करायचं: traces/logs/lib.

कसं करायचं:
  1. Task मधल्या top-level keys पासून सुरू करा.
  2. Child keys 2 spaces ने indent करा (tabs नकोत).
  3. प्रत्येक property मध्ये task मधली value भरा.
  4. Check answer दाबा. Keys चा क्रम महत्त्वाचा नाही.

सोपं Active

का: XRay.

काय करायचं: Active tracing तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

मध्यम EMF

का: Metrics.

काय करायचं: EMF तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

मध्यम Alarm

का: Ops.

काय करायचं: Alarm errors तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

मध्यम Sample

का: Cost.

काय करायचं: Sample traces तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

मध्यम PII

का: Safe.

काय करायचं: Redact PII तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

मध्यम Ops

का: Alarm.

काय करायचं: alarm_on/link.

कसं करायचं:
  1. Task मधल्या top-level keys पासून सुरू करा.
  2. Child keys 2 spaces ने indent करा (tabs नकोत).
  3. प्रत्येक property मध्ये task मधली value भरा.
  4. Check answer दाबा. Keys चा क्रम महत्त्वाचा नाही.

अवघड Init

का: Cold.

काय करायचं: InitDuration तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

अवघड Dash

का: Ops.

काय करायचं: Dashboard तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

अवघड Noise

का: Hygiene.

काय करायचं: Avoid noise तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

अवघड Lab

का: Hygiene.

काय करायचं: Delete lab तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.