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
pull/70756/head
Gábor Farkas 2 years ago committed by GitHub
parent 2738a3a6da
commit 8e9ec9dcef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      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],
},
],
};

Loading…
Cancel
Save