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: legend for empty metrics names list

Pranshu Chittorae88cfcd4daed
diff --git a/frontend/src/store/actions/dashboard/getQueryResults.ts b/frontend/src/store/actions/dashboard/getQueryResults.ts
index f1143a1431..17137b13c1 100644
--- a/frontend/src/store/actions/dashboard/getQueryResults.ts
+++ b/frontend/src/store/actions/dashboard/getQueryResults.ts
@@ -143,17 +143,23 @@ export async function GetMetricQueryRange({
`API responded with ${response.statusCode} - ${response.error}`,
);
}
-
if (response.payload?.data?.result) {
response.payload.data.result = response.payload.data.result.map(
(queryData) => {
const newQueryData = queryData;
- newQueryData.legend = legendMap[queryData.queryName];
+ newQueryData.legend = legendMap[queryData.queryName]; // Adds the legend if it is already defined by the user.
+ // If metric names is an empty object
if (isEmpty(queryData.metric)) {
- newQueryData.metric[queryData.queryName] = queryData.queryName;
- newQueryData.legend = queryData.queryName;
+ // If metrics list is empty && the user haven't defined a legend then add the legend equal to the name of the query.
+ if (!newQueryData.legend) {
+ newQueryData.legend = queryData.queryName;
+ }
+ // If name of the query and the legend if inserted is same then add the same to the metrics object.
+ if (queryData.queryName === newQueryData.legend) {
+ newQueryData.metric[queryData.queryName] = queryData.queryName;
+ }
}
- return queryData;
+ return newQueryData;
},
);
}