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.

feat(ingestion): make set alert on ingestion limit prominent and added default alert name (#11215)

SagarRajput-7757c4a84c06c
diff --git a/frontend/src/constants/query.ts b/frontend/src/constants/query.ts
index 3b4c037ba9..7065966099 100644
--- a/frontend/src/constants/query.ts
+++ b/frontend/src/constants/query.ts
@@ -56,4 +56,5 @@ export enum QueryParams {
showClassicCreateAlertsPage = 'showClassicCreateAlertsPage',
isTestAlert = 'isTestAlert',
yAxisUnit = 'yAxisUnit',
+ ruleName = 'ruleName',
}
diff --git a/frontend/src/container/CreateAlertV2/AlertCondition/utils.tsx b/frontend/src/container/CreateAlertV2/AlertCondition/utils.tsx
index 11e02f1367..b0cc25c80a 100644
--- a/frontend/src/container/CreateAlertV2/AlertCondition/utils.tsx
+++ b/frontend/src/container/CreateAlertV2/AlertCondition/utils.tsx
@@ -10,6 +10,7 @@ import {
AlertThresholdOperator,
} from 'container/CreateAlertV2/context/types';
import { getSelectedQueryOptions } from 'container/FormAlertRules/utils';
+import { useSafeNavigate } from 'hooks/useSafeNavigate';
import { ArrowRight } from 'lucide-react';
import { IUser } from 'providers/App/types';
import { Query } from 'types/api/queryBuilder/queryBuilderData';
@@ -410,6 +411,7 @@ export function RoutingPolicyBanner({
notificationSettings,
setNotificationSettings,
}: RoutingPolicyBannerProps): JSX.Element {
+ const { safeNavigate } = useSafeNavigate();
return (
<div className="routing-policies-info-banner">
<Typography.Text>
@@ -427,10 +429,10 @@ export function RoutingPolicyBanner({
}}
/>
<Button
- href={ROUTING_POLICIES_ROUTE}
type="link"
className="view-routing-policies-button"
data-testid="view-routing-policies-button"
+ onClick={(): void => safeNavigate(ROUTING_POLICIES_ROUTE)}
>
View Routing Policies
<ArrowRight size={14} />
diff --git a/frontend/src/container/CreateAlertV2/QuerySection/ChartPreview/ChartPreview.tsx b/frontend/src/container/CreateAlertV2/QuerySection/ChartPreview/ChartPreview.tsx
index 7b77cb09fa..79dde33370 100644
--- a/frontend/src/container/CreateAlertV2/QuerySection/ChartPreview/ChartPreview.tsx
+++ b/frontend/src/container/CreateAlertV2/QuerySection/ChartPreview/ChartPreview.tsx
@@ -1,9 +1,11 @@
import { useEffect, useMemo, useState } from 'react';
// eslint-disable-next-line no-restricted-imports
import { useSelector } from 'react-redux';
+import { useLocation } from 'react-router-dom';
import YAxisUnitSelector from 'components/YAxisUnitSelector';
import { YAxisSource } from 'components/YAxisUnitSelector/types';
import { PANEL_TYPES } from 'constants/queryBuilder';
+import { QueryParams } from 'constants/query';
import { useCreateAlertState } from 'container/CreateAlertV2/context';
import ChartPreviewComponent from 'container/FormAlertRules/ChartPreview';
import PlotTag from 'container/NewWidget/LeftContainer/WidgetGraph/PlotTag';
@@ -39,14 +41,22 @@ function ChartPreview({
const yAxisUnit = alertState.yAxisUnit || '';
- // Only update automatically when creating a new metrics-based alert rule
+ const location = useLocation();
+ const yAxisUnitFromURL = new URLSearchParams(location.search).get(
+ QueryParams.yAxisUnit,
+ );
+
+ // Only update automatically when creating a new metrics-based alert rule.
+ // Skip when yAxisUnit was explicitly provided via URL (e.g. from ingestion settings).
const shouldUpdateYAxisUnit = useMemo(() => {
- // Do not update if we are coming to the page from dashboards (we still show warning)
if (source === YAxisSource.DASHBOARDS) {
return false;
}
+ if (yAxisUnitFromURL) {
+ return false;
+ }
return !isEditMode && alertType === AlertTypes.METRICS_BASED_ALERT;
- }, [isEditMode, alertType, source]);
+ }, [isEditMode, alertType, source, yAxisUnitFromURL]);
const selectedQueryName = thresholdState.selectedQuery;
const { yAxisUnit: initialYAxisUnit, isLoading } =
diff --git a/frontend/src/container/CreateAlertV2/context/index.tsx b/frontend/src/container/CreateAlertV2/context/index.tsx
index daa763d03c..7858073dd6 100644
--- a/frontend/src/container/CreateAlertV2/context/index.tsx
+++ b/frontend/src/container/CreateAlertV2/context/index.tsx
@@ -7,6 +7,7 @@ import {
useEffect,
useMemo,
useReducer,
+ useRef,
useState,
} from 'react';
import { useLocation } from 'react-router-dom';
@@ -123,6 +124,8 @@ export function CreateAlertProvider(
const location = useLocation();
const queryParams = new URLSearchParams(location.search);
const thresholdsFromURL = queryParams.get(QueryParams.thresholds);
+ const ruleNameFromURL = queryParams.get(QueryParams.ruleName);
+ const yAxisUnitFromURL = queryParams.get(QueryParams.yAxisUnit);
const [alertType, setAlertType] = useState<AlertTypes>(() => {
if (isEditMode) {
@@ -154,6 +157,9 @@ export function CreateAlertProvider(
[redirectWithQueryBuilderData],
);
+ const ruleNameAppliedRef = useRef(false);
+ const yAxisUnitAppliedRef = useRef(false);
+
useEffect(() => {
setCreateAlertState({
slice: CreateAlertSlice.THRESHOLD,
@@ -191,7 +197,29 @@ export function CreateAlertProvider(
},
});
}
- }, [alertType, thresholdsFromURL]);
+
+ if (ruleNameFromURL && !ruleNameAppliedRef.current) {
+ ruleNameAppliedRef.current = true;
+ setCreateAlertState({
+ slice: CreateAlertSlice.BASIC,
+ action: {
+ type: 'SET_ALERT_NAME',
+ payload: ruleNameFromURL,
+ },
+ });
+ }
+
+ if (yAxisUnitFromURL && !yAxisUnitAppliedRef.current) {
+ yAxisUnitAppliedRef.current = true;
+ setCreateAlertState({
+ slice: CreateAlertSlice.BASIC,
+ action: {
+ type: 'SET_Y_AXIS_UNIT',
+ payload: yAxisUnitFromURL,
+ },
+ });
+ }
+ }, [alertType, thresholdsFromURL, ruleNameFromURL, yAxisUnitFromURL]);
useEffect(() => {
if (isEditMode && initialAlertState) {
diff --git a/frontend/src/container/IngestionSettings/IngestionSettings.styles.scss b/frontend/src/container/IngestionSettings/IngestionSettings.styles.scss
index 391131c991..5a34306571 100644
--- a/frontend/src/container/IngestionSettings/IngestionSettings.styles.scss
+++ b/frontend/src/container/IngestionSettings/IngestionSettings.styles.scss
@@ -443,7 +443,25 @@
.signal-limit-save-discard {
display: flex;
- gap: 8px;
+ gap: var(--spacing-4);
+
+ .signal-limit-save-discard-actions {
+ display: flex;
+ align-items: center;
+ gap: var(--spacing-4);
+ }
+
+ .signal-limit-alert-helper {
+ display: flex;
+ align-items: center;
+ gap: var(--spacing-2);
+ font-size: var(--paragraph-small-400-font-size);
+ color: var(--l2-foreground);
+ border-bottom: 1px dashed var(--l2-foreground);
+ padding-bottom: 1px;
+ font-style: italic;
+ margin-left: var(--spacing-6);
+ }
}
}
}
@@ -475,6 +493,7 @@
.ant-modal-footer {
padding: 16px;
margin-top: 0;
+ gap: 8px;
display: flex;
justify-content: flex-end;
diff --git a/frontend/src/container/IngestionSettings/MultiIngestionSettings.tsx b/frontend/src/container/IngestionSettings/MultiIngestionSettings.tsx
index 0400b1a444..31ecf1c9cf 100644
--- a/frontend/src/container/IngestionSettings/MultiIngestionSettings.tsx
+++ b/frontend/src/container/IngestionSettings/MultiIngestionSettings.tsx
@@ -3,8 +3,8 @@ import { useTranslation } from 'react-i18next';
import { useHistory } from 'react-router-dom';
import { useCopyToClipboard } from 'react-use';
import { Color } from '@signozhq/design-tokens';
+import { Badge, Button } from '@signozhq/ui';
import {
- Button,
Col,
Collapse,
DatePicker,
@@ -41,6 +41,7 @@ import {
import { AxiosError } from 'axios';
import { getYAxisFormattedValue } from 'components/Graph/yAxisConfig';
import Tags from 'components/Tags/Tags';
+import { UniversalYAxisUnit } from 'components/YAxisUnitSelector/types';
import { SOMETHING_WENT_WRONG } from 'constants/api';
import { DATE_TIME_FORMATS } from 'constants/dateTimeFormats';
import { QueryParams } from 'constants/query';
@@ -98,9 +99,30 @@ const COUNT_MULTIPLIER = {
};
const SIGNALS_CONFIG = [
- { name: 'logs', usesSize: true, usesCount: false },
- { name: 'traces', usesSize: true, usesCount: false },
- { name: 'metrics', usesSize: false, usesCount: true },
+ {
+ name: 'logs',
+ usesSize: true,
+ usesCount: false,
+ metricName: 'signoz.meter.log.size',
+ yAxisUnit: UniversalYAxisUnit.BYTES_IEC,
+ thresholdUnit: UniversalYAxisUnit.GIBIBYTES,
+ },
+ {
+ name: 'traces',
+ usesSize: true,
+ usesCount: false,
+ metricName: 'signoz.meter.span.size',
+ yAxisUnit: UniversalYAxisUnit.BYTES_IEC,
+ thresholdUnit: UniversalYAxisUnit.GIBIBYTES,
+ },
+ {
+ name: 'metrics',
+ usesSize: false,
+ usesCount: true,
+ metricName: 'signoz.meter.metric.datapoint.count',
+ yAxisUnit: UniversalYAxisUnit.COUNT,
+ thresholdUnit: UniversalYAxisUnit.COUNT,
+ },
];
// Using any type here because antd's DatePicker expects its own internal Dayjs type
@@ -394,7 +416,7 @@ function MultiIngestionSettings(): JSX.Element {
notifications.success({
message: 'Ingestion key deleted successfully',
});
- refetchAPIKeys();
+ void refetchAPIKeys();
setIsDeleteModalOpen(false);
},
onError: (error) => {
@@ -426,7 +448,7 @@ function MultiIngestionSettings(): JSX.Element {
notifications.success({
message: 'Ingestion key updated successfully',
});
- refetchAPIKeys();
+ void refetchAPIKeys();
setIsEditModalOpen(false);
},
onError: (error) => {
@@ -466,7 +488,7 @@ function MultiIngestionSettings(): JSX.Element {
setActiveAPIKey(null);
setUpdatedTags([]);
hideAddViewModal();
- refetchAPIKeys();
+ void refetchAPIKeys();
},
onError: (error) => {
showErrorNotification(notifications, error as AxiosError);
@@ -630,13 +652,14 @@ function MultiIngestionSettings(): JSX.Element {
onSuccess: () => {
notifications.success({
message: 'Limit created successfully',
+ description: "Set up an alert to know when you're close to hitting it.",
});
setActiveSignal(null);
setActiveAPIKey(null);
setIsEditAddLimitOpen(false);
setUpdatedTags([]);
hideAddViewModal();
- refetchAPIKeys();
+ void refetchAPIKeys();
setHasCreateLimitForIngestionKeyError(false);
},
onError: (error: AxiosError<RenderErrorResponseDTO>) => {
@@ -733,13 +756,14 @@ function MultiIngestionSettings(): JSX.Element {
onSuccess: () => {
notifications.success({
message: 'Limit updated successfully',
+ description: "Set up an alert to know when you're close to hitting it.",
});
setActiveSignal(null);
setActiveAPIKey(null);
setIsEditAddLimitOpen(false);
setUpdatedTags([]);
hideAddViewModal();
- refetchAPIKeys();
+ void refetchAPIKeys();
setHasUpdateLimitForIngestionKeyError(false);
},
onError: (error: AxiosError<RenderErrorResponseDTO>) => {
@@ -824,7 +848,7 @@ function MultiIngestionSettings(): JSX.Element {
});
setIsDeleteModalOpen(false);
setIsDeleteLimitModalOpen(false);
- refetchAPIKeys();
+ void refetchAPIKeys();
},
onError: (error) => {
showErrorNotification(notifications, error as AxiosError);
@@ -840,29 +864,22 @@ function MultiIngestionSettings(): JSX.Element {
APIKey: GatewaytypesIngestionKeyDTO,
signal: LimitProps,
): void => {
- let metricName = '';
-
- switch (signal.signal) {
- case 'metrics':
- metricName = 'signoz.meter.metric.datapoint.count';
- break;
- case 'traces':
- metricName = 'signoz.meter.span.size';
- break;
- case 'logs':
- metricName = 'signoz.meter.log.size';
- break;
- default:
- return;
+ const signalCfg = SIGNALS_CONFIG.find((cfg) => cfg.name === signal.signal);
+ if (!signalCfg) {
+ return;
}
- const threshold =
- signal.signal === 'metrics'
- ? signal.config?.day?.count || 0
- : signal.config?.day?.size || 0;
+ const { metricName, yAxisUnit, thresholdUnit } = signalCfg;
+
+ // Size signals store the limit in bytes but the user entered GiB; pass the GiB
+ // value so the threshold reads "400 GiB" while the chart Y-axis stays in bytes.
+ const thresholdValue = signalCfg.usesCount
+ ? signal.config?.day?.count || 0
+ : bytesToGb(signal.config?.day?.size);
const query = {
...initialQueryMeterWithType,
+ unit: yAxisUnit,
builder: {
...initialQueryMeterWithType.builder,
queryData: [
@@ -887,13 +904,23 @@ function MultiIngestionSettings(): JSX.Element {
const stringifiedQuery = JSON.stringify(query);
const thresholds = cloneDeep(INITIAL_ALERT_THRESHOLD_STATE.thresholds);
- thresholds[0].thresholdValue = threshold;
+ thresholds[0].thresholdValue = thresholdValue;
+ thresholds[0].unit = thresholdUnit;
+
+ const keyName = APIKey.name?.trim();
+ const ruleName = keyName
+ ? `[ingestion][${signal.signal}] ${keyName} has exceeded daily ingestion limit`
+ : `[ingestion][${signal.signal}] ${signal.signal} has exceeded daily ingestion limit`;
const URL = `${ROUTES.ALERTS_NEW}?${
QueryParams.compositeQuery
}=${encodeURIComponent(stringifiedQuery)}&${
QueryParams.thresholds
- }=${encodeURIComponent(JSON.stringify(thresholds))}`;
+ }=${encodeURIComponent(JSON.stringify(thresholds))}&${
+ QueryParams.ruleName
+ }=${encodeURIComponent(ruleName)}&${
+ QueryParams.yAxisUnit
+ }=${encodeURIComponent(yAxisUnit)}`;
history.push(URL);
};
@@ -980,13 +1007,18 @@ function MultiIngestionSettings(): JSX.Element {
</div>
<div className="action-btn">
<Button
- className="periscope-btn ghost"
- icon={<PenLine size={14} />}
+ variant="link"
+ size="icon"
+ color="secondary"
+ suffix={<PenLine size={14} />}
+ aria-label="Edit ingestion key"
onClick={onEditKey}
/>
<Button
- className="periscope-btn ghost"
- icon={<Trash2 color={Color.BG_CHERRY_500} size={14} />}
+ variant="link"
+ size="icon"
+ color="destructive"
+ suffix={<Trash2 color={Color.BG_CHERRY_500} size={14} />}
onClick={onDeleteKey}
/>
</div>
@@ -1092,16 +1124,22 @@ function MultiIngestionSettings(): JSX.Element {
{hasLimits(signalName) ? (
<>
<Button
- className="periscope-btn ghost"
- icon={<PenLine size={14} />}
+ variant="link"
+ size="icon"
+ color="secondary"
+ prefix={<PenLine size={14} />}
+ aria-label={`Edit ${signalName} limit`}
disabled={
!!(activeAPIKey?.id === APIKey?.id && activeSignal)
}
onClick={onEditSignalLimit}
/>
<Button
- className="periscope-btn ghost"
- icon={<Trash2 color={Color.BG_CHERRY_500} size={14} />}
+ variant="link"
+ size="icon"
+ color="destructive"
+ prefix={<Trash2 color={Color.BG_CHERRY_500} size={14} />}
+ aria-label={`Delete ${signalName} limit`}
disabled={
!!(activeAPIKey?.id === APIKey?.id && activeSignal)
}
@@ -1110,10 +1148,10 @@ function MultiIngestionSettings(): JSX.Element {
</>
) : (
<Button
- className="periscope-btn"
- size="small"
- shape="round"
- icon={<PlusIcon size={14} />}
+ variant="outlined"
+ size="sm"
+ color="secondary"
+ prefix={<PlusIcon size={12} />}
disabled={!!(activeAPIKey?.id === APIKey?.id && activeSignal)}
onClick={onAddSignalLimit}
>
@@ -1344,31 +1382,35 @@ function MultiIngestionSettings(): JSX.Element {
activeSignal.signal === signalName &&
isEditAddLimitOpen && (
<div className="signal-limit-save-discard">
- <Button
- type="primary"
- className="periscope-btn primary"
- size="small"
- disabled={
- isLoadingLimitForKey || isLoadingUpdatedLimitForKey
- }
- loading={
- isLoadingLimitForKey || isLoadingUpdatedLimitForKey
- }
- onClick={onSaveSignalLimit}
- >
- Save
- </Button>
- <Button
- type="default"
- className="periscope-btn"
- size="small"
- disabled={
- isLoadingLimitForKey || isLoadingUpdatedLimitForKey
- }
- onClick={handleDiscardSaveLimit}
- >
- Discard
- </Button>
+ <div className="signal-limit-save-discard-actions">
+ <Button
+ variant="solid"
+ size="sm"
+ disabled={
+ isLoadingLimitForKey || isLoadingUpdatedLimitForKey
+ }
+ loading={
+ isLoadingLimitForKey || isLoadingUpdatedLimitForKey
+ }
+ onClick={onSaveSignalLimit}
+ >
+ Save
+ </Button>
+ <Button
+ variant="outlined"
+ color="secondary"
+ size="sm"
+ disabled={
+ isLoadingLimitForKey || isLoadingUpdatedLimitForKey
+ }
+ onClick={handleDiscardSaveLimit}
+ >
+ Discard
+ </Button>
+ <span className="signal-limit-alert-helper">
+ You can set up an alert after saving
+ </span>
+ </div>
</div>
)}
</Form>
@@ -1425,19 +1467,18 @@ function MultiIngestionSettings(): JSX.Element {
limit?.config?.day?.size !== undefined) ||
(signalCfg.usesCount &&
limit?.config?.day?.count !== undefined)) && (
- <Tooltip
- title="Set alert on this limit"
- placement="top"
- arrow={false}
+ <Badge
+ asChild
+ color="cherry"
+ variant="outline"
+ testId={`set-alert-btn-${signalName}`}
+ className="set-alert-btn"
>
- <Button
- icon={<BellPlus size={14} color={Color.BG_CHERRY_400} />}
- className="set-alert-btn periscope-btn ghost"
- type="text"
- data-testid={`set-alert-btn-${signalName}`}
- onClick={onCreateSignalAlert}
- />
- </Tooltip>
+ <Button onClick={onCreateSignalAlert} size="sm">
+ <BellPlus size={12} />
+ Set alert
+ </Button>
+ </Badge>
)}
</div>
@@ -1617,7 +1658,13 @@ function MultiIngestionSettings(): JSX.Element {
}
placement="topLeft"
>
- <Button type="text" icon={<TriangleAlert size={14} />} />
+ <Button
+ variant="ghost"
+ size="icon"
+ color="secondary"
+ prefix={<TriangleAlert size={14} />}
+ aria-label="Ingestion URL error details"
+ />
</Tooltip>
)}
</div>
@@ -1633,11 +1680,12 @@ function MultiIngestionSettings(): JSX.Element {
/>
<Button
+ variant="solid"
className="add-new-ingestion-key-btn"
- type="primary"
+ prefix={<Plus size={14} />}
onClick={showAddModal}
>
- <Plus size={14} /> New Ingestion key
+ New Ingestion key
</Button>
</div>
@@ -1670,15 +1718,19 @@ function MultiIngestionSettings(): JSX.Element {
footer={[
<Button
key="cancel"
+ variant="ghost"
+ color="secondary"
+ prefix={<X size={16} />}
onClick={hideDeleteViewModal}
className="cancel-btn"
- icon={<X size={16} />}
>
Cancel
</Button>,
<Button
key="submit"
- icon={<Trash2 size={16} />}
+ variant="solid"
+ color="destructive"
+ prefix={<Trash2 size={16} />}
loading={isDeleteingAPIKey}
onClick={onDeleteHandler}
className="delete-btn"
@@ -1706,15 +1758,19 @@ function MultiIngestionSettings(): JSX.Element {
footer={[
<Button
key="cancel"
+ variant="ghost"
+ color="secondary"
+ prefix={<X size={16} />}
onClick={hideDeleteLimitModal}
className="cancel-btn"
- icon={<X size={16} />}
>
Cancel
</Button>,
<Button
key="submit"
- icon={<Trash2 size={16} />}
+ variant="solid"
+ color="destructive"
+ prefix={<Trash2 size={16} />}
loading={isDeletingLimit}
onClick={onDeleteLimitHandler}
className="delete-btn"
@@ -1745,18 +1801,18 @@ function MultiIngestionSettings(): JSX.Element {
footer={[
<Button
key="cancel"
+ variant="ghost"
+ color="secondary"
+ prefix={<X size={16} />}
onClick={hideEditViewModal}
- className="periscope-btn cancel-btn"
- icon={<X size={16} />}
>
Cancel
</Button>,
<Button
- className="periscope-btn primary"
key="submit"
- type="primary"
+ variant="solid"
+ prefix={<Check size={14} />}
loading={isLoadingUpdateAPIKey}
- icon={<Check size={14} />}
onClick={onUpdateApiKey}
>
Update Ingestion Key
@@ -1813,18 +1869,18 @@ function MultiIngestionSettings(): JSX.Element {
footer={[
<Button
key="cancel"
+ variant="ghost"
+ color="secondary"
+ prefix={<X size={16} />}
onClick={hideAddViewModal}
- className="periscope-btn cancel-btn"
- icon={<X size={16} />}
>
Cancel
</Button>,
<Button
- className="periscope-btn primary"
- test-id="create-new-key"
key="submit"
- type="primary"
- icon={<Check size={14} />}
+ variant="solid"
+ testId="create-new-key"
+ prefix={<Check size={14} />}
loading={isLoadingCreateAPIKey}
onClick={onCreateIngestionKey}
>
@@ -1858,7 +1914,7 @@ function MultiIngestionSettings(): JSX.Element {
]}
validateTrigger="onBlur"
>
- <Input placeholder="Enter Ingestion Key name" autoFocus />
+ <Input placeholder="Enter Ingestion Key name" />
</Form.Item>
<Form.Item
diff --git a/frontend/src/container/IngestionSettings/__tests__/MultiIngestionSettings.test.tsx b/frontend/src/container/IngestionSettings/__tests__/MultiIngestionSettings.test.tsx
index 121958eda7..c6f57d9ceb 100644
--- a/frontend/src/container/IngestionSettings/__tests__/MultiIngestionSettings.test.tsx
+++ b/frontend/src/container/IngestionSettings/__tests__/MultiIngestionSettings.test.tsx
@@ -1,24 +1,16 @@
import { GatewaytypesGettableIngestionKeysDTO } from 'api/generated/services/sigNoz.schemas';
import { QueryParams } from 'constants/query';
import { rest, server } from 'mocks-server/server';
-import { render, screen, userEvent, waitFor } from 'tests/test-utils';
-import { LimitProps } from 'types/api/ingestionKeys/limits/types';
import {
- AllIngestionKeyProps,
- IngestionKeyProps,
-} from 'types/api/ingestionKeys/types';
+ fireEvent,
+ render,
+ screen,
+ userEvent,
+ waitFor,
+} from 'tests/test-utils';
import MultiIngestionSettings from '../MultiIngestionSettings';
-// Extend the existing types to include limits with proper structure
-interface TestIngestionKeyProps extends Omit<IngestionKeyProps, 'limits'> {
- limits?: LimitProps[];
-}
-
-interface TestAllIngestionKeyProps extends Omit<AllIngestionKeyProps, 'data'> {
- data: TestIngestionKeyProps[];
-}
-
// Gateway API response type (uses actual schema types for contract safety)
interface TestGatewayIngestionKeysResponse {
status: string;
@@ -40,6 +32,16 @@ const TEST_EXPIRES_AT = '2030-01-01T00:00:00Z';
const TEST_WORKSPACE_ID = 'w1';
const INGESTION_SETTINGS_ROUTE = '/ingestion-settings';
+const GLOBAL_CONFIG_RESPONSE = {
+ status: 'success',
+ data: {
+ external_url: '',
+ ingestion_url: 'http://ingest.example.com',
+ ai_assistant_url: null,
+ mcp_url: null,
+ },
+};
+
describe('MultiIngestionSettings Page', () => {
beforeEach(() => {
mockPush.mockClear();
@@ -71,11 +73,6 @@ describe('MultiIngestionSettings Page', () => {
});
it('navigates to create alert with metrics count threshold', async () => {
- // Increase timeout - test involves multiple user interactions and async waits
- // that can exceed 5s default under heavy load (full test suite)
- const user = userEvent.setup({ pointerEventsCheck: 0 });
-
- // Arrange API response with a metrics daily count limit so the alert button is visible
const response: TestGatewayIngestionKeysResponse = {
status: 'success',
data: {
@@ -103,95 +100,91 @@ describe('MultiIngestionSettings Page', () => {
};
server.use(
+ rest.get('*/api/v1/global/config*', (_req, res, ctx) =>
+ res(ctx.status(200), ctx.json(GLOBAL_CONFIG_RESPONSE)),
+ ),
rest.get('*/api/v2/gateway/ingestion_keys*', (_req, res, ctx) =>
res(ctx.status(200), ctx.json(response)),
),
);
- // Render with initial route to test navigation
render(<MultiIngestionSettings />, undefined, {
initialRoute: INGESTION_SETTINGS_ROUTE,
});
- // Wait for ingestion key to load and expand the row to show limits
await screen.findByText('Key One');
- const expandButton = screen.getByRole('button', { name: /right Key One/i });
- await user.click(expandButton);
+ fireEvent.click(screen.getByRole('button', { name: /right Key One/i }));
- // Wait for limits section to render and click metrics alert button by test id
await screen.findByText('LIMITS');
- const metricsAlertBtn = (await screen.findByTestId(
- 'set-alert-btn-metrics',
- )) as HTMLButtonElement;
- await user.click(metricsAlertBtn);
+ fireEvent.click(
+ (await screen.findByTestId('set-alert-btn-metrics')) as HTMLButtonElement,
+ );
- // Wait for navigation to occur
await waitFor(() => {
expect(mockPush).toHaveBeenCalledTimes(1);
});
- // Assert: navigation occurred with correct query parameters
const navigationCall = mockPush.mock.calls[0][0] as string;
-
- // Check URL contains alerts/new route
expect(navigationCall).toContain('/alerts/new');
- // Parse query parameters
const urlParams = new URLSearchParams(navigationCall.split('?')[1]);
const thresholds = JSON.parse(urlParams.get(QueryParams.thresholds) || '{}');
- expect(thresholds).toBeDefined();
expect(thresholds[0].thresholdValue).toBe(1000);
+ expect(thresholds[0].unit).toBe('{count}');
- // Verify compositeQuery parameter exists and contains correct data
const compositeQuery = JSON.parse(
urlParams.get(QueryParams.compositeQuery) || '{}',
);
- expect(compositeQuery.builder).toBeDefined();
+ expect(compositeQuery.unit).toBe('{count}');
expect(compositeQuery.builder.queryData).toBeDefined();
- // Check that the query contains the correct filter expression for the key
const firstQueryData = compositeQuery.builder.queryData[0];
expect(firstQueryData.filter.expression).toContain(
"signoz.workspace.key.id='k1'",
);
-
- // Verify metric name for metrics signal
expect(firstQueryData.aggregations[0].metricName).toBe(
'signoz.meter.metric.datapoint.count',
);
- }, 15000);
- // skipping the flaky test
- it.skip('navigates to create alert for logs with size threshold', async () => {
- const user = userEvent.setup({ pointerEventsCheck: 0 });
+ expect(urlParams.get(QueryParams.yAxisUnit)).toBe('{count}');
+ expect(urlParams.get(QueryParams.ruleName)).toContain('metrics');
+ });
+
+ it('navigates to create alert for logs with GiB threshold and bytes yAxisUnit', async () => {
+ const GIB = 1073741824;
+ const sizeInBytes = 400 * GIB;
- // Arrange API response with a logs daily size limit so the alert button is visible
- const response: TestAllIngestionKeyProps = {
+ const response: TestGatewayIngestionKeysResponse = {
status: 'success',
- data: [
- {
- name: 'Key Two',
- expires_at: TEST_EXPIRES_AT,
- value: 'secret',
- workspace_id: TEST_WORKSPACE_ID,
- id: 'k2',
- created_at: TEST_CREATED_UPDATED,
- updated_at: TEST_CREATED_UPDATED,
- tags: [],
- limits: [
- {
- id: 'l2',
- signal: 'logs',
- config: { day: { size: 2048 } },
- },
- ],
- },
- ],
- _pagination: { page: 1, per_page: 10, pages: 1, total: 1 },
+ data: {
+ keys: [
+ {
+ name: 'Key Logs',
+ expires_at: new Date(TEST_EXPIRES_AT),
+ value: 'secret',
+ workspace_id: TEST_WORKSPACE_ID,
+ id: 'k2',
+ created_at: new Date(TEST_CREATED_UPDATED),
+ updated_at: new Date(TEST_CREATED_UPDATED),
+ tags: [],
+ limits: [
+ {
+ id: 'l2',
+ signal: 'logs',
+ config: { day: { size: sizeInBytes } },
+ },
+ ],
+ },
+ ],
+ _pagination: { page: 1, per_page: 10, pages: 1, total: 1 },
+ },
};
server.use(
- rest.get('*/workspaces/me/keys*', (_req, res, ctx) =>
+ rest.get('*/api/v1/global/config*', (_req, res, ctx) =>
+ res(ctx.status(200), ctx.json(GLOBAL_CONFIG_RESPONSE)),
+ ),
+ rest.get('*/api/v2/gateway/ingestion_keys*', (_req, res, ctx) =>
res(ctx.status(200), ctx.json(response)),
),
);
@@ -199,55 +192,102 @@ describe('MultiIngestionSettings Page', () => {
render(<MultiIngestionSettings />, undefined, {
initialRoute: INGESTION_SETTINGS_ROUTE,
});
+ await screen.findByText('Key Logs');
+ fireEvent.click(screen.getByRole('button', { name: /right Key Logs/i }));
- // Wait for ingestion key to load and expand the row to show limits
- await screen.findByText('Key Two');
- const expandButton = screen.getByRole('button', { name: /right Key Two/i });
- await user.click(expandButton);
-
- // Wait for limits section to render and click logs alert button by test id
await screen.findByText('LIMITS');
- const logsAlertBtn = (await screen.findByTestId(
- 'set-alert-btn-logs',
- )) as HTMLButtonElement;
- await user.click(logsAlertBtn);
+ fireEvent.click(
+ (await screen.findByTestId('set-alert-btn-logs')) as HTMLButtonElement,
+ );
- // Wait for navigation to occur
await waitFor(() => {
expect(mockPush).toHaveBeenCalledTimes(1);
});
- // Assert: navigation occurred with correct query parameters
const navigationCall = mockPush.mock.calls[0][0] as string;
-
- // Check URL contains alerts/new route
expect(navigationCall).toContain('/alerts/new');
- // Parse query parameters
const urlParams = new URLSearchParams(navigationCall.split('?')[1]);
- // Verify thresholds parameter
const thresholds = JSON.parse(urlParams.get(QueryParams.thresholds) || '{}');
- expect(thresholds).toBeDefined();
- expect(thresholds[0].thresholdValue).toBe(2048);
+ expect(thresholds[0].thresholdValue).toBe(400);
+ expect(thresholds[0].unit).toBe('GiBy');
- // Verify compositeQuery parameter exists and contains correct data
const compositeQuery = JSON.parse(
urlParams.get(QueryParams.compositeQuery) || '{}',
);
- expect(compositeQuery.builder).toBeDefined();
- expect(compositeQuery.builder.queryData).toBeDefined();
+ expect(compositeQuery.unit).toBe('bytes');
- // Check that the query contains the correct filter expression for the key
const firstQueryData = compositeQuery.builder.queryData[0];
expect(firstQueryData.filter.expression).toContain(
"signoz.workspace.key.id='k2'",
);
-
- // Verify metric name for logs signal
expect(firstQueryData.aggregations[0].metricName).toBe(
'signoz.meter.log.size',
);
+
+ expect(urlParams.get(QueryParams.yAxisUnit)).toBe('bytes');
+ expect(urlParams.get(QueryParams.ruleName)).toContain('logs');
+ });
+
+ it('shows alert CTAs in view mode and helper text in edit mode for configured limits', async () => {
+ const KEY_NAME = 'Key With Limits';
+ const response: TestGatewayIngestionKeysResponse = {
+ status: 'success',
+ data: {
+ keys: [
+ {
+ name: KEY_NAME,
+ expires_at: new Date(TEST_EXPIRES_AT),
+ value: 'secret',
+ workspace_id: TEST_WORKSPACE_ID,
+ id: 'k1',
+ created_at: new Date(TEST_CREATED_UPDATED),
+ updated_at: new Date(TEST_CREATED_UPDATED),
+ tags: [],
+ limits: [
+ {
+ id: 'l1',
+ signal: 'metrics',
+ config: { day: { count: 1000 } },
+ },
+ {
+ id: 'l2',
+ signal: 'logs',
+ config: { day: { size: 1073741824 } },
+ },
+ ],
+ },
+ ],
+ _pagination: { page: 1, per_page: 10, pages: 1, total: 1 },
+ },
+ };
+
+ server.use(
+ rest.get('*/api/v1/global/config*', (_req, res, ctx) =>
+ res(ctx.status(200), ctx.json(GLOBAL_CONFIG_RESPONSE)),
+ ),
+ rest.get('*/api/v2/gateway/ingestion_keys*', (_req, res, ctx) =>
+ res(ctx.status(200), ctx.json(response)),
+ ),
+ );
+
+ render(<MultiIngestionSettings />, undefined, {
+ initialRoute: INGESTION_SETTINGS_ROUTE,
+ });
+
+ await screen.findByText(KEY_NAME);
+ fireEvent.click(
+ screen.getByRole('button', { name: new RegExp(`right ${KEY_NAME}`, 'i') }),
+ );
+ await screen.findByText('LIMITS');
+
+ expect(screen.getAllByText('Set alert').length).toBeGreaterThan(0);
+
+ fireEvent.click(screen.getByRole('button', { name: 'Edit logs limit' }));
+ expect(
+ screen.getByText('You can set up an alert after saving'),
+ ).toBeInTheDocument();
});
it('switches to search API when search text is entered', async () => {
@@ -297,6 +337,9 @@ describe('MultiIngestionSettings Page', () => {
const searchHandler = jest.fn();
server.use(
+ rest.get('*/api/v1/global/config*', (_req, res, ctx) =>
+ res(ctx.status(200), ctx.json(GLOBAL_CONFIG_RESPONSE)),
+ ),
rest.get('*/api/v2/gateway/ingestion_keys', (req, res, ctx) => {
if (req.url.pathname.endsWith('/search')) {
return undefined;
diff --git a/frontend/src/container/SpanDetailsDrawer/LinkedSpans/LinkedSpans.tsx b/frontend/src/container/SpanDetailsDrawer/LinkedSpans/LinkedSpans.tsx
index 990a436c55..373c7cc002 100644
--- a/frontend/src/container/SpanDetailsDrawer/LinkedSpans/LinkedSpans.tsx
+++ b/frontend/src/container/SpanDetailsDrawer/LinkedSpans/LinkedSpans.tsx
@@ -4,6 +4,7 @@ import { Typography } from '@signozhq/ui';
import ROUTES from 'constants/routes';
import { formUrlParams } from 'container/TraceDetail/utils';
import { Span } from 'types/api/trace/getTraceV2';
+import { withBasePath } from 'utils/basePath';
import NoData from '../NoData/NoData';
@@ -26,11 +27,13 @@ function LinkedSpans(props: LinkedSpansProps): JSX.Element {
if (!item.traceId || !item.spanId) {
return null;
}
- return `${ROUTES.TRACE}/${item.traceId}${formUrlParams({
- spanId: item.spanId,
- levelUp: 0,
- levelDown: 0,
- })}`;
+ return withBasePath(
+ `${ROUTES.TRACE}/${item.traceId}${formUrlParams({
+ spanId: item.spanId,
+ levelUp: 0,
+ levelDown: 0,
+ })}`,
+ );
}, []);
// Filter out CHILD_OF references as they are parent-child relationships