Pcornel
Browse topics
Options
Recent
Favorites
Observability · Technical reference

Elasticsearch and OpenSearch Log Indices

Direct answer

Elasticsearch/OpenSearch store logs in indices (often time-based or data streams) split into shards, with mappings for field types and ILM/ISM policies for rollover and deletion.

When to use this

Use it when operating an Elastic/OpenSearch log cluster.

First 30 seconds

1. Health: curl -s es:9200/_cluster/health?pretty.

2. Unassigned shards: curl -s es:9200/_cluster/allocation/explain?pretty.

3. Index sizes: curl -s 'es:9200/_cat/indices?v&s=store.size:desc'.

4. Lifecycle policy applied.

5. Disk watermarks.

Operational verification

log → ingest pipeline → index/data stream → shards → lifecycle

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
OpenTelemetry / Prometheus / Grafana / common metrics-log-trace pipelines
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformOpenTelemetry / Prometheus / Grafana / common metrics-log-trace pipelines
Scope / prerequisiteUse it when operating an Elastic/OpenSearch log cluster.
What next?2 suggested next steps
Evidence0
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

2 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 How to verify Verify boundary

Watch cluster health, disk use per node and rejected bulk requests. Confirm lifecycle policies delete data on schedule.

Step 2 Common failures Narrow the fault

Too many small shards waste memory. Disk above the flood-stage watermark blocks writes. Dynamic mapping of free-form JSON creates thousands of fields.

Key points

Cluster health yellow/red means unassigned shards. Keep shard sizes reasonable (tens of GB). Explicit mappings avoid mapping explosions. Lifecycle policies delete old data.

Key checks
  • curl -s es:9200/_cluster/health?pretty — first check for this topic
  • curl -s localhost:9090/-/ready — Prometheus ready
  • curl -s 'localhost:9090/api/v1/query?query=up' — scrape targets up/down
  • promtool check config prometheus.yml — config valid
ReferenceWhat it is1 section · depth on demand

How it works

Each index is split into primary shards with replicas on other nodes. Templates set mappings and settings for new indices. Disk watermarks stop allocation and, at the flood stage, make indices read-only.

ReferenceImportant terms & boundaries3 sections · depth on demand

Index management

  • Use data streams or rollover with ILM/ISM policies (hot → warm → cold → delete).
  • Shard size around 10–50 GB; too many small shards waste heap.
  • Define mappings/templates; avoid mapping explosions from dynamic fields.
  • Check health: GET _cluster/health, GET _cat/indices?v&s=store.size:desc, GET _cat/shards?v.

Yellow = replicas unassigned (often a single node); red = primary shards missing (data unavailable).

In depth

Lifecycle for log indices

Write to a data stream (or a rollover alias); a lifecycle policy rolls the backing index over at a size or age and moves older indices through phases:

PhaseTypical action
HotActive writes; rollover at ~30–50 GB per primary shard or 1 day
WarmRead-only, force-merge to 1 segment, fewer replicas
ColdCheaper nodes or searchable snapshots
DeleteAfter the retention period

OpenSearch implements this with Index State Management (ISM) policies; Elasticsearch with Index Lifecycle Management (ILM). Without a policy, indices grow until the disk watermarks block writes.

Shard sizing

Each shard is a Lucene index with fixed memory and file-handle overhead. Thousands of tiny daily shards (one per small service per day) waste heap and slow cluster state updates. Aim for shards of roughly 10–50 GB and use rollover by size, not by calendar day.

Disk watermarks

Watermark (default)Effect
Low (85 %)No new shards allocated to the node
High (90 %)Shards moved away from the node
Flood stage (95 %)Indices with a shard on the node become read-only (index.blocks.read_only_allow_delete)

After freeing space, recent versions remove the block automatically; older ones need it cleared by hand.

Health checks

GET _cluster/health                          # status, unassigned_shards
GET _cat/allocation?v                        # disk per node
GET _cat/indices?v&s=store.size:desc&h=index,pri,rep,docs.count,store.size | head
GET _cluster/allocation/explain              # why a shard is unassigned
GET _nodes/stats/thread_pool/write           # rejected bulk requests

Mappings

Define an index template with explicit mappings for known fields and set dynamic mapping to false or runtime for free-form JSON; otherwise every new key in a log line becomes a field, and a type clash (a field that is a number in one line and text in another) rejects documents.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Common mistakes

  • No index lifecycle policy.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
elasticsearch and opensearch log indiceselasticsearch cluster healthindex lifecycle policy
Confirmation

Confirm action

Continue?