From 8e9ec9dcef5dd7eb7efbcd19b8a699de9ad48b0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Farkas?= Date: Tue, 27 Jun 2023 14:04:29 +0200 Subject: [PATCH] Elasticsearch: Make it compatible with the new log context functionality (#70697) * elastic: make it work with the new logs-context * add remaining fields * lint fix --- .../app/plugins/datasource/elasticsearch/LegacyQueryRunner.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/elasticsearch/LegacyQueryRunner.ts b/public/app/plugins/datasource/elasticsearch/LegacyQueryRunner.ts index 3bc2126b77c..c70a6ee60b2 100644 --- a/public/app/plugins/datasource/elasticsearch/LegacyQueryRunner.ts +++ b/public/app/plugins/datasource/elasticsearch/LegacyQueryRunner.ts @@ -7,6 +7,7 @@ import { DataQueryRequest, DataQueryResponse, dateTime, + ensureTimeField, Field, LogRowContextOptions, LogRowContextQueryDirection, @@ -134,12 +135,13 @@ export class LegacyQueryRunner { */ const timestampField = dataFrame.fields.find((f: Field) => f.name === this.datasource.timeField); const lineField = dataFrame.fields.find((f: Field) => f.name === this.datasource.logMessageField); + const otherFields = dataFrame.fields.filter((f: Field) => f !== timestampField && f !== lineField); if (timestampField && lineField) { return { data: [ { ...dataFrame, - fields: [...dataFrame.fields, { ...timestampField, name: 'ts' }, { ...lineField, name: 'line' }], + fields: [ensureTimeField(timestampField), lineField, ...otherFields], }, ], };