适用版本: 6.8-8.x
1. 错误异常的基本描述 #
could not parse [search] input for watch [id]. failed to parse [request] 表示 Watcher 已经确认这是一个 search input,并开始解析 request 字段,但 WatcherSearchTemplateRequest.fromXContent(...) 在处理这个请求片段时失败了。
这说明问题不在 input 类型名,而是在 request 里的搜索请求结构。
2. 为什么会发生这个错误 #
request不是合法对象,或者其中的indices、body、template结构错误。- 搜索 DSL 本身格式不合法。
- 模板渲染后出现了多余逗号、错误类型、未替换占位符。
- 把普通
_search请求示例直接复制到 watch 中,但字段层级不符合 Watcher 的要求。
3. 如何排查和解决这个异常和解决这个异常 #
- 单独抽出
input.search.request,作为最小片段检查。 - 先验证
indices、search_type、body这些核心字段的类型是否正确。 - 如果使用模板,查看渲染后的最终 JSON,而不是模板原文。
- 必要时把
body拿到_search接口单独验证,确认 DSL 本身可执行。
4. 如何解决这个错误 #
错误示例:
{
"input": {
"search": {
"request": {
"indices": "logs-*",
"body": "{ \"query\": { \"match_all\": {} } }"
}
}
}
}
修正示例:
{
"input": {
"search": {
"request": {
"indices": ["logs-*"],
"body": {
"query": {
"match_all": {}
}
}
}
}
}
}
5. 小结 #
failed to parse [request] 的核心是 request 块本身不合法。优先把 request 单独拿出来验证,而不是从触发器、条件或 action 开始排查。
相关错误 #
附:日志上下文 #
currentFieldName = parser.currentName();
} else if (Field.REQUEST.match(currentFieldName, parser.getDeprecationHandler())) {
try {
request = WatcherSearchTemplateRequest.fromXContent(parser, ExecutableSearchInput.DEFAULT_SEARCH_TYPE);
} catch (ElasticsearchParseException srpe) {
throw new ElasticsearchParseException("could not parse [{}] input for watch [{}]. failed to parse [{}]", srpe, TYPE,
watchId, currentFieldName);
}
} else if (token == XContentParser.Token.START_ARRAY) {
if (Field.EXTRACT.match(currentFieldName, parser.getDeprecationHandler())) {
extract = new HashSet<>();





