Cannot parse duration – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-7.17

Briefly, this error occurs when Elasticsearch is unable to parse the duration value provided in a request. This could be due to an incorrect format or an invalid value. To resolve this issue, ensure that the duration is specified in a format that Elasticsearch can understand, such as “5d” for five days or “2h” for two hours. Also, check that the value is valid and within the acceptable range. If the problem persists, consider checking your Elasticsearch version as some versions may have specific requirements for duration formatting.

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

Log Context

Log “Cannot parse duration [{}]” class name is Intervals.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 case SECOND:
 return Duration.ZERO.plusSeconds(duration);
 case MILLISECOND:
 return Duration.ZERO.plusMillis(duration);
 default:
 throw new ParsingException(source; "Cannot parse duration [{}]"; unit);
 }
 } catch (ArithmeticException ae) {
 throw new ParsingException(source; "Value [{}] cannot be used as it is too large to convert into [{}]s"; duration; unit);
 }
 }

 

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?