# Elastic Stack (ELK) and OpenSearch

> Full-text indexed logging and search with Elasticsearch or OpenSearch, Logstash or Beats for ingestion, and Kibana for exploration. Free notes, key concepts,...

Canonical: https://www.internhack.in/roadmaps/tracks/devops/elk-stack
Last updated: 2026-11-28

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](https://www.internhack.in/roadmaps/tracks/devops/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](https://www.internhack.in/roadmaps/tracks/devops/loki-logging): 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

- [Elastic documentation](https://www.elastic.co/docs) (Elastic)
- [OpenSearch documentation](https://opensearch.org/docs/latest/) (OpenSearch Project)

Previous: [Centralised Logging with Loki](https://www.internhack.in/roadmaps/tracks/devops/loki-logging) · Next: [Distributed Tracing with OpenTelemetry](https://www.internhack.in/roadmaps/tracks/devops/tracing-opentelemetry)

## More in Observability: Metrics, Logs, Traces and SLOs

- [Observability Fundamentals](https://www.internhack.in/roadmaps/tracks/devops/observability-fundamentals)
- [Prometheus and Grafana](https://www.internhack.in/roadmaps/tracks/devops/prometheus-grafana)
- [Centralised Logging with Loki](https://www.internhack.in/roadmaps/tracks/devops/loki-logging)
- [Elastic Stack (ELK) and OpenSearch](https://www.internhack.in/roadmaps/tracks/devops/elk-stack)
- [Distributed Tracing with OpenTelemetry](https://www.internhack.in/roadmaps/tracks/devops/tracing-opentelemetry)
- [Alerting That Does Not Burn People Out](https://www.internhack.in/roadmaps/tracks/devops/alerting)
- [SLIs, SLOs and Error Budgets](https://www.internhack.in/roadmaps/tracks/devops/slo-error-budgets)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [DevOps Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/devops)
