Chapter 95: Logging with Loki, Elastic Stack and CloudWatch
Friends, chapter 87 explained monitoring with Prometheus. Today we ask a different question: what happened in one request? Logs are event records, not a replacement for metrics or traces. We will compare three logging systems, read their query languages slowly, and run only a tiny Python lab with invented data. No real log file, cloud account or logging server is needed. Every Loki, Elastic and CloudWatch result is illustrative, not executed.
मित्रांनो, chapter 87 मध्ये Prometheus monitoring शिकलो. आज वेगळा प्रश्न आहे: एका request मध्ये नेमकं काय झालं? Logs म्हणजे events ची नोंद; ते metrics किंवा traces ची जागा घेत नाहीत. तीन logging systems आणि त्यांच्या queries हळू हळू बघू. फक्त बनवलेल्या data वर छोटा Python lab चालवू. खरे log files, cloud account किंवा logging server लागत नाही. Loki, Elastic आणि CloudWatch चे outputs उदाहरणे आहेत, चालवलेले नाहीत.
दोस्तों, chapter 87 में Prometheus monitoring सीखा. आज सवाल है: एक request में क्या हुआ? Logs events का record हैं, metrics या traces का विकल्प नहीं. तीन logging systems और उनकी queries धीरे पढ़ेंगे. सिर्फ बनाए हुए data पर छोटा Python lab चलाएँगे. असली log files, cloud account या logging server नहीं चाहिए. Loki, Elastic और CloudWatch के results उदाहरण हैं, चलाए नहीं गए.
Classroom safety and route
- Learn the shape of one event before collecting millions of lines.
- Remove sensitive fields before sending or storing anything.
- Learn Loki labels and LogQL, Elastic mappings and queries, then CloudWatch groups and Insights QL.
- Practise time conversion, parsing and aggregation on synthetic local data only.
- Finish the interview cards and the one chapter quiz.
A CLI is a command-line interface. An API is an application request interface. JSON is structured text containing named fields and values. HTTP is a request/response protocol; GET reads, while POST submits a request. TLS encrypts network traffic. These terms do not grant permission to collect logs or access a real system.
Existing monitoring/project lessons introduce observability tools. This chapter teaches log-event design and querying instead of repeating Prometheus installation. All business stories are fictional. No actual customer, account, credential, production log or personal profile is used. Prices and product licenses are not claimed. Official documentation links opened for this chapter appear at the end.
Concepts in this chapter
- 95.1Logs, metrics and traces — three different questions
- 95.2One event — timestamp, severity and structured JSON
- 95.3The pipeline — agent, collector, storage and query
- 95.4Privacy — allowlists, redaction and safe correlation
- 95.5Loki — streams, labels and cardinality
- 95.6LogQL — selector, line filter and JSON parser
- 95.7Ingestion with Alloy — current collector choice
- 95.8Elastic Stack — Elasticsearch, Logstash and Kibana
- 95.9Elasticsearch — index, mapping, text and keyword
- 95.10Kibana KQL versus Elasticsearch Query DSL
- 95.11CloudWatch Logs — groups, streams and retention
- 95.12Logs Insights QL — fields, filter, stats and time scope
- 95.13Time zones, parsing and multiline stack traces
- 95.14Correlation, duplicates and event identity
- 95.15Access, retention and cost guardrails
- 95.16Alert principles — useful signals without sending alerts
- 95.17Troubleshooting missing, delayed and duplicate logs
- 95.18Comparison — Loki, Elastic Stack and CloudWatch
- 95.19Entirely local lab — synthetic Python logging and parsing
- 95.20Interview questions, revision and chapter quiz