配置项作用 #
index_state_management.history.enabled 配置项用于控制是否启用索引状态管理(ISM)的历史记录功能。
启用后,ISM 会记录索引状态变更的历史信息,包括策略执行情况、状态变更、操作日志等,存储在专门的历史索引中。
配置项属性 #
- 配置路径:
index_state_management.history.enabled - 数据类型:
Boolean(布尔值) - 默认值:
true - 是否可选: 是
- 作用域: NodeScope(节点级别)
- 动态更新: 是(支持动态更新)
配置项详解 #
工作机制 #
ISM 历史记录流程
ISM 策略执行操作
│
↓
检查 history.enabled
│
├──────── false ──→ 不记录历史 ❌
│
└──────── true ──→ 记录到历史索引 ✅
│
↓
写入 .ism-history 索引
│
├──────── 元数据
│ ├── 索引名称
│ ├── 策略名称
│ ├── 状态变更
│ └── 操作类型
│
├──────── 时间戳
│ └── 操作时间
│
└──────── 执行结果
├── 成功
├── 失败
└── 错误信息
历史索引结构 #
历史索引组织结构
.ism-history-000001
.ism-history-000002
.ism-history-000003
│
↓ 别名
.ism-history (别名)
│
↓ 包含文档类型
ism_history (文档类型)
文档结构示例:
{
"index_name": "logs-2024-01-01",
"policy_name": "logs_policy",
"state_name": "hot",
"action_name": "rollover",
"start_time": "2024-01-01T10:00:00Z",
"end_time": "2024-01-01T10:00:05Z",
"status": "success",
"message": "Rollover to logs-2024-01-02"
}
历史记录滚动 #
历史索引的生命周期
历史索引创建
│
↓
记录 ISM 操作
│
↓
检查滚动条件
│
├──────── max_docs 达到?
│ ↓
│ 是 ──→ 触发 rollover
│ ↓
│ 创建新历史索引
│
└──────── max_age 达到?
↓
是 ──→ 触发 rollover
↓
创建新历史索引
配置建议 #
生产环境(默认) #
index_state_management:
history:
enabled: true # 默认值
建议: 保持默认值 true。用于故障排查和操作审计。
资源受限环境 #
index_state_management:
history:
enabled: false # 禁用历史记录
建议: 设置为 false。存储资源有限时使用。
测试环境 #
index_state_management:
history:
enabled: false
建议: 设置为 false。不需要历史记录时使用。
代码示例 #
easysearch.yml 基础配置 #
index_state_management:
history:
enabled: true
完整历史配置 #
index_state_management:
history:
enabled: true
max_docs: 2500000
max_age: 24h
number_of_shards: 1
number_of_replicas: 1
动态更新配置 #
PUT /_cluster/settings
{
"transient": {
"index_state_management.history.enabled": false
}
}
禁用历史记录 #
index_state_management:
history:
enabled: false
相关配置 #
| 配置项 | 作用 | 默认值 |
|---|---|---|
index_state_management.history.enabled | 是否启用历史记录 | true |
index_state_management.history.max_docs | 历史索引最大文档数 | 2500000 |
index_state_management.history.max_age | 历史索引最大年龄 | 24h |
index_state_management.history.rollover_check_period | 滚动检查周期 | 8h |
历史记录用途 #
历史记录的用途
1. 故障排查
├── 查看策略执行历史
├── 诊断失败原因
└── 追踪状态变更
2. 操作审计
├── 记录谁执行了什么操作
├── 记录操作时间
└── 满足合规要求
3. 性能分析
├── 分析策略执行耗时
├── 识别瓶颈操作
└── 优化策略配置
4. 调试支持
├── 查看详细的执行日志
├── 理解状态转换
└── 验证策略行为
存储影响分析 #
历史记录的存储消耗
假设平均每条记录 10KB
max_docs = 2500000:
存储需求 ≈ 2500000 × 10KB ≈ 25GB
max_docs = 1000000:
存储需求 ≈ 1000000 × 10KB ≈ 10GB
max_docs = 5000000:
存储需求 ≈ 5000000 × 10KB ≈ 50GB
影响因素:
- 策略执行频率
- 索引数量
- 操作类型
- 错误消息大小
使用场景 #
推荐启用历史记录的场景 #
- 生产环境: 需要追踪和审计
- 关键业务: 需要详细的操作记录
- 故障排查: 需要快速定位问题
- 合规要求: 需要操作审计
可以禁用历史记录的场景 #
- 存储受限: 存储资源紧张
- 测试环境: 不需要历史记录
- 简单部署: ISM 策略简单稳定
历史查询示例 #
查询 ISM 历史记录
查看特定索引的历史:
GET .ism-history/_search
{
"query": {
"term": {
"index_name": "logs-2024-01-01"
}
}
}
查看失败的策略执行:
GET .ism-history/_search
{
"query": {
"term": {
"status": "failed"
}
}
}
按时间范围查询:
GET .ism-history/_search
{
"query": {
"range": {
"start_time": {
"gte": "now-7d"
}
}
}
}
注意事项 #
默认启用: 默认值为
true,建议生产环境保持启用。存储消耗: 历史记录会占用额外的存储空间。
动态更新: 支持动态更新,修改后立即生效。
性能影响: 写入历史记录有轻微的性能开销。
索引命名: 历史索引以
.ism-history-前缀命名。滚动条件: 配合
max_docs和max_age控制索引大小。保留期: 旧历史索引会根据保留期配置自动删除。
查询访问: 需要相应权限才能访问历史索引。
监控建议: 监控历史索引的大小和增长速度。
备份考虑: 历史记录应包含在备份策略中。





