加载中

通用剖析索引生命周期管理

Elastic Stack

索引生命周期策略允许您自动化剖析索引的生命周期,随着索引的增长和老化。系统会应用默认策略,但您可以根据您的业务需求进行自定义。

默认的通用剖析索引生命周期策略包含以下滚动和删除定义:

  • 滚动:滚动可防止单个索引变得过大,并优化索引和搜索性能。达到年龄或大小指标阈值后,将创建一个新索引,所有后续更新都将写入新索引。
  • 删除:达到时间阈值后,删除阶段将永久删除索引。

下表列出了滚动和删除的默认阈值:

滚动 温和层 删除
30 天或 50 GB 后 30 天后 60 天后
注意

滚动条件会 阻止阶段转换,这意味着索引会在热层滚动 30 天保留。

要在 Kibana 中查看通用剖析索引生命周期策略,请导航到堆栈管理索引生命周期管理,然后搜索 profiling

提示

默认的 ILM 策略在次要版本之间可能会发生变化。这不被视为破坏性更改,因为索引管理应不断改进并适应新功能。

请完成以下步骤来配置自定义索引生命周期策略。

  1. 要打开索引生命周期策略,请在主菜单中找到堆栈管理,或使用 全局搜索字段
  2. 点击创建策略
  3. 为新策略命名,例如 custom-profiling-policy
  4. 按需自定义策略。
  5. 点击保存策略
提示

请参阅 管理索引生命周期,了解有关 ILM 策略的更多信息。

要为通用剖析应用新的索引生命周期策略,请创建一个名为 profiling-ilm@custom 的新组件模板。

注意

要应用自定义 ILM 策略,您必须将组件模板命名为 profiling-ilm@custom。不支持其他名称。

  1. 索引管理页面,选择组件模板选项卡,然后点击创建组件模板

  2. 输入 profiling-ilm@custom 作为名称,然后点击下一步

  3. 索引设置中,设置在上一步中创建的 ILM 策略名称。

    {
      "lifecycle": {
        "name": "custom-profiling-policy"
      }
    }
    
  4. 继续到审阅步骤,然后选择请求选项卡。您的请求应与下图类似。

    如果正确,请点击创建组件模板

    Create component template

确认通用剖析现在正在使用新的索引模板和 ILM 策略。

  1. 通过在 全局搜索字段中查找 Dev Tools 来打开控制台

  2. 运行以下命令:

    GET _ilm/policy/custom-profiling-policy
    
    1. 步骤 1 中选择的自定义 ILM 策略的名称。

如果自定义策略已应用,结果应包含以下内容:

{
    "in_use_by": {
      "indices": [
        ...
      ],
      "data_streams": [
        ...
        "profiling-events-all",
        ...
      ],
      "composable_templates": [
        "profiling-stackframes",
        "profiling-symbols-global",
        "profiling-metrics",
        "profiling-stacktraces",
        "profiling-executables",
        "profiling-hosts",
        "profiling-events"
      ]
    }
}

如果结果为空,则表示自定义 ILM 策略尚未生效。新的 ILM 策略仅在新索引创建时生效,因此,请等待滚动发生(通常在 30 天后或索引大小达到 50 GB 时),或者使用 Elasticsearch 滚动 API强制执行滚动。

POST /profiling-events-5pow01/_rollover/
POST /profiling-events-5pow02/_rollover/
POST /profiling-events-5pow03/_rollover/
POST /profiling-events-5pow04/_rollover/
POST /profiling-events-5pow05/_rollover/
POST /profiling-events-5pow06/_rollover/
POST /profiling-events-5pow07/_rollover/
POST /profiling-events-5pow08/_rollover/
POST /profiling-events-5pow09/_rollover/
POST /profiling-events-5pow10/_rollover/
POST /profiling-events-5pow11/_rollover/
POST /profiling-events-all/_rollover/
POST /profiling-executables/_rollover/
POST /profiling-hosts/_rollover/
POST /profiling-metrics/_rollover/
POST /profiling-stackframes/_rollover/
POST /profiling-stacktraces/_rollover/
POST /profiling-symbols-global/_rollover/

滚动后,自定义 ILM 策略将应用于新索引和数据流。

© . This site is unofficial and not affiliated with Elasticsearch BV.