Use it when operating an Elastic/OpenSearch log cluster.
Elasticsearch and OpenSearch Log Indices
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.
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.
log → ingest pipeline → index/data stream → shards → lifecycle
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
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.
Cluster health yellow/red means unassigned shards. Keep shard sizes reasonable (tens of GB). Explicit mappings avoid mapping explosions. Lifecycle policies delete old data.
curl -s es:9200/_cluster/health?pretty— first check for this topiccurl -s localhost:9090/-/ready— Prometheus readycurl -s 'localhost:9090/api/v1/query?query=up'— scrape targets up/downpromtool 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:
| Phase | Typical action |
|---|---|
| Hot | Active writes; rollover at ~30–50 GB per primary shard or 1 day |
| Warm | Read-only, force-merge to 1 segment, fewer replicas |
| Cold | Cheaper nodes or searchable snapshots |
| Delete | After 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.
Common mistakes
- No index lifecycle policy.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
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.