0Pricing
System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) · 课时

索引生命周期管理(ILM)

掌握 Index Lifecycle Management,自动化执行索引滚动更新、冷热架构和数据保留,让日志索引保持高性能并控制存储使用。

索引生命周期管理(ILM) 是 CoddyKit 上的免费 System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) 课时。 这是第 4 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) 课程共包含 4 节课。

本课时的部分内容尚未翻译,以英文显示。

Why Manage Index Lifecycle?

Time-series data like logs grows endlessly. Index Lifecycle Management (ILM) automates moving, shrinking, and deleting indices so old data does not crush your cluster.

Rollover

Rollover creates a new index when the current one hits a size, age, or document count threshold. Writes always go to a single alias.

rollover:
  max_size: 50gb
  max_age: 1d
  max_docs: 100000000

Write Aliases

Apps write to an alias such as logs-write. ILM swaps which physical index the alias points to on rollover, invisible to the writer.

POST logs-write/_doc
{ "message": "..." }

The Phases

ILM defines lifecycle phases a data ages through.

  • Hot: actively written and queried
  • Warm: read-only, queried less
  • Cold: rarely queried, cheap storage
  • Delete: removed

Hot Phase

The hot phase lives on the fastest nodes with the most resources, handling all writes and recent queries.

phases:
  hot:
    actions:
      rollover: { max_age: 1d }

Warm Phase

In warm, indices become read-only and may move to cheaper nodes. You can shrink shards and force-merge segments to save space.

warm:
  min_age: 7d
  actions:
    forcemerge: { max_num_segments: 1 }
    shrink: { number_of_shards: 1 }

Cold and Frozen

Cold data moves to the cheapest disks; frozen can be searched directly from object storage. Both trade query speed for cost.

cold:
  min_age: 30d
  actions:
    allocate: { require: { data: cold } }

Delete Phase

The delete phase enforces retention by removing indices past a chosen age, the simplest way to cap storage growth.

delete:
  min_age: 90d
  actions:
    delete: {}

Attaching a Policy

An index template binds new indices to an ILM policy and the write alias automatically.

PUT _index_template/logs
{ "template": { "settings": {
  "index.lifecycle.name": "logs-policy" } } }

Node Roles

Hot-warm-cold relies on node attributes so allocation actions can route shards to the right hardware tier.

node.attr.data: hot   # on fast nodes
node.attr.data: cold  # on cheap nodes

Putting It Together

A typical logging policy: roll over daily in hot, move to warm and force-merge after a week, go cold after a month, and delete after ninety days.

Quick Check

Pick the phase that enforces retention.

Recap

You learned how ILM automates index management: rollover starts fresh indices behind a write alias, and the hot-warm-cold-delete phases move data to cheaper tiers as it ages and finally remove it. Index templates bind policies automatically, keeping clusters fast and storage bounded.

常见问题解答

「索引生命周期管理(ILM)」课时是免费的吗?

是的 — 「索引生命周期管理(ILM)」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) 课程的其余内容,请升级到 CoddyKit PRO。 System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) 课程共包含 4 节课。

「索引生命周期管理(ILM)」这节课中我会学到什么?

掌握 Index Lifecycle Management,自动化执行索引滚动更新、冷热架构和数据保留,让日志索引保持高性能并控制存储使用。 你通过在浏览器中直接运行的动手代码来练习 System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry),全天候 AI 导师会在你学习这节课的过程中回答你的问题。

学习 System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) 需要有经验吗?

无需任何先前经验。CoddyKit 上的 System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 4 节课,共 4 节。

「索引生命周期管理(ILM)」课时需要多长时间?

大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。

我能在这节 System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) 课中编写并运行代码吗?

能。每节 System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。

此课程中的所有课时

  1. Elasticsearch 查询语言(DSL)
  2. Logstash 过滤器与管道
  3. Kibana Discover 与 Lens
  4. 索引生命周期管理(ILM)
← 返回 System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)