Could not parse watch unexpected token – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-8.9

Briefly, this error occurs when Elasticsearch tries to parse a watch definition and encounters an unexpected token. This usually happens due to a syntax error in the watch definition, such as a missing or misplaced bracket, comma, or quotation mark. To resolve this issue, you should carefully review the watch definition for any syntax errors. Make sure that all brackets, commas, and quotation marks are correctly placed. Also, ensure that the watch definition is correctly formatted as a JSON object. If the error persists, try to simplify the watch definition to identify the problematic part.

This guide will help you check for common problems that cause the log ” could not parse watch [{}]; unexpected token [{}] ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: plugin.

Log Context

Log “could not parse watch [{}]; unexpected token [{}]” class name is WatchParser.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 if (token == null) {
 throw new ElasticsearchParseException("could not parse watch [{}]. null token"; id);
 } else if (token == XContentParser.Token.FIELD_NAME) {
 currentFieldName = parser.currentName();
 } else if (currentFieldName == null) {
 throw new ElasticsearchParseException("could not parse watch [{}]; unexpected token [{}]"; id; token);
 } else if (WatchField.TRIGGER.match(currentFieldName; parser.getDeprecationHandler())) {
 trigger = triggerService.parseTrigger(id; parser);
 } else if (WatchField.INPUT.match(currentFieldName; parser.getDeprecationHandler())) {
 input = inputRegistry.parse(id; parser);
 } else if (WatchField.CONDITION.match(currentFieldName; parser.getDeprecationHandler())) {

 

How helpful was this guide?

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?