Q28
How would you design and implement a scalable logging architecture for a distributed system?
💬Answer
Logging in a distributed microservice system requires centralizing logs to avoid logging into individual servers. The architecture is typically implemented using the PLG (Promtail-Loki-Grafana) or EFK (Elasticsearch-Fluentd-Kibana) stack:
- Structured JSON Logs: Enforce applications to write logs in structured JSON format (containing timestamp, severity level, service name, message, trace/correlation IDs, and request metadata).
- Correlation IDs (Tracing): Inject a unique Correlation ID (or traceparent header) at the API Gateway. Pass this ID to every downstream service in HTTP/gRPC request headers so logs from different services can be grouped and queried together.
- Log Forwarding (Collectors): Run a lightweight log collector agent (e.g., Fluent Bit, Promtail, or Logstash) on every node/host. These agents watch container log files (e.g.,
/var/log/containers/*), append Kubernetes labels, and forward them. - Log Indexing & Storage (Aggregator): Forward logs to a central indexing database (e.g., Grafana Loki or Elasticsearch).
- Visualization & Querying: Use a dashboard (e.g., Grafana or Kibana) to query and analyze log streams during troubleshooting.
- Retention Policies: Define log rotation and lifecycle policies (e.g., keeping logs in hot index for 7 days, then archiving to cheap cold storage like S3 for 90 days before deletion).
Related Monitoring Questions
View All MonitoringQuestions →Q1
How do you explain the difference between Monitoring and Observability? Are they the same thing?
Q2What are the Four Golden Signals of Monitoring, and why are they critical?
Q3How does the RED methodology help monitor request-driven microservices?
Q4What is the USE methodology, and in what scenarios is it preferred over RED?

Created by
Apurv Gujjar
DevOps & Cloud Engineer
Specialized in:DevOpsAWSGCPKubernetesTerraformDocker
View Portfolio