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
This commit is contained in:
Gábor Farkas 2023-06-27 14:04:29 +02:00 committed by GitHub
parent 2738a3a6da
commit 8e9ec9dcef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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],
},
],
};