AI Hints
Home›Elasticsearch Tutorial›Data Streams, Snapshots and Security
Elasticsearch · Lesson 109 of 120

Data Streams and ILM

Time series data.

⏱ 2 min read▶ Video at 1:42:49🎓 Free
Watch this lesson in the Elasticsearch courseWatch on YouTube ↗Full Elasticsearch course

Logs and metrics never stop arriving. Keeping them all in one giant index gets slow. A data stream writes to a series of indices behind the scenes, and a lifecycle policy rolls them over and deletes old ones.

  • Endless logs
  • Many backing indices
  • Auto cleanup

A data stream with a policy

The lifecycle policy rolls over to a new index every day, and deletes indices after thirty days. The index template turns logs app into a data stream, using that policy. We add one log line, with a timestamp. Run it. The data stream exists, with its first backing index.

Dev Tools Consoletext
PUT _ilm/policy/logs-policy?filter_path=acknowledged
{ "policy": { "phases": {
    "hot":    { "actions": { "rollover": { "max_age": "1d" } } },
    "delete": { "min_age": "30d", "actions": { "delete": {} } } } } }

PUT _index_template/app-logs?filter_path=acknowledged
{ "index_patterns": ["logs-app*"], "data_stream": {}, "priority": 200,
  "template": { "settings": { "index.lifecycle.name": "logs-policy" } } }

POST logs-app/_doc?filter_path=result
{ "@timestamp": "2026-11-14T09:00:00Z", "message": "Order TH-10042 paid" }

GET _data_stream/logs-app/_stats?filter_path=data_stream_count,backing_indices
Output
# PUT _ilm/policy/logs-policy 200 OK
{"acknowledged": true}

# PUT _index_template/app-logs 200 OK
{"acknowledged": true}

# POST logs-app/_doc 201 Created
{"result": "created"}

# GET _data_stream/logs-app/_stats 200 OK
{"data_stream_count": 1, "backing_indices": 1}

Data stream rules

Every document needs an at timestamp field. You can only add documents, not update them in place. Rollover creates the next backing index. And searching the stream name searches all its indices.

keyvalue
@timestamprequired
Writesappend only
Rollovernext backing index
Searchthe whole stream

Summary

Data streams handle endless time series data, and lifecycle policies roll over and delete old indices. Next, backups with snapshots.

Key takeaways
  • Data streams
  • ILM policy
  • Rollover
Next up: Snapshots — backup and restore