Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

fix(FE): variables with multiple values are merged into one string (#2960)

Marco Schlichtaada9060da50
diff --git a/frontend/src/container/NewDashboard/DashboardVariablesSelection/VariableItem.tsx b/frontend/src/container/NewDashboard/DashboardVariablesSelection/VariableItem.tsx
index ef85297d92..264f657363 100644
--- a/frontend/src/container/NewDashboard/DashboardVariablesSelection/VariableItem.tsx
+++ b/frontend/src/container/NewDashboard/DashboardVariablesSelection/VariableItem.tsx
@@ -5,7 +5,7 @@ import query from 'api/dashboard/variables/query';
import { commaValuesParser } from 'lib/dashbaordVariables/customCommaValuesParser';
import sortValues from 'lib/dashbaordVariables/sortVariableValues';
import map from 'lodash-es/map';
-import { memo, useCallback, useEffect, useState } from 'react';
+import { memo, useCallback, useEffect, useMemo, useState } from 'react';
import { IDashboardVariable } from 'types/api/dashboard/getAll';
import { variablePropsToPayloadVariables } from '../utils';
@@ -24,6 +24,16 @@ interface VariableItemProps {
onAllSelectedUpdate: (name: string, arg1: boolean) => void;
lastUpdatedVar: string;
}
+
+const getSelectValue = (
+ selectedValue: IDashboardVariable['selectedValue'],
+): string | string[] => {
+ if (Array.isArray(selectedValue)) {
+ return selectedValue.map((item) => item.toString());
+ }
+ return selectedValue?.toString() || '';
+};
+
function VariableItem({
variableData,
existingVariables,
@@ -141,9 +151,15 @@ function VariableItem({
}
};
+ const { selectedValue } = variableData;
+ const selectedValueStringified = useMemo(() => getSelectValue(selectedValue), [
+ selectedValue,
+ ]);
+
const selectValue = variableData.allSelected
? 'ALL'
- : variableData.selectedValue?.toString() || '';
+ : selectedValueStringified;
+
const mode =
variableData.multiSelect && !variableData.allSelected
? 'multiple'