Skywalking 凌晨出现 index_not_found_exception
背景
Skywalking 每天凌晨 0 点之后,会出现连续几分钟的 index_not_found_exception
异常,提示要插入数据的索引不存在:
{
"error": {
"root_cause": [
{
"type": "index_not_found_exception",
"reason": "no such index [swtest_records-all-20241118]",
"index_uuid": "_na_",
"index": "swtest_records-all-20241118"
}
],
"type": "index_not_found_exception",
"reason": "no such index [swtest_records-all-20241118]",
"index_uuid": "_na_",
"index": "swtest_records-all-20241118"
},
"status": 404
}
大概描述一下我的配置和参数情况:
OAP 版本 10.1.0,存储使用的是阿里云 ES,指标 ttl 为 7 天,trace ttl 为 3 天,dayStep 为 1 天,并且使用了合并索引配置。
按照这个设置,默认每天都会有新的索引创建,但现在的问题就出现在新的一天开始时的那一小段时间里,索引是未创建的。
问题原因
先直接说结论:我们使用的阿里云 ES 默认不支持自动创建索引,但 Skywalking
需要依赖该能力做索引自动创建,
Skywalking creates index template, new index created driven by data. So, if template is there, it should create automatically.
所以在新的一天开始后,写入的数据无法创建对应的索引,一直提示索引不存在。
而过了一段时间之后,索引继续存在,其原因是有一个 ttl 定时任务,在该任务当中,创建了 lastWriteIndex
(点击查看),也就是当天的索引,而该任务的执行周期默认是 5 min,也就出现了这个现象:
每天凌晨总有一段时间报错索引不存在。
解决思路
根据ES 官方文档提示,增加对应的配置即可
PUT /_cluster/settings
{
"persistent": {
"action": {
"auto_create_index": "true"
}
}
}