Ravindra BagaleCourses & study guides मराठी

Chapter 95: Logging with Loki, Elastic Stack and CloudWatch

DevOps

95.2 One event — timestamp, severity and structured JSON

Story (fictional teaching scenario). At a fictional Nashik shop, Meera and Sara from Oslo replace a vague “something broke” message with a few consistent fields.

One event — timestamp, severity and structured JSON
One event — timestamp, severity and structured JSON

Why

Stable fields let computers filter without guessing the meaning of free-form sentences.

What

  • An event is one occurrence being recorded.
  • A timestamp says when it happened; include an offset or UTC marker.
  • Severity classifies importance. INFO, WARN and ERROR here are application conventions, not identical rules across all products.
  • Structured logging stores named fields instead of only a sentence.
  • A schema describes allowed field names and types.

How

  1. Choose a small stable schema.

  2. Keep duration fields numeric and state their unit.

  3. Use one JSON object per line for this lab.

  4. Do not put a request body or credential in the message.

Example 1: A harmless event

  1. Read the command or request.
{"ts":"2026-11-01T00:00:03Z","service":"bakery-api","level":"ERROR","request_id":"req-demo-003","status":500,"latency_ms":800}
  1. Read the result.

Output (illustrative; NOT executed against Loki, Elastic or CloudWatch)

One event: status 500, duration 800 milliseconds, fictional request req-demo-003.
  1. Line by line: ts uses Z for UTC. service identifies the producer. level is our chosen severity. request_id is an invented correlation value. status is an integer HTTP result code. latency_ms is an integer duration in milliseconds. JSON quotes strings, not these numbers.

Ravindra Bagale's Tip

Keep the field type and time unit consistent.

Did you understand? Let us try it once more.