Skip to content

Commit

Permalink
Merge pull request #86 from quickwit-oss/ddelemeny/skip-empty-frames
Browse files Browse the repository at this point in the history
Skip processing when frame is empty
  • Loading branch information
fmassot authored Feb 20, 2024
2 parents f06cc0f + 5b13cc4 commit 896f760
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 896f760

Please sign in to comment.