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.

chore: update APM metrics to use v4 query range (#4638)

Srikanth Chekurib3b7522250e4
diff --git a/frontend/src/api/metrics/getQueryRange.ts b/frontend/src/api/metrics/getQueryRange.ts
index a33cedee95..40deb021bc 100644
--- a/frontend/src/api/metrics/getQueryRange.ts
+++ b/frontend/src/api/metrics/getQueryRange.ts
@@ -1,6 +1,7 @@
import { ApiV3Instance, ApiV4Instance } from 'api';
import { ErrorResponseHandler } from 'api/ErrorResponseHandler';
import { AxiosError } from 'axios';
+import { ENTITY_VERSION_V4 } from 'constants/app';
import { ErrorResponse, SuccessResponse } from 'types/api';
import {
MetricRangePayloadV3,
@@ -13,7 +14,7 @@ export const getMetricsQueryRange = async (
signal: AbortSignal,
): Promise<SuccessResponse<MetricRangePayloadV3> | ErrorResponse> => {
try {
- if (version && version === 'v4') {
+ if (version && version === ENTITY_VERSION_V4) {
const response = await ApiV4Instance.post('/query_range', props, { signal });
return {
diff --git a/frontend/src/constants/app.ts b/frontend/src/constants/app.ts
index 3b7b0fc960..d260806856 100644
--- a/frontend/src/constants/app.ts
+++ b/frontend/src/constants/app.ts
@@ -15,3 +15,4 @@ export const SIGNOZ_UPGRADE_PLAN_URL =
export const DASHBOARD_TIME_IN_DURATION = 'refreshInterval';
export const DEFAULT_ENTITY_VERSION = 'v3';
+export const ENTITY_VERSION_V4 = 'v4';
diff --git a/frontend/src/container/CreateAlertRule/defaults.ts b/frontend/src/container/CreateAlertRule/defaults.ts
index fee6981881..677f4accc4 100644
--- a/frontend/src/container/CreateAlertRule/defaults.ts
+++ b/frontend/src/container/CreateAlertRule/defaults.ts
@@ -1,3 +1,4 @@
+import { ENTITY_VERSION_V4 } from 'constants/app';
import {
initialQueryBuilderFormValuesMap,
initialQueryPromQLData,
@@ -24,7 +25,7 @@ const defaultAnnotations = {
export const alertDefaults: AlertDef = {
alertType: AlertTypes.METRICS_BASED_ALERT,
- version: 'v4',
+ version: ENTITY_VERSION_V4,
condition: {
compositeQuery: {
builderQueries: {
diff --git a/frontend/src/container/CreateAlertRule/index.tsx b/frontend/src/container/CreateAlertRule/index.tsx
index 2ce3b9f1d3..a5924531b2 100644
--- a/frontend/src/container/CreateAlertRule/index.tsx
+++ b/frontend/src/container/CreateAlertRule/index.tsx
@@ -1,4 +1,5 @@
import { Form, Row } from 'antd';
+import { ENTITY_VERSION_V4 } from 'constants/app';
import FormAlertRules from 'container/FormAlertRules';
import { useGetCompositeQueryParam } from 'hooks/queryBuilder/useGetCompositeQueryParam';
import { useEffect, useState } from 'react';
@@ -44,7 +45,7 @@ function CreateRules(): JSX.Element {
default:
setInitValues({
...alertDefaults,
- version: version || 'v4',
+ version: version || ENTITY_VERSION_V4,
});
}
};
diff --git a/frontend/src/container/FormAlertRules/QuerySection.tsx b/frontend/src/container/FormAlertRules/QuerySection.tsx
index 66583ba058..1604cdb929 100644
--- a/frontend/src/container/FormAlertRules/QuerySection.tsx
+++ b/frontend/src/container/FormAlertRules/QuerySection.tsx
@@ -2,6 +2,7 @@ import './QuerySection.styles.scss';
import { Button, Tabs, Tooltip } from 'antd';
import { ALERTS_DATA_SOURCE_MAP } from 'constants/alerts';
+import { ENTITY_VERSION_V4 } from 'constants/app';
import { PANEL_TYPES } from 'constants/queryBuilder';
import { QBShortcuts } from 'constants/shortcuts/QBShortcuts';
import { QueryBuilder } from 'container/QueryBuilder';
@@ -55,7 +56,8 @@ function QuerySection({
initialDataSource: ALERTS_DATA_SOURCE_MAP[alertType],
}}
showFunctions={
- alertType === AlertTypes.METRICS_BASED_ALERT && alertDef.version === 'v4'
+ alertType === AlertTypes.METRICS_BASED_ALERT &&
+ alertDef.version === ENTITY_VERSION_V4
}
version={alertDef.version || 'v3'}
/>
diff --git a/frontend/src/container/GridCardLayout/GridCard/FullView/index.tsx b/frontend/src/container/GridCardLayout/GridCard/FullView/index.tsx
index a4d3fb5cbb..0b15adc345 100644
--- a/frontend/src/container/GridCardLayout/GridCard/FullView/index.tsx
+++ b/frontend/src/container/GridCardLayout/GridCard/FullView/index.tsx
@@ -40,6 +40,7 @@ function FullView({
fullViewOptions = true,
onClickHandler,
name,
+ version,
originalName,
yAxisUnit,
options,
@@ -97,7 +98,7 @@ function FullView({
globalSelectedInterval: globalSelectedTime,
variables: getDashboardVariables(selectedDashboard?.data.variables),
},
- selectedDashboard?.data?.version || DEFAULT_ENTITY_VERSION,
+ selectedDashboard?.data?.version || version || DEFAULT_ENTITY_VERSION,
{
queryKey: `FullViewGetMetricsQueryRange-${selectedTime.enum}-${globalSelectedTime}-${widget.id}`,
enabled: !isDependedDataLoaded && widget.panelTypes !== PANEL_TYPES.LIST, // Internally both the list view panel has it's own query range api call, so we don't need to call it again
diff --git a/frontend/src/container/GridCardLayout/GridCard/FullView/types.ts b/frontend/src/container/GridCardLayout/GridCard/FullView/types.ts
index a2ae598fd3..8ce23562fc 100644
--- a/frontend/src/container/GridCardLayout/GridCard/FullView/types.ts
+++ b/frontend/src/container/GridCardLayout/GridCard/FullView/types.ts
@@ -50,6 +50,7 @@ export interface FullViewProps {
fullViewOptions?: boolean;
onClickHandler?: OnClickPluginOpts['onClick'];
name: string;
+ version?: string;
originalName: string;
options: uPlot.Options;
yAxisUnit?: string;
diff --git a/frontend/src/container/GridCardLayout/GridCard/WidgetGraphComponent.tsx b/frontend/src/container/GridCardLayout/GridCard/WidgetGraphComponent.tsx
index a07a4197e9..b396697798 100644
--- a/frontend/src/container/GridCardLayout/GridCard/WidgetGraphComponent.tsx
+++ b/frontend/src/container/GridCardLayout/GridCard/WidgetGraphComponent.tsx
@@ -39,6 +39,7 @@ function WidgetGraphComponent({
queryResponse,
errorMessage,
name,
+ version,
threshold,
headerMenuList,
isWarning,
@@ -283,6 +284,7 @@ function WidgetGraphComponent({
>
<FullView
name={`${name}expanded`}
+ version={version}
originalName={name}
widget={widget}
yAxisUnit={widget.yAxisUnit}
diff --git a/frontend/src/container/GridCardLayout/GridCard/index.tsx b/frontend/src/container/GridCardLayout/GridCard/index.tsx
index 79aef8d554..46ba01b6a5 100644
--- a/frontend/src/container/GridCardLayout/GridCard/index.tsx
+++ b/frontend/src/container/GridCardLayout/GridCard/index.tsx
@@ -237,6 +237,7 @@ function GridCardGraph({
errorMessage={errorMessage}
isWarning={false}
name={name}
+ version={version}
onDragSelect={onDragSelect}
threshold={threshold}
headerMenuList={menuList}
diff --git a/frontend/src/container/GridCardLayout/GridCard/types.ts b/frontend/src/container/GridCardLayout/GridCard/types.ts
index b98bda5f83..9e527c143d 100644
--- a/frontend/src/container/GridCardLayout/GridCard/types.ts
+++ b/frontend/src/container/GridCardLayout/GridCard/types.ts
@@ -23,6 +23,7 @@ export interface WidgetGraphComponentProps extends UplotProps {
>;
errorMessage: string | undefined;
name: string;
+ version?: string;
onDragSelect: (start: number, end: number) => void;
onClickHandler?: OnClickPluginOpts['onClick'];
threshold?: ReactNode;
diff --git a/frontend/src/container/ListOfDashboard/DashboardsList.tsx b/frontend/src/container/ListOfDashboard/DashboardsList.tsx
index ccdcd1c15e..aea98141ba 100644
--- a/frontend/src/container/ListOfDashboard/DashboardsList.tsx
+++ b/frontend/src/container/ListOfDashboard/DashboardsList.tsx
@@ -10,6 +10,7 @@ import {
import DynamicColumnTable from 'components/ResizeTable/DynamicColumnTable';
import LabelColumn from 'components/TableRenderer/LabelColumn';
import TextToolTip from 'components/TextToolTip';
+import { ENTITY_VERSION_V4 } from 'constants/app';
import ROUTES from 'constants/routes';
import { useGetAllDashboard } from 'hooks/dashboard/useGetAllDashboard';
import useComponentPermission from 'hooks/useComponentPermission';
@@ -210,7 +211,7 @@ function DashboardsList(): JSX.Element {
ns: 'dashboard',
}),
uploadedGrafana: false,
- version: 'v4',
+ version: ENTITY_VERSION_V4,
});
if (response.statusCode === 200) {
diff --git a/frontend/src/container/MetricsApplication/MetricsPageQueries/DBCallQueries.ts b/frontend/src/container/MetricsApplication/MetricsPageQueries/DBCallQueries.ts
index 2cec9e823b..91343b7b06 100644
--- a/frontend/src/container/MetricsApplication/MetricsPageQueries/DBCallQueries.ts
+++ b/frontend/src/container/MetricsApplication/MetricsPageQueries/DBCallQueries.ts
@@ -113,9 +113,13 @@ export const databaseCallsAvgDuration = ({
const disabled = [true, true];
const legendFormulas = ['Average Duration'];
const expressions = [FORMULA.DATABASE_CALLS_AVG_DURATION];
- const aggregateOperators = [
- MetricAggregateOperator.SUM_RATE,
- MetricAggregateOperator.SUM_RATE,
+ const timeAggregateOperators = [
+ MetricAggregateOperator.RATE,
+ MetricAggregateOperator.RATE,
+ ];
+ const spaceAggregateOperators = [
+ MetricAggregateOperator.SUM,
+ MetricAggregateOperator.SUM,
];
const dataSource = DataSource.METRICS;
@@ -126,7 +130,8 @@ export const databaseCallsAvgDuration = ({
disabled,
expressions,
legendFormulas,
- aggregateOperators,
+ timeAggregateOperators,
+ spaceAggregateOperators,
dataSource,
});
};
diff --git a/frontend/src/container/MetricsApplication/MetricsPageQueries/ExternalQueries.ts b/frontend/src/container/MetricsApplication/MetricsPageQueries/ExternalQueries.ts
index 3375d3920a..a2c87f0874 100644
--- a/frontend/src/container/MetricsApplication/MetricsPageQueries/ExternalQueries.ts
+++ b/frontend/src/container/MetricsApplication/MetricsPageQueries/ExternalQueries.ts
@@ -93,9 +93,13 @@ export const externalCallErrorPercent = ({
const additionalItems = [additionalItemsA, additionalItemsB];
- const aggregateOperators = [
- MetricAggregateOperator.SUM_RATE,
- MetricAggregateOperator.SUM_RATE,
+ const timeAggregateOperators = [
+ MetricAggregateOperator.RATE,
+ MetricAggregateOperator.RATE,
+ ];
+ const spaceAggregateOperators = [
+ MetricAggregateOperator.SUM,
+ MetricAggregateOperator.SUM,
];
const legends = [legend, legend];
const dataSource = DataSource.METRICS;
@@ -108,7 +112,8 @@ export const externalCallErrorPercent = ({
disabled,
expressions,
legendFormulas,
- aggregateOperators,
+ timeAggregateOperators,
+ spaceAggregateOperators,
dataSource,
});
};
@@ -152,9 +157,13 @@ export const externalCallDuration = ({
const additionalItems = [additionalItemsA, additionalItemsA];
const legends = [legend, legend];
- const aggregateOperators = [
- MetricAggregateOperator.SUM_RATE,
- MetricAggregateOperator.SUM_RATE,
+ const timeAggregateOperators = [
+ MetricAggregateOperator.RATE,
+ MetricAggregateOperator.RATE,
+ ];
+ const spaceAggregateOperators = [
+ MetricAggregateOperator.SUM,
+ MetricAggregateOperator.SUM,
];
const dataSource = DataSource.METRICS;
@@ -165,7 +174,8 @@ export const externalCallDuration = ({
disabled,
expressions,
legendFormulas,
- aggregateOperators,
+ timeAggregateOperators,
+ spaceAggregateOperators,
dataSource,
});
};
@@ -250,9 +260,13 @@ export const externalCallDurationByAddress = ({
const autocompleteData = [autocompleteDataA, autocompleteDataB];
const additionalItems = [additionalItemsA, additionalItemsA];
const legends = [legend, legend];
- const aggregateOperators = [
- MetricAggregateOperator.SUM_RATE,
- MetricAggregateOperator.SUM_RATE,
+ const timeAggregateOperators = [
+ MetricAggregateOperator.RATE,
+ MetricAggregateOperator.RATE,
+ ];
+ const spaceAggregateOperators = [
+ MetricAggregateOperator.SUM,
+ MetricAggregateOperator.SUM,
];
const dataSource = DataSource.METRICS;
@@ -264,7 +278,8 @@ export const externalCallDurationByAddress = ({
disabled,
expressions,
legendFormulas,
- aggregateOperators,
+ timeAggregateOperators,
+ spaceAggregateOperators,
dataSource,
});
};
diff --git a/frontend/src/container/MetricsApplication/MetricsPageQueries/MetricsPageQueriesFactory.ts b/frontend/src/container/MetricsApplication/MetricsPageQueries/MetricsPageQueriesFactory.ts
index 2f80415aba..71a16fcc07 100644
--- a/frontend/src/container/MetricsApplication/MetricsPageQueries/MetricsPageQueriesFactory.ts
+++ b/frontend/src/container/MetricsApplication/MetricsPageQueries/MetricsPageQueriesFactory.ts
@@ -9,6 +9,7 @@ import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
import {
MetricAggregateOperator,
QueryBuilderData,
+ Temporality,
} from 'types/common/queryBuilder';
import {
@@ -69,7 +70,8 @@ export const getQueryBuilderQuerieswithFormula = ({
disabled,
expressions,
legendFormulas,
- aggregateOperators,
+ timeAggregateOperators,
+ spaceAggregateOperators,
dataSource,
}: BuilderQuerieswithFormulaProps): QueryBuilderData => ({
queryFormulas: expressions.map((expression, index) => ({
@@ -79,7 +81,9 @@ export const getQueryBuilderQuerieswithFormula = ({
})),
queryData: autocompleteData.map((_, index) => ({
...initialQueryBuilderFormValuesMap.metrics,
- aggregateOperator: aggregateOperators[index],
+ timeAggregation: timeAggregateOperators[index],
+ spaceAggregation: spaceAggregateOperators[index],
+ temporality: Temporality.Delta,
disabled: disabled[index],
groupBy,
legend: legends[index],
diff --git a/frontend/src/container/MetricsApplication/MetricsPageQueries/OverviewQueries.ts b/frontend/src/container/MetricsApplication/MetricsPageQueries/OverviewQueries.ts
index 3186931891..d27bfc01be 100644
--- a/frontend/src/container/MetricsApplication/MetricsPageQueries/OverviewQueries.ts
+++ b/frontend/src/container/MetricsApplication/MetricsPageQueries/OverviewQueries.ts
@@ -250,11 +250,16 @@ export const apDexTracesQueryBuilderQueries = ({
const disabled = Array(3).fill(true);
const expressions = [FORMULA.APDEX_TRACES];
const legendFormulas = [GraphTitle.APDEX];
- const aggregateOperators = [
+ const timeAggregateOperators = [
MetricAggregateOperator.COUNT,
MetricAggregateOperator.COUNT,
MetricAggregateOperator.COUNT,
];
+ const spaceAggregateOperators = [
+ MetricAggregateOperator.EMPTY,
+ MetricAggregateOperator.EMPTY,
+ MetricAggregateOperator.EMPTY,
+ ];
const dataSource = DataSource.TRACES;
return getQueryBuilderQuerieswithFormula({
@@ -264,7 +269,8 @@ export const apDexTracesQueryBuilderQueries = ({
disabled,
expressions,
legendFormulas,
- aggregateOperators,
+ timeAggregateOperators,
+ spaceAggregateOperators,
dataSource,
});
};
@@ -433,10 +439,16 @@ export const apDexMetricsQueryBuilderQueries = ({
? [FORMULA.APDEX_DELTA_SPAN_METRICS]
: [FORMULA.APDEX_CUMULATIVE_SPAN_METRICS];
const legendFormulas = [GraphTitle.APDEX];
- const aggregateOperators = [
- MetricAggregateOperator.SUM_RATE,
- MetricAggregateOperator.SUM_RATE,
- MetricAggregateOperator.SUM_RATE,
+ const timeAggregateOperators = [
+ MetricAggregateOperator.RATE,
+ MetricAggregateOperator.RATE,
+ MetricAggregateOperator.RATE,
+ ];
+
+ const spaceAggregateOperators = [
+ MetricAggregateOperator.SUM,
+ MetricAggregateOperator.SUM,
+ MetricAggregateOperator.SUM,
];
const dataSource = DataSource.METRICS;
@@ -447,7 +459,8 @@ export const apDexMetricsQueryBuilderQueries = ({
disabled,
expressions,
legendFormulas,
- aggregateOperators,
+ timeAggregateOperators,
+ spaceAggregateOperators,
dataSource,
});
};
@@ -593,9 +606,13 @@ export const errorPercentage = ({
const disabled = [true, true];
const expressions = [FORMULA.ERROR_PERCENTAGE];
const legendFormulas = [GraphTitle.ERROR_PERCENTAGE];
- const aggregateOperators = [
- MetricAggregateOperator.SUM_RATE,
- MetricAggregateOperator.SUM_RATE,
+ const timeAggregateOperators = [
+ MetricAggregateOperator.RATE,
+ MetricAggregateOperator.RATE,
+ ];
+ const spaceAggregateOperators = [
+ MetricAggregateOperator.SUM,
+ MetricAggregateOperator.SUM,
];
const dataSource = DataSource.METRICS;
@@ -606,7 +623,8 @@ export const errorPercentage = ({
disabled,
expressions,
legendFormulas,
- aggregateOperators,
+ timeAggregateOperators,
+ spaceAggregateOperators,
dataSource,
});
};
diff --git a/frontend/src/container/MetricsApplication/MetricsPageQueries/TopOperationQueries.ts b/frontend/src/container/MetricsApplication/MetricsPageQueries/TopOperationQueries.ts
index 225e2084cd..18f0d07a88 100644
--- a/frontend/src/container/MetricsApplication/MetricsPageQueries/TopOperationQueries.ts
+++ b/frontend/src/container/MetricsApplication/MetricsPageQueries/TopOperationQueries.ts
@@ -118,13 +118,21 @@ export const topOperationQueries = ({
KeyOperationTableHeader.ERROR_RATE,
KeyOperationTableHeader.NUM_OF_CALLS,
];
- const aggregateOperators = [
- MetricAggregateOperator.HIST_QUANTILE_50,
- MetricAggregateOperator.HIST_QUANTILE_90,
- MetricAggregateOperator.HIST_QUANTILE_99,
- MetricAggregateOperator.SUM_RATE,
- MetricAggregateOperator.SUM_RATE,
- MetricAggregateOperator.SUM_RATE,
+ const timeAggregateOperators = [
+ MetricAggregateOperator.EMPTY,
+ MetricAggregateOperator.EMPTY,
+ MetricAggregateOperator.EMPTY,
+ MetricAggregateOperator.RATE,
+ MetricAggregateOperator.RATE,
+ MetricAggregateOperator.RATE,
+ ];
+ const spaceAggregateOperators = [
+ MetricAggregateOperator.P50,
+ MetricAggregateOperator.P90,
+ MetricAggregateOperator.P99,
+ MetricAggregateOperator.SUM,
+ MetricAggregateOperator.SUM,
+ MetricAggregateOperator.SUM,
];
const expressions = ['D*100/E'];
const legendFormulas = [GraphTitle.ERROR_PERCENTAGE];
@@ -135,7 +143,8 @@ export const topOperationQueries = ({
additionalItems,
disabled,
legends,
- aggregateOperators,
+ timeAggregateOperators,
+ spaceAggregateOperators,
expressions,
legendFormulas,
dataSource,
diff --git a/frontend/src/container/MetricsApplication/Tabs/DBCall.tsx b/frontend/src/container/MetricsApplication/Tabs/DBCall.tsx
index 31ed0769bf..ab88a8d7dc 100644
--- a/frontend/src/container/MetricsApplication/Tabs/DBCall.tsx
+++ b/frontend/src/container/MetricsApplication/Tabs/DBCall.tsx
@@ -1,4 +1,5 @@
import { Col } from 'antd';
+import { ENTITY_VERSION_V4 } from 'constants/app';
import { PANEL_TYPES } from 'constants/queryBuilder';
import Graph from 'container/GridCardLayout/GridCard';
import {
@@ -121,6 +122,7 @@ function DBCall(): JSX.Element {
'database_call_rps',
);
}}
+ version={ENTITY_VERSION_V4}
/>
</GraphContainer>
</Card>
@@ -156,6 +158,7 @@ function DBCall(): JSX.Element {
'database_call_avg_duration',
);
}}
+ version={ENTITY_VERSION_V4}
/>
</GraphContainer>
</Card>
diff --git a/frontend/src/container/MetricsApplication/Tabs/External.tsx b/frontend/src/container/MetricsApplication/Tabs/External.tsx
index 7748f8002a..48e4f24b4c 100644
--- a/frontend/src/container/MetricsApplication/Tabs/External.tsx
+++ b/frontend/src/container/MetricsApplication/Tabs/External.tsx
@@ -1,4 +1,5 @@
import { Col } from 'antd';
+import { ENTITY_VERSION_V4 } from 'constants/app';
import { PANEL_TYPES } from 'constants/queryBuilder';
import Graph from 'container/GridCardLayout/GridCard';
import {
@@ -165,6 +166,7 @@ function External(): JSX.Element {
'external_call_error_percentage',
);
}}
+ version={ENTITY_VERSION_V4}
/>
</GraphContainer>
</Card>
@@ -201,6 +203,7 @@ function External(): JSX.Element {
'external_call_duration',
);
}}
+ version={ENTITY_VERSION_V4}
/>
</GraphContainer>
</Card>
@@ -238,6 +241,7 @@ function External(): JSX.Element {
'external_call_rps_by_address',
)
}
+ version={ENTITY_VERSION_V4}
/>
</GraphContainer>
</Card>
@@ -274,6 +278,7 @@ function External(): JSX.Element {
'external_call_duration_by_address',
);
}}
+ version={ENTITY_VERSION_V4}
/>
</GraphContainer>
</Card>
diff --git a/frontend/src/container/MetricsApplication/Tabs/Overview/ApDex/ApDexMetrics.tsx b/frontend/src/container/MetricsApplication/Tabs/Overview/ApDex/ApDexMetrics.tsx
index e3b03ac577..77eb42d676 100644
--- a/frontend/src/container/MetricsApplication/Tabs/Overview/ApDex/ApDexMetrics.tsx
+++ b/frontend/src/container/MetricsApplication/Tabs/Overview/ApDex/ApDexMetrics.tsx
@@ -5,6 +5,7 @@ import {
apDexToolTipUrl,
apDexToolTipUrlText,
} from 'constants/apDex';
+import { ENTITY_VERSION_V4 } from 'constants/app';
import { PANEL_TYPES } from 'constants/queryBuilder';
import Graph from 'container/GridCardLayout/GridCard';
import DisplayThreshold from 'container/GridCardLayout/WidgetHeader/DisplayThreshold';
@@ -94,6 +95,7 @@ function ApDexMetrics({
onClickHandler={handleGraphClick('ApDex')}
threshold={threshold}
isQueryEnabled={isQueryEnabled}
+ version={ENTITY_VERSION_V4}
/>
);
}
diff --git a/frontend/src/container/MetricsApplication/Tabs/Overview/ApDex/ApDexTraces.tsx b/frontend/src/container/MetricsApplication/Tabs/Overview/ApDex/ApDexTraces.tsx
index 1b2e5ba0cd..294560b752 100644
--- a/frontend/src/container/MetricsApplication/Tabs/Overview/ApDex/ApDexTraces.tsx
+++ b/frontend/src/container/MetricsApplication/Tabs/Overview/ApDex/ApDexTraces.tsx
@@ -1,5 +1,6 @@
// This component is not been used in the application as we support only metrics for ApDex as of now.
// This component is been kept for future reference.
+import { ENTITY_VERSION_V4 } from 'constants/app';
import { PANEL_TYPES } from 'constants/queryBuilder';
import Graph from 'container/GridCardLayout/GridCard';
import { GraphTitle } from 'container/MetricsApplication/constant';
@@ -54,6 +55,7 @@ function ApDexTraces({
onClickHandler={handleGraphClick('ApDex')}
threshold={thresholdValue}
isQueryEnabled={isQueryEnabled}
+ version={ENTITY_VERSION_V4}
/>
);
}
diff --git a/frontend/src/container/MetricsApplication/Tabs/Overview/ServiceOverview.tsx b/frontend/src/container/MetricsApplication/Tabs/Overview/ServiceOverview.tsx
index a6e0e756e1..435d7b26b4 100644
--- a/frontend/src/container/MetricsApplication/Tabs/Overview/ServiceOverview.tsx
+++ b/frontend/src/container/MetricsApplication/Tabs/Overview/ServiceOverview.tsx
@@ -1,3 +1,4 @@
+import { ENTITY_VERSION_V4 } from 'constants/app';
import { FeatureKeys } from 'constants/features';
import { PANEL_TYPES } from 'constants/queryBuilder';
import Graph from 'container/GridCardLayout/GridCard';
@@ -93,6 +94,7 @@ function ServiceOverview({
onClickHandler={handleGraphClick('Service')}
isQueryEnabled={isQueryEnabled}
fillSpans={false}
+ version={ENTITY_VERSION_V4}
/>
</GraphContainer>
</Card>
diff --git a/frontend/src/container/MetricsApplication/Tabs/Overview/TopLevelOperations.tsx b/frontend/src/container/MetricsApplication/Tabs/Overview/TopLevelOperations.tsx
index bf2df1656f..1b0903f4fa 100644
--- a/frontend/src/container/MetricsApplication/Tabs/Overview/TopLevelOperations.tsx
+++ b/frontend/src/container/MetricsApplication/Tabs/Overview/TopLevelOperations.tsx
@@ -1,6 +1,7 @@
import { Typography } from 'antd';
import axios from 'axios';
import { SOMETHING_WENT_WRONG } from 'constants/api';
+import { ENTITY_VERSION_V4 } from 'constants/app';
import Graph from 'container/GridCardLayout/GridCard';
import { Card, GraphContainer } from 'container/MetricsApplication/styles';
import { OnClickPluginOpts } from 'lib/uPlotLib/plugins/onClickPlugin';
@@ -33,6 +34,7 @@ function TopLevelOperation({
onClickHandler={handleGraphClick(opName)}
onDragSelect={onDragSelect}
isQueryEnabled={!topLevelOperationsIsLoading}
+ version={ENTITY_VERSION_V4}
/>
</GraphContainer>
)}
diff --git a/frontend/src/container/MetricsApplication/Tabs/Overview/TopOperationMetrics.tsx b/frontend/src/container/MetricsApplication/Tabs/Overview/TopOperationMetrics.tsx
index d4116c559b..090d10e808 100644
--- a/frontend/src/container/MetricsApplication/Tabs/Overview/TopOperationMetrics.tsx
+++ b/frontend/src/container/MetricsApplication/Tabs/Overview/TopOperationMetrics.tsx
@@ -1,4 +1,4 @@
-import { DEFAULT_ENTITY_VERSION } from 'constants/app';
+import { ENTITY_VERSION_V4 } from 'constants/app';
import { PANEL_TYPES } from 'constants/queryBuilder';
import { topOperationMetricsDownloadOptions } from 'container/MetricsApplication/constant';
import { getWidgetQueryBuilder } from 'container/MetricsApplication/MetricsApplication.factory';
@@ -68,7 +68,7 @@ function TopOperationMetrics(): JSX.Element {
globalSelectedInterval,
variables: {},
},
- DEFAULT_ENTITY_VERSION,
+ ENTITY_VERSION_V4,
{
queryKey: [
`GetMetricsQueryRange-${keyOperationWidget?.timePreferance}-${globalSelectedInterval}-${keyOperationWidget?.id}`,
diff --git a/frontend/src/container/MetricsApplication/Tabs/types.ts b/frontend/src/container/MetricsApplication/Tabs/types.ts
index f30bf1b14e..9b45bd5492 100644
--- a/frontend/src/container/MetricsApplication/Tabs/types.ts
+++ b/frontend/src/container/MetricsApplication/Tabs/types.ts
@@ -39,7 +39,8 @@ export interface BuilderQuerieswithFormulaProps {
expressions: string[];
legendFormulas: string[];
additionalItems: TagFilterItem[][];
- aggregateOperators: MetricAggregateOperator[];
+ timeAggregateOperators: MetricAggregateOperator[];
+ spaceAggregateOperators: MetricAggregateOperator[];
dataSource: DataSource;
}
diff --git a/frontend/src/container/QueryBuilder/components/Query/Query.tsx b/frontend/src/container/QueryBuilder/components/Query/Query.tsx
index 636c771185..335b998334 100644
--- a/frontend/src/container/QueryBuilder/components/Query/Query.tsx
+++ b/frontend/src/container/QueryBuilder/components/Query/Query.tsx
@@ -2,6 +2,7 @@
import './Query.styles.scss';
import { Col, Input, Row } from 'antd';
+import { ENTITY_VERSION_V4 } from 'constants/app';
// ** Constants
import { ATTRIBUTE_TYPES, PANEL_TYPES } from 'constants/queryBuilder';
import ROUTES from 'constants/routes';
@@ -316,13 +317,15 @@ export const Query = memo(function Query({
const disableOperatorSelector =
!query?.aggregateAttribute.key || query?.aggregateAttribute.key === '';
- const isVersionV4 = version && version === 'v4';
+ const isVersionV4 = version && version === ENTITY_VERSION_V4;
return (
<Row gutter={[0, 12]}>
<QBEntityOptions
isMetricsDataSource={isMetricsDataSource}
- showFunctions={(version && version === 'v4') || showFunctions || false}
+ showFunctions={
+ (version && version === ENTITY_VERSION_V4) || showFunctions || false
+ }
isCollapsed={isCollapse}
entityType="query"
entityData={query}
@@ -375,7 +378,7 @@ export const Query = memo(function Query({
</Col>
{version &&
- version === 'v4' &&
+ version === ENTITY_VERSION_V4 &&
operators &&
Array.isArray(operators) &&
operators.length > 0 && (
diff --git a/frontend/src/container/QueryBuilder/filters/HavingFilter/HavingFilter.tsx b/frontend/src/container/QueryBuilder/filters/HavingFilter/HavingFilter.tsx
index d1a5df79ed..7d11d018cc 100644
--- a/frontend/src/container/QueryBuilder/filters/HavingFilter/HavingFilter.tsx
+++ b/frontend/src/container/QueryBuilder/filters/HavingFilter/HavingFilter.tsx
@@ -1,4 +1,5 @@
import { Select } from 'antd';
+import { ENTITY_VERSION_V4 } from 'constants/app';
// ** Constants
import { HAVING_OPERATORS, initialHavingValues } from 'constants/queryBuilder';
import { HavingFilterTag } from 'container/QueryBuilder/components';
@@ -54,7 +55,7 @@ export function HavingFilter({
query &&
query.dataSource === DataSource.METRICS &&
query.spaceAggregation &&
- entityVersion === 'v4'
+ entityVersion === ENTITY_VERSION_V4
) {
return `${query.spaceAggregation.toUpperCase()}(${aggregatorAttribute})`;
}
diff --git a/frontend/src/container/ServiceApplication/ServiceMetrics/ServiceMetricTable.tsx b/frontend/src/container/ServiceApplication/ServiceMetrics/ServiceMetricTable.tsx
index 39b208a266..f592f6a540 100644
--- a/frontend/src/container/ServiceApplication/ServiceMetrics/ServiceMetricTable.tsx
+++ b/frontend/src/container/ServiceApplication/ServiceMetrics/ServiceMetricTable.tsx
@@ -1,7 +1,7 @@
import { WarningFilled } from '@ant-design/icons';
import { Flex, Typography } from 'antd';
import { ResizeTable } from 'components/ResizeTable';
-import { DEFAULT_ENTITY_VERSION } from 'constants/app';
+import { ENTITY_VERSION_V4 } from 'constants/app';
import { MAX_RPS_LIMIT } from 'constants/global';
import ResourceAttributesFilter from 'container/ResourceAttributesFilter';
import { useGetQueriesRange } from 'hooks/queryBuilder/useGetQueriesRange';
@@ -36,26 +36,22 @@ function ServiceMetricTable({
const { data: licenseData, isFetching } = useLicense();
const isCloudUserVal = isCloudUser();
- const queries = useGetQueriesRange(
- queryRangeRequestData,
- DEFAULT_ENTITY_VERSION,
- {
- queryKey: [
- `GetMetricsQueryRange-${queryRangeRequestData[0].selectedTime}-${globalSelectedInterval}`,
- maxTime,
- minTime,
- globalSelectedInterval,
- ],
- keepPreviousData: true,
- enabled: true,
- refetchOnMount: false,
- onError: (error) => {
- notifications.error({
- message: error.message,
- });
- },
+ const queries = useGetQueriesRange(queryRangeRequestData, ENTITY_VERSION_V4, {
+ queryKey: [
+ `GetMetricsQueryRange-${queryRangeRequestData[0].selectedTime}-${globalSelectedInterval}`,
+ maxTime,
+ minTime,
+ globalSelectedInterval,
+ ],
+ keepPreviousData: true,
+ enabled: true,
+ refetchOnMount: false,
+ onError: (error) => {
+ notifications.error({
+ message: error.message,
+ });
},
- );
+ });
const isLoading = queries.some((query) => query.isLoading);
const services: ServicesList[] = useMemo(
diff --git a/frontend/src/container/ServiceApplication/ServiceMetrics/ServiceMetricsQuery.ts b/frontend/src/container/ServiceApplication/ServiceMetrics/ServiceMetricsQuery.ts
index 46f94acd87..352e144ade 100644
--- a/frontend/src/container/ServiceApplication/ServiceMetrics/ServiceMetricsQuery.ts
+++ b/frontend/src/container/ServiceApplication/ServiceMetrics/ServiceMetricsQuery.ts
@@ -166,11 +166,17 @@ export const serviceMetricsQuery = (
operationPrSecondAdditionalItems,
];
- const aggregateOperators = [
- MetricAggregateOperator.HIST_QUANTILE_99,
- MetricAggregateOperator.SUM_RATE,
- MetricAggregateOperator.SUM_RATE,
- MetricAggregateOperator.SUM_RATE,
+ const timeAggregateOperators = [
+ MetricAggregateOperator.EMPTY,
+ MetricAggregateOperator.RATE,
+ MetricAggregateOperator.RATE,
+ MetricAggregateOperator.RATE,
+ ];
+ const spaceAggregateOperators = [
+ MetricAggregateOperator.P99,
+ MetricAggregateOperator.SUM,
+ MetricAggregateOperator.SUM,
+ MetricAggregateOperator.SUM,
];
const disabled = [false, true, true, false];
@@ -201,7 +207,8 @@ export const serviceMetricsQuery = (
additionalItems,
disabled,
legends,
- aggregateOperators,
+ timeAggregateOperators,
+ spaceAggregateOperators,
expressions,
legendFormulas,
groupBy,
diff --git a/frontend/src/hooks/queryBuilder/useQueryBuilderOperations.ts b/frontend/src/hooks/queryBuilder/useQueryBuilderOperations.ts
index 2de0a661b5..7766122a45 100644
--- a/frontend/src/hooks/queryBuilder/useQueryBuilderOperations.ts
+++ b/frontend/src/hooks/queryBuilder/useQueryBuilderOperations.ts
@@ -1,3 +1,4 @@
+import { ENTITY_VERSION_V4 } from 'constants/app';
import { LEGEND } from 'constants/global';
import {
ATTRIBUTE_TYPES,
@@ -183,7 +184,10 @@ export const useQueryOperations: UseQueryOperations = ({
having: [],
};
- if (newQuery.dataSource === DataSource.METRICS && entityVersion === 'v4') {
+ if (
+ newQuery.dataSource === DataSource.METRICS &&
+ entityVersion === ENTITY_VERSION_V4
+ ) {
handleMetricAggregateAtributeTypes(newQuery.aggregateAttribute);
if (newQuery.aggregateAttribute.type === ATTRIBUTE_TYPES.SUM) {
@@ -310,7 +314,7 @@ export const useQueryOperations: UseQueryOperations = ({
dataSource === DataSource.METRICS &&
query &&
query.aggregateAttribute &&
- entityVersion === 'v4'
+ entityVersion === ENTITY_VERSION_V4
) {
handleMetricAggregateAtributeTypes(query.aggregateAttribute);
} else {
diff --git a/frontend/src/mocks-server/handlers.ts b/frontend/src/mocks-server/handlers.ts
index 25564363e4..af25738aa7 100644
--- a/frontend/src/mocks-server/handlers.ts
+++ b/frontend/src/mocks-server/handlers.ts
@@ -11,6 +11,10 @@ export const handlers = [
res(ctx.status(200), ctx.json(queryRangeSuccessResponse)),
),
+ rest.post('http://localhost/api/v4/query_range', (req, res, ctx) =>
+ res(ctx.status(200), ctx.json(queryRangeSuccessResponse)),
+ ),
+
rest.post('http://localhost/api/v1/services', (req, res, ctx) =>
res(ctx.status(200), ctx.json(serviceSuccessResponse)),
),
diff --git a/frontend/src/types/api/queryBuilder/queryBuilderData.ts b/frontend/src/types/api/queryBuilder/queryBuilderData.ts
index 7c4c9f27a3..6a54254617 100644
--- a/frontend/src/types/api/queryBuilder/queryBuilderData.ts
+++ b/frontend/src/types/api/queryBuilder/queryBuilderData.ts
@@ -60,6 +60,7 @@ export type IBuilderQuery = {
aggregateAttribute: BaseAutocompleteData;
timeAggregation: string;
spaceAggregation?: string;
+ temporality?: string;
functions: QueryFunctionProps[];
filters: TagFilter;
groupBy: BaseAutocompleteData[];
diff --git a/frontend/src/types/common/queryBuilder.ts b/frontend/src/types/common/queryBuilder.ts
index f8befa344b..731de0650d 100644
--- a/frontend/src/types/common/queryBuilder.ts
+++ b/frontend/src/types/common/queryBuilder.ts
@@ -61,7 +61,14 @@ export enum BoolOperators {
COUNT_DISTINCT = 'count_distinct',
}
+export enum Temporality {
+ Unspecified = 'Unspecified',
+ Delta = 'Delta',
+ Cumulative = 'Cumulative',
+}
+
export enum MetricAggregateOperator {
+ EMPTY = '', // used as time aggregator for histograms
NOOP = 'noop',
COUNT = 'count',
COUNT_DISTINCT = 'count_distinct',
diff --git a/pkg/query-service/app/formula.go b/pkg/query-service/app/formula.go
index 657a7bcad9..72db8ab39d 100644
--- a/pkg/query-service/app/formula.go
+++ b/pkg/query-service/app/formula.go
@@ -120,6 +120,13 @@ func joinAndCalculate(results []*v3.Result, uniqueLabelSet map[string]string, ex
for queryName, series := range seriesMap {
values[queryName] = series[timestamp]
}
+
+ // If the value is not present in the values map, set it to 0
+ for _, v := range expression.Vars() {
+ if _, ok := values[v]; !ok {
+ values[v] = 0
+ }
+ }
newValue, err := expression.Evaluate(values)
if err != nil {
return nil, err
diff --git a/pkg/query-service/app/parser_test.go b/pkg/query-service/app/parser_test.go
index 8b172027a4..5b9e776486 100644
--- a/pkg/query-service/app/parser_test.go
+++ b/pkg/query-service/app/parser_test.go
@@ -492,23 +492,23 @@ func TestParseQueryRangeParamsCompositeQuery(t *testing.T) {
expectErr: true,
errMsg: "data source is invalid",
},
- {
- desc: "invalid aggregate operator for builder query",
- compositeQuery: v3.CompositeQuery{
- PanelType: v3.PanelTypeGraph,
- QueryType: v3.QueryTypeBuilder,
- BuilderQueries: map[string]*v3.BuilderQuery{
- "A": {
- QueryName: "A",
- DataSource: "metrics",
- AggregateOperator: "invalid",
- Expression: "A",
- },
- },
- },
- expectErr: true,
- errMsg: "aggregate operator is invalid",
- },
+ // {
+ // desc: "invalid aggregate operator for builder query",
+ // compositeQuery: v3.CompositeQuery{
+ // PanelType: v3.PanelTypeGraph,
+ // QueryType: v3.QueryTypeBuilder,
+ // BuilderQueries: map[string]*v3.BuilderQuery{
+ // "A": {
+ // QueryName: "A",
+ // DataSource: "metrics",
+ // AggregateOperator: "invalid",
+ // Expression: "A",
+ // },
+ // },
+ // },
+ // expectErr: true,
+ // errMsg: "aggregate operator is invalid",
+ // },
{
desc: "invalid aggregate attribute for builder query",
compositeQuery: v3.CompositeQuery{
diff --git a/pkg/query-service/model/v3/v3.go b/pkg/query-service/model/v3/v3.go
index 7b4a74f594..43e7a940ab 100644
--- a/pkg/query-service/model/v3/v3.go
+++ b/pkg/query-service/model/v3/v3.go
@@ -654,22 +654,22 @@ func (b *BuilderQuery) Validate() error {
}
if b.DataSource == DataSourceMetrics {
// if AggregateOperator is specified, then the request is using v3 payload
- if b.AggregateOperator != "" && b.SpaceAggregation == SpaceAggregationUnspecified {
- if err := b.AggregateOperator.Validate(); err != nil {
- return fmt.Errorf("aggregate operator is invalid: %w", err)
- }
- } else {
- // the time aggregation is not needed for percentile operators
- if !IsPercentileOperator(b.SpaceAggregation) {
- if err := b.TimeAggregation.Validate(); err != nil {
- return fmt.Errorf("time aggregation is invalid: %w", err)
- }
- }
-
- if err := b.SpaceAggregation.Validate(); err != nil {
- return fmt.Errorf("space aggregation is invalid: %w", err)
- }
- }
+ // if b.AggregateOperator != "" && b.SpaceAggregation == SpaceAggregationUnspecified {
+ // if err := b.AggregateOperator.Validate(); err != nil {
+ // return fmt.Errorf("aggregate operator is invalid: %w", err)
+ // }
+ // } else {
+ // // the time aggregation is not needed for percentile operators
+ // if !IsPercentileOperator(b.SpaceAggregation) {
+ // if err := b.TimeAggregation.Validate(); err != nil {
+ // return fmt.Errorf("time aggregation is invalid: %w", err)
+ // }
+ // }
+
+ // if err := b.SpaceAggregation.Validate(); err != nil {
+ // return fmt.Errorf("space aggregation is invalid: %w", err)
+ // }
+ // }
} else {
if err := b.AggregateOperator.Validate(); err != nil {
return fmt.Errorf("aggregate operator is invalid: %w", err)