What if you could see all your system's problems in one place, instantly?
Why Centralized logging (ELK stack) in Microservices? - Purpose & Use Cases
Start learning this pattern below
Jump into concepts and practice - no test required
Imagine you run many small shops in different parts of a city, and each shop keeps its own paper logbook for sales and issues. When you want to check how your whole business is doing, you have to visit each shop, read through piles of papers, and try to remember what you saw. This takes a lot of time and is very tiring.
Manually collecting logs from many services is slow and confusing. Logs are scattered everywhere, making it hard to find problems quickly. You might miss important warnings or errors because you have to look in too many places. This can cause delays in fixing issues and frustrate your team.
The ELK stack brings all logs from different services into one place. It organizes and searches logs easily, like having a smart assistant who reads all your shop logbooks and tells you exactly what you need to know. This saves time and helps you fix problems faster.
ssh service1; cat /var/log/app.log ssh service2; cat /var/log/app.log
Use Filebeat to send logs to Elasticsearch and search them in the Kibana dashboard
With centralized logging, you can instantly see the health of all your services and quickly spot issues before customers notice.
A company running many microservices uses ELK to monitor errors and performance in real time, so their support team can respond immediately to outages or slowdowns.
Manual log checking is slow and scattered.
ELK stack centralizes and organizes logs from all services.
This helps teams find and fix problems faster and keep systems healthy.
Practice
Solution
Step 1: Understand ELK stack components
ELK stands for Elasticsearch (storage), Logstash (processing), and Kibana (visualization), all focused on logs.Step 2: Identify ELK stack role in microservices
It centralizes logs from many services to one place for easier monitoring and troubleshooting.Final Answer:
To collect, store, and visualize logs from multiple services in one place -> Option CQuick Check:
ELK stack = centralized logging [OK]
- Confusing ELK with deployment tools
- Thinking ELK manages databases
- Assuming ELK monitors network traffic
Solution
Step 1: Recall ELK stack components
Elasticsearch stores logs, Logstash processes, Kibana visualizes, Filebeat ships logs.Step 2: Identify correct service name in Docker Compose
The service running Elasticsearch is named "elasticsearch" in Docker Compose files.Final Answer:
elasticsearch -> Option AQuick Check:
Elasticsearch service = elasticsearch [OK]
- Confusing Logstash or Kibana as Elasticsearch service
- Using 'filebeat' as ELK core service
- Misspelling service names
input { beats { port => 5044 } } output { elasticsearch { hosts => ["http://elasticsearch:9200"] } }What happens when Logstash receives logs on port 5044?
Solution
Step 1: Analyze Logstash input configuration
Logstash listens for logs from Beats agents on port 5044.Step 2: Analyze Logstash output configuration
Logs received are forwarded to Elasticsearch at the specified host and port.Final Answer:
Logs are sent to Elasticsearch at http://elasticsearch:9200 -> Option BQuick Check:
Logstash input port 5044 forwards logs to Elasticsearch [OK]
- Assuming logs go directly to Kibana
- Thinking port 5044 is invalid
- Believing logs are stored locally on Logstash
Solution
Step 1: Check connectivity between Logstash and Elasticsearch
If Elasticsearch is down or unreachable, Logstash cannot send logs to it.Step 2: Verify other options
Kibana not running or missing does not stop logs from reaching Elasticsearch; wrong input port would prevent Logstash from receiving logs, not sending.Final Answer:
Elasticsearch service is down or unreachable -> Option DQuick Check:
Logs missing usually means Elasticsearch unreachable [OK]
- Blaming Kibana for missing logs in Elasticsearch
- Confusing input port with Elasticsearch port
- Ignoring Elasticsearch service health
Solution
Step 1: Setup Filebeat on microservice host
Filebeat collects logs locally and forwards them to Logstash on port 5044.Step 2: Ensure ELK stack components are running
Logstash processes logs, sends them to Elasticsearch, and Kibana visualizes them.Final Answer:
Install Filebeat on the microservice host, configure it to send logs to Logstash on port 5044, and verify Elasticsearch and Kibana are running -> Option AQuick Check:
Filebeat -> Logstash -> Elasticsearch -> Kibana [OK]
- Trying to send logs directly to Kibana
- Expecting Elasticsearch to pull logs automatically
- Running Logstash on microservice host unnecessarily
