From 330ae55c6e37e703f38b87f4ddf275799d8cd252 Mon Sep 17 00:00:00 2001 From: Marc Guasch Date: Mon, 19 Oct 2020 18:02:48 +0200 Subject: [PATCH] [Filebeat][httpjson] Fix date_cursor validation (#21756) (#21982) * Fix date_cursor validation * Only check for parse errors (cherry picked from commit 15251d4741386162397c5bdecb752dcaaca29d02) --- x-pack/filebeat/input/httpjson/config.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/x-pack/filebeat/input/httpjson/config.go b/x-pack/filebeat/input/httpjson/config.go index 2be0eb6f211..7d2da55f45d 100644 --- a/x-pack/filebeat/input/httpjson/config.go +++ b/x-pack/filebeat/input/httpjson/config.go @@ -109,10 +109,15 @@ func (dc *DateCursor) Validate() error { if dc.DateFormat == "" { return nil } - now := time.Now().Format(dc.DateFormat) - if _, err := time.Parse(dc.DateFormat, now); err != nil { + + const knownTimestamp = 1602601228 // 2020-10-13T15:00:28+00:00 RFC3339 + knownDate := time.Unix(knownTimestamp, 0).UTC() + + dateStr := knownDate.Format(dc.DateFormat) + if _, err := time.Parse(dc.DateFormat, dateStr); err != nil { return errors.New("invalid configuration: date_format is not a valid date layout") } + return nil }