Steven's Knowledge

ELK Stack

Elasticsearch, Logstash, and Kibana for centralized logging, search, and visualization

ELK Stack

The ELK Stack (Elasticsearch, Logstash, Kibana) is the most widely adopted open-source solution for centralized log management, full-text search, and data visualization. Elastic also provides Beats (lightweight data shippers) and the broader Elastic Stack ecosystem.

Overview

ComponentRoleDescription
ElasticsearchSearch & StorageDistributed search and analytics engine based on Apache Lucene
LogstashData ProcessingServer-side data processing pipeline for ingestion and transformation
KibanaVisualizationWeb UI for searching, visualizing, and dashboarding Elasticsearch data
BeatsData ShippingLightweight agents for shipping data from edge machines

Architecture

┌─────────┐   ┌─────────┐   ┌─────────┐
│  App 1  │   │  App 2  │   │  App 3  │
└────┬────┘   └────┬────┘   └────┬────┘
     │              │              │
     ▼              ▼              ▼
┌─────────┐   ┌─────────┐   ┌─────────┐
│Filebeat │   │Filebeat │   │Metricbeat│
└────┬────┘   └────┬────┘   └────┬────┘
     │              │              │
     └──────────────┼──────────────┘

             ┌────────────┐
             │  Logstash   │  (Parse, Transform, Enrich)
             └──────┬─────┘

           ┌──────────────┐
           │Elasticsearch │  (Index, Store, Search)
           └──────┬───────┘

             ┌─────────┐
             │ Kibana   │  (Visualize, Dashboard, Alert)
             └─────────┘

Learning Path

Read in this order if you're new — each page builds on the previous one.

Beats: Data Shippers

BeatPurposeData Source
FilebeatLog filesApplication logs, system logs, container logs
MetricbeatSystem metricsCPU, memory, disk, network, container stats
PacketbeatNetwork dataHTTP, DNS, MySQL, Redis protocol analysis
HeartbeatUptime monitoringHTTP, TCP, ICMP health checks
AuditbeatAudit dataFile integrity, system calls, user activity

A working Filebeat config and complete pipeline live in Getting Started.

Deployment Patterns

Small (Development / Small Team)

  • Single-node Elasticsearch
  • Logstash on the same host
  • Filebeat on application servers

Medium (Production)

  • 3-node Elasticsearch cluster (1 master, 2 data)
  • Dedicated Logstash instances
  • Kafka/Redis as buffer between Beats and Logstash
  • Kibana behind reverse proxy with authentication

Large (Enterprise)

  • Dedicated master, data, ingest, and coordinating nodes
  • Hot-warm-cold architecture for data lifecycle
  • Cross-cluster replication for disaster recovery
  • Kafka as durable message buffer
  • Multiple Logstash pipelines

Best Practices

ELK Stack Guidelines

  1. Sizing: Allocate 50% of available RAM to Elasticsearch JVM heap (max 31GB)
  2. Sharding: Use 1 primary shard per 20-40GB of data; avoid over-sharding
  3. Index Lifecycle: Use ILM policies to manage hot/warm/cold/delete phases
  4. Security: Enable TLS between nodes and authentication for production
  5. Buffering: Use Kafka or Redis between Beats and Logstash for resilience
  6. Monitoring: Use Elastic's built-in monitoring or Metricbeat to monitor the stack itself
  7. Mapping: Define explicit index mappings instead of relying on dynamic mapping
  8. Retention: Set index lifecycle policies to automatically delete old data

ELK vs Alternatives

FeatureELK StackGrafana LokiDatadogSplunk
CostFree (self-hosted)Free (self-hosted)Per-GB ingestedPer-GB indexed
Full-text Search★★★★★★★☆☆☆★★★★☆★★★★★
Log Aggregation★★★★★★★★★★★★★★★★★★★★
Resource UsageHighLowN/A (SaaS)High
Setup ComplexityMediumLowLow (SaaS)Medium
Scalability★★★★★★★★★☆★★★★★★★★★★
Visualization★★★★☆★★★★★ (Grafana)★★★★★★★★★☆
APM Integration★★★★☆★★★☆☆★★★★★★★★★☆

On this page