From 5b13cc48efd32ad5859eee98d99900ebc3a9763a Mon Sep 17 00:00:00 2001 From: Damien de Lemeny Date: Tue, 20 Feb 2024 15:19:58 -0500 Subject: [PATCH] Skip processing when frame is empty --- src/datasource/processResponse.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/datasource/processResponse.ts b/src/datasource/processResponse.ts index c22670c..1cf1737 100644 --- a/src/datasource/processResponse.ts +++ b/src/datasource/processResponse.ts @@ -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"; @@ -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 = []; @@ -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: {},