适用版本: 6.8-8.x
1. 错误说明 #
报错 failed to parse [<type>] action [<watch_id>/<action_id>]. missing required [message] field 表示 Watcher 在解析某个 action 时,没有找到必填的 message 字段。
附录代码已经表明,这个 action 在构造返回对象之前会先检查 message == null。只要 message 没有被解析到,就不会继续创建 action,而是直接报错。
2. 常见触发场景 #
- 配置 Slack action 时遗漏了
message。 message被放进了错误层级,导致解析器根本读不到。- 模板变量为空,最终渲染后整个
message字段被省略。
错误示例:
{
"actions": {
"notify-slack": {
"slack": {
"account": "team-default"
}
}
}
}
3. 排查方法 #
- 根据
watch_id/action_id找到对应 action 配置。 - 确认
message是否真的存在于该 action 的正确层级。 - 如果使用模板生成 Watcher,检查模板变量为空时是否会删除整个字段。
- 对最终下发到 Elasticsearch 的 JSON 做一次最小回放,确认
message没有在中间流程中丢失。
4. 修复方法 #
- 为该 action 补齐
message字段。 - 确保
message位于当前 action 类型允许的位置,而不是嵌套在错误对象下。 - 对模板或配置中心增加必填字段校验,提交前直接拒绝不完整配置。
修正示例:
{
"actions": {
"notify-slack": {
"slack": {
"account": "team-default",
"message": {
"text": "cluster health is red"
}
}
}
}
}
5. 预防建议 #
- 对 Watcher action 建立必填字段清单,做发布前校验。
- 在模板渲染阶段区分“空字符串”和“字段缺失”,避免静默吞掉关键字段。
- 为常见 action 类型准备可复用模板,减少手写配置遗漏。
相关错误 #
- 解析 action 失败:字段本应为字符串却收到其他类型
- 解析 action 失败:无法解析 fields 字段
- 解析 action 失败:出现意外的 token
- 解析 action 失败:出现意外的字符串字段
附:日志上下文 #
actionId; token);
}
} if (message == null) {
throw new ElasticsearchParseException("failed to parse [{}] action [{}/{}]. missing required [{}] field"; TYPE; watchId;
actionId; Field.MESSAGE.getPreferredName());
} return new SlackAction(account; message; proxy);
}





