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.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
fix(infrastructure-monitoring): migrate having clause to new format (#12467)
Vinicius Lourençod7aa63f1bc13
diff --git a/frontend/src/container/InfraMonitoringHostsV2/constants.tsx b/frontend/src/container/InfraMonitoringHostsV2/constants.tsxindex a5df84e1b9..5d26874f21 100644--- a/frontend/src/container/InfraMonitoringHostsV2/constants.tsx+++ b/frontend/src/container/InfraMonitoringHostsV2/constants.tsx@@ -82,7 +82,7 @@ export function getHostMetricsQueryPayload(start: number,end: number,): ReturnType<typeof getHostQueryPayload> {- return getHostQueryPayload(host.hostName, start, end);+ return getHostQueryPayload(host.hostName, start, end, true);}export { hostWidgetInfo };diff --git a/frontend/src/container/InfraMonitoringK8sV2/Clusters/constants.ts b/frontend/src/container/InfraMonitoringK8sV2/Clusters/constants.tsindex 6754c6d4e5..4fae185215 100644--- a/frontend/src/container/InfraMonitoringK8sV2/Clusters/constants.ts+++ b/frontend/src/container/InfraMonitoringK8sV2/Clusters/constants.ts@@ -562,13 +562,9 @@ export const getClusterMetricsQueryPayload = (type: 'tag',},],- having: [- {- columnName: `MAX(${INFRA_MONITORING_ATTR_KEYS.K8S_NODE_CONDITION_READY})`,- op: '=',- value: 1,- },- ],+ having: {+ expression: `max(${INFRA_MONITORING_ATTR_KEYS.K8S_NODE_CONDITION_READY}) = 1`,+ },legend: `{{${INFRA_MONITORING_ATTR_KEYS.K8S_NODE_NAME}}}`,limit: null,orderBy: [],@@ -648,13 +644,9 @@ export const getClusterMetricsQueryPayload = (type: 'tag',},],- having: [- {- columnName: `MAX(${INFRA_MONITORING_ATTR_KEYS.K8S_NODE_CONDITION_READY})`,- op: '=',- value: 0,- },- ],+ having: {+ expression: `max(${INFRA_MONITORING_ATTR_KEYS.K8S_NODE_CONDITION_READY}) = 0`,+ },legend: `{{${INFRA_MONITORING_ATTR_KEYS.K8S_NODE_NAME}}}`,limit: null,orderBy: [],diff --git a/frontend/src/container/InfraMonitoringK8sV2/Namespaces/constants.ts b/frontend/src/container/InfraMonitoringK8sV2/Namespaces/constants.tsindex 43266403f9..5755829eb7 100644--- a/frontend/src/container/InfraMonitoringK8sV2/Namespaces/constants.ts+++ b/frontend/src/container/InfraMonitoringK8sV2/Namespaces/constants.ts@@ -1208,13 +1208,9 @@ export const getNamespaceMetricsQueryPayload = (type: 'tag',},],- having: [- {- columnName: `MAX(${INFRA_MONITORING_ATTR_KEYS.K8S_REPLICASET_DESIRED})`,- op: '>',- value: 0,- },- ],+ having: {+ expression: `max(${INFRA_MONITORING_ATTR_KEYS.K8S_REPLICASET_DESIRED}) > 0`,+ },legend: 'desired',limit: null,orderBy: [],@@ -1261,13 +1257,9 @@ export const getNamespaceMetricsQueryPayload = (type: 'tag',},],- having: [- {- columnName: `MAX(${INFRA_MONITORING_ATTR_KEYS.K8S_REPLICASET_DESIRED})`,- op: '>',- value: 0,- },- ],+ having: {+ expression: `max(${INFRA_MONITORING_ATTR_KEYS.K8S_REPLICASET_AVAILABLE}) > 0`,+ },legend: 'available',limit: null,orderBy: [],diff --git a/frontend/src/container/LogDetailedView/InfraMetrics/constants.ts b/frontend/src/container/LogDetailedView/InfraMetrics/constants.tsindex b058437bf9..9aa9e9e171 100644--- a/frontend/src/container/LogDetailedView/InfraMetrics/constants.ts+++ b/frontend/src/container/LogDetailedView/InfraMetrics/constants.ts@@ -1,9 +1,19 @@import { PANEL_TYPES } from 'constants/queryBuilder';import { GetQueryResultsProps } from 'lib/dashboard/getQueryResults';+import type { Having } from 'types/api/queryBuilder/queryBuilderData';import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';+import type { Having as HavingV5 } from 'types/api/v5/queryRange';import { EQueryType } from 'types/common/dashboard';import { DataSource, ReduceOperators } from 'types/common/queryBuilder';+const buildSumGreaterThanZeroHaving = (+ metricKey: string,+ useV5HavingFormat: boolean,+): Having[] | HavingV5 =>+ useV5HavingFormat+ ? { expression: `sum(${metricKey}) > 0` }+ : [{ columnName: `SUM(${metricKey})`, op: '>', value: 0 }];+export const getPodQueryPayload = (clusterName: string,podName: string,@@ -1540,6 +1550,7 @@ export const getHostQueryPayload = (hostName: string,start: number,end: number,+ useV5HavingFormat = false,): GetQueryResultsProps[] => {const hostNameKey = 'host.name';const cpuTimeKey = 'system.cpu.time';@@ -1802,13 +1813,7 @@ export const getHostQueryPayload = (type: 'tag',},],- having: [- {- columnName: `SUM(${fsUsageKey})`,- op: '>',- value: 0,- },- ],+ having: buildSumGreaterThanZeroHaving(fsUsageKey, useV5HavingFormat),legend: '{{mountpoint}}',limit: null,orderBy: [],@@ -1857,13 +1862,7 @@ export const getHostQueryPayload = (type: 'tag',},],- having: [- {- columnName: `SUM(${fsUsageKey})`,- op: '>',- value: 0,- },- ],+ having: buildSumGreaterThanZeroHaving(fsUsageKey, useV5HavingFormat),legend: '{{mountpoint}}',limit: null,orderBy: [],@@ -2089,13 +2088,7 @@ export const getHostQueryPayload = (type: 'tag',},],- having: [- {- columnName: `SUM(${netIoKey})`,- op: '>',- value: 0,- },- ],+ having: buildSumGreaterThanZeroHaving(netIoKey, useV5HavingFormat),legend: '{{device}}::{{direction}}',limit: 30,orderBy: [],@@ -2551,13 +2544,7 @@ export const getHostQueryPayload = (type: 'tag',},],- having: [- {- columnName: `SUM(${diskOpsKey})`,- op: '>',- value: 0,- },- ],+ having: buildSumGreaterThanZeroHaving(diskOpsKey, useV5HavingFormat),legend: '{{device}}::{{direction}}',limit: null,orderBy: [],@@ -2626,13 +2613,7 @@ export const getHostQueryPayload = (type: 'tag',},],- having: [- {- columnName: `SUM(${diskPendingKey})`,- op: '>',- value: 0,- },- ],+ having: buildSumGreaterThanZeroHaving(diskPendingKey, useV5HavingFormat),legend: '{{device}}',limit: null,orderBy: [],@@ -2708,13 +2689,7 @@ export const getHostQueryPayload = (type: 'tag',},],- having: [- {- columnName: `SUM(${diskOpTimeKey})`,- op: '>',- value: 0,- },- ],+ having: buildSumGreaterThanZeroHaving(diskOpTimeKey, useV5HavingFormat),legend: '{{device}}::{{direction}}',limit: null,orderBy: [],