diff --git a/x-pack/filebeat/input/httpjson/config.go b/x-pack/filebeat/input/httpjson/config.go index ee1445b8a3d..6384811aaa4 100644 --- a/x-pack/filebeat/input/httpjson/config.go +++ b/x-pack/filebeat/input/httpjson/config.go @@ -125,10 +125,15 @@ func (dc *dateCursorConfig) 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 } diff --git a/x-pack/filebeat/input/httpjson/config_test.go b/x-pack/filebeat/input/httpjson/config_test.go index 1986ee7abe9..85c7c64848d 100644 --- a/x-pack/filebeat/input/httpjson/config_test.go +++ b/x-pack/filebeat/input/httpjson/config_test.go @@ -362,7 +362,6 @@ func TestConfigOauth2Validation(t *testing.T) { "url": "localhost", }, }, - /* Flaky test: https://github.com/elastic/beats/issues/21748 { name: "date_cursor.date_format will fail if invalid", expectedErr: "invalid configuration: date_format is not a valid date layout accessing 'date_cursor'", @@ -371,7 +370,6 @@ func TestConfigOauth2Validation(t *testing.T) { "url": "localhost", }, }, - */ { name: "date_cursor must work with a valid date_format", input: map[string]interface{}{