Elasticsearch: Fix processing of logs with not-recognized time format (#67767)

* Elasticsearch: Fix parsing of invalid time

* Fix lint

* Add more test data to data.js

* Add tests

* Fix lint

* Update pkg/tsdb/elasticsearch/client/search_request.go
This commit is contained in:
Ivana Huckova
2023-05-04 19:33:00 +02:00
committed by GitHub
parent 49ff85ef54
commit 95cf598423
8 changed files with 142 additions and 37 deletions

View File

@@ -64,6 +64,18 @@ async function elasticSetupIndexTemplate() {
'@timestamp': {
type: 'date',
},
'@timestamp_custom': {
type: 'date',
format: 'yyyy_MM_dd_HH_mm_ss'
},
'@timestamp_unix': {
type: 'date',
format: 'epoch_millis'
},
'@timestamp_nanos': {
type: 'date_nanos',
format: 'strict_date_optional_time_nanos'
},
counter: {
type: 'integer',
},
@@ -115,6 +127,9 @@ function getRandomLogItem(counter, timestamp) {
const maybeAnsiText = Math.random() < 0.5 ? 'with ANSI \u001b[31mpart of the text\u001b[0m' : '';
return {
'@timestamp': timestamp.toISOString(),
'@timestamp_custom': timestamp.toISOString().split('.')[0].replace(/[T:-]/g,'_'),
'@timestamp_unix': timestamp.getTime(),
'@timestamp_nanos': timestamp.toISOString().slice(0,-1) + '123Z',
line: `log text ${maybeAnsiText} [${randomText}]`,
counter: counter.toString(),
float: 100 * Math.random().toString(),