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: Service Map environment filter not working with DOT_METRICS_ENABLED (#10227)

Ederson G. Elias6d78df2275df
diff --git a/frontend/src/container/ResourceAttributesFilter/ResourceAttributesFilter.tsx b/frontend/src/container/ResourceAttributesFilter/ResourceAttributesFilter.tsx
index 96e620f26f..41d3e954d2 100644
--- a/frontend/src/container/ResourceAttributesFilter/ResourceAttributesFilter.tsx
+++ b/frontend/src/container/ResourceAttributesFilter/ResourceAttributesFilter.tsx
@@ -95,7 +95,6 @@ function ResourceAttributesFilter({
data-testid="resource-environment-filter"
style={{ minWidth: 200, height: 34 }}
onChange={handleEnvironmentChange}
- onBlur={handleBlur}
>
{environments.map((opt) => (
<Select.Option key={opt.value} value={opt.value}>
diff --git a/frontend/src/hooks/useResourceAttribute/__tests__/whitelistedKeys.test.ts b/frontend/src/hooks/useResourceAttribute/__tests__/whitelistedKeys.test.ts
new file mode 100644
index 0000000000..ccb92f9b0e
--- /dev/null
+++ b/frontend/src/hooks/useResourceAttribute/__tests__/whitelistedKeys.test.ts
@@ -0,0 +1,77 @@
+import ROUTES from 'constants/routes';
+
+import { whilelistedKeys } from '../config';
+import { mappingWithRoutesAndKeys } from '../utils';
+
+describe('useResourceAttribute config', () => {
+ describe('whilelistedKeys', () => {
+ it('should include underscore-notation keys (DOT_METRICS_ENABLED=false)', () => {
+ expect(whilelistedKeys).toContain('resource_deployment_environment');
+ expect(whilelistedKeys).toContain('resource_k8s_cluster_name');
+ expect(whilelistedKeys).toContain('resource_k8s_cluster_namespace');
+ });
+
+ it('should include dot-notation keys (DOT_METRICS_ENABLED=true)', () => {
+ expect(whilelistedKeys).toContain('resource_deployment.environment');
+ expect(whilelistedKeys).toContain('resource_k8s.cluster.name');
+ expect(whilelistedKeys).toContain('resource_k8s.cluster.namespace');
+ });
+ });
+
+ describe('mappingWithRoutesAndKeys', () => {
+ const dotNotationFilters = [
+ {
+ label: 'deployment.environment',
+ value: 'resource_deployment.environment',
+ },
+ { label: 'k8s.cluster.name', value: 'resource_k8s.cluster.name' },
+ { label: 'k8s.cluster.namespace', value: 'resource_k8s.cluster.namespace' },
+ ];
+
+ const underscoreNotationFilters = [
+ {
+ label: 'deployment.environment',
+ value: 'resource_deployment_environment',
+ },
+ { label: 'k8s.cluster.name', value: 'resource_k8s_cluster_name' },
+ { label: 'k8s.cluster.namespace', value: 'resource_k8s_cluster_namespace' },
+ ];
+
+ const nonWhitelistedFilters = [
+ { label: 'host.name', value: 'resource_host_name' },
+ { label: 'service.name', value: 'resource_service_name' },
+ ];
+
+ it('should keep dot-notation filters on the Service Map route', () => {
+ const result = mappingWithRoutesAndKeys(
+ ROUTES.SERVICE_MAP,
+ dotNotationFilters,
+ );
+ expect(result).toHaveLength(3);
+ expect(result).toEqual(dotNotationFilters);
+ });
+
+ it('should keep underscore-notation filters on the Service Map route', () => {
+ const result = mappingWithRoutesAndKeys(
+ ROUTES.SERVICE_MAP,
+ underscoreNotationFilters,
+ );
+ expect(result).toHaveLength(3);
+ expect(result).toEqual(underscoreNotationFilters);
+ });
+
+ it('should filter out non-whitelisted keys on the Service Map route', () => {
+ const allFilters = [...dotNotationFilters, ...nonWhitelistedFilters];
+ const result = mappingWithRoutesAndKeys(ROUTES.SERVICE_MAP, allFilters);
+ expect(result).toHaveLength(3);
+ expect(result).toEqual(dotNotationFilters);
+ });
+
+ it('should return all filters on non-Service Map routes', () => {
+ const allFilters = [...dotNotationFilters, ...nonWhitelistedFilters];
+ const result = mappingWithRoutesAndKeys('/services', allFilters);
+ expect(result).toHaveLength(5);
+ expect(result).toEqual(allFilters);
+ });
+ });
+});
diff --git a/frontend/src/hooks/useResourceAttribute/config.ts b/frontend/src/hooks/useResourceAttribute/config.ts
index f15a8ccf60..b5e27a3a77 100644
--- a/frontend/src/hooks/useResourceAttribute/config.ts
+++ b/frontend/src/hooks/useResourceAttribute/config.ts
@@ -1,5 +1,8 @@
export const whilelistedKeys = [
'resource_deployment_environment',
+ 'resource_deployment.environment',
'resource_k8s_cluster_name',
+ 'resource_k8s.cluster.name',
'resource_k8s_cluster_namespace',
+ 'resource_k8s.cluster.namespace',
];