Skip to content

Commit

Permalink
Skip processing when frame is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelemeny committed Feb 20, 2024
1 parent f06cc0f commit 5b13cc4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/datasource/processResponse.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DataFrame, DataLink, DataQueryRequest, DataQueryResponse, FieldType } from "@grafana/data";
import { DataFrame, DataLink, DataQueryRequest, DataQueryResponse, Field, FieldType } from "@grafana/data";
import { getDataSourceSrv } from "@grafana/runtime";
import { QuickwitDataSource } from 'datasource';
import { DataLinkConfig, ElasticsearchQuery } from "../types";
Expand All @@ -22,6 +22,10 @@ export function processLogsDataFrame(datasource: QuickwitDataSource, dataFrame:
if (!dataFrame.refId || dataFrame.refId.startsWith('log-volume')) {
return;
}
// Skip empty dataframes
if (dataFrame.length===0 || dataFrame.fields.length === 0) {
return;
}
if (datasource.logMessageField) {
const messageFields = datasource.logMessageField.split(',');
let field_idx_list = [];
Expand All @@ -45,7 +49,7 @@ export function processLogsDataFrame(datasource: QuickwitDataSource, dataFrame:
displayedMessages[idx] = displayedMessage.trim();
}

const newField = {
const newField: Field = {
name: getCustomFieldName('message'),
type: FieldType.string,
config: {},
Expand Down

0 comments on commit 5b13cc4

Please sign in to comment.