Elastic Stack (ELK) and OpenSearch

Full-text indexed logging and search with Elasticsearch or OpenSearch, Logstash or Beats for ingestion, and Kibana for exploration.

Intermediate · about 7 hours · difficulty 3/5

Learn first: Observability Fundamentals

The ELK stack (Elasticsearch, Logstash, Kibana, plus Beats) was the first widely adopted open log platform and is still common, as is its fork OpenSearch with OpenSearch Dashboards.

Components

  • Elasticsearch / OpenSearch: a distributed search engine that indexes every field of every document, enabling fast full-text search and aggregations.
  • Beats (Filebeat, Metricbeat) or Elastic Agent: lightweight shippers on each host.
  • Logstash: a pipeline that parses (grok, JSON), enriches (GeoIP) and routes events. Fluentd or Fluent Bit are frequent replacements.
  • Kibana / OpenSearch Dashboards: search, visualisations and dashboards.

Core concepts

  • Data lives in indices split into shards with replicas across nodes.
  • Mappings define field types; let dynamic mapping run wild and you get mapping explosions.
  • Index Lifecycle Management (ILM, or ISM in OpenSearch) rolls over indices and moves them hot to warm to cold to delete.
  • Queries use KQL or the Lucene syntax in Kibana, and the Query DSL via the API.

Trade-offs vs Loki

Full-text indexing gives very fast, flexible search and analytics, but costs more CPU, memory and disk, and clusters need real care (shard sizing, heap, upgrades). Managed offerings (Elastic Cloud, Amazon OpenSearch Service) remove much of that work.

Good enough to move on: you can run a small Elasticsearch or OpenSearch cluster with Filebeat shipping container logs, set an ILM policy that deletes data after 14 days, and build a Kibana view of errors by service.

Key concepts

  • Elasticsearch vs OpenSearch
  • Beats and Elastic Agent
  • Logstash pipelines and grok
  • Indices, shards and replicas
  • Mappings
  • Index lifecycle management
  • Kibana and KQL

Other options for this step

  • Centralised Logging with Loki: Ship logs from every host and pod to Grafana Loki, a cost-efficient log store that indexes labels rather than full text.

Mini project

Run Elasticsearch and Kibana with Docker Compose, ship an app's JSON logs with Filebeat, add an ILM policy, and build a dashboard of error counts and top error messages.

Check yourself

What problem does index lifecycle management solve, and what happens to a cluster that never deletes old indices?

Free resources