[v10.0.x] Elasticsearch: Make it compatible with the new log context functionality (#70748)

Elasticsearch: Make it compatible with the new log context functionality (#70697)

(cherry picked from commit 8e9ec9dcef)
This commit is contained in:
Gábor Farkas
2023-06-27 14:31:42 +02:00
committed by GitHub
parent b78a4d7d39
commit 7499db7060
@@ -28,6 +28,7 @@ import {
SupplementaryQueryOptions,
DataQueryError,
rangeUtil,
ensureTimeField,
Field,
LogRowContextQueryDirection,
LogRowContextOptions,
@@ -577,12 +578,13 @@ export class ElasticDatasource
*/
const timestampField = dataFrame.fields.find((f: Field) => f.name === this.timeField);
const lineField = dataFrame.fields.find((f: Field) => f.name === this.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],
},
],
};