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 error state for alert not found (#10132)

Amlan Kumar Nandy85953c9a4cb9
diff --git a/frontend/src/constants/query.ts b/frontend/src/constants/query.ts
index 941b4b81c3..3611b834fb 100644
--- a/frontend/src/constants/query.ts
+++ b/frontend/src/constants/query.ts
@@ -54,4 +54,5 @@ export enum QueryParams {
version = 'version',
source = 'source',
showClassicCreateAlertsPage = 'showClassicCreateAlertsPage',
+ isTestAlert = 'isTestAlert',
}
diff --git a/frontend/src/pages/AlertDetails/AlertDetails.tsx b/frontend/src/pages/AlertDetails/AlertDetails.tsx
index df62266b25..d77d601992 100644
--- a/frontend/src/pages/AlertDetails/AlertDetails.tsx
+++ b/frontend/src/pages/AlertDetails/AlertDetails.tsx
@@ -1,15 +1,17 @@
import { useEffect, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useLocation } from 'react-router-dom';
-import { Breadcrumb, Button, Divider, Empty } from 'antd';
+import { Breadcrumb, Button, Divider } from 'antd';
import logEvent from 'api/common/logEvent';
import classNames from 'classnames';
import { Filters } from 'components/AlertDetailsFilters/Filters';
import RouteTab from 'components/RouteTab';
import Spinner from 'components/Spinner';
+import { QueryParams } from 'constants/query';
import ROUTES from 'constants/routes';
import { CreateAlertProvider } from 'container/CreateAlertV2/context';
import { getCreateAlertLocalStateFromAlertDef } from 'container/CreateAlertV2/utils';
+import useUrlQuery from 'hooks/useUrlQuery';
import history from 'lib/history';
import { AlertTypes } from 'types/api/alerts/alertTypes';
import {
@@ -18,6 +20,7 @@ import {
} from 'types/api/alerts/alertTypesV2';
import AlertHeader from './AlertHeader/AlertHeader';
+import AlertNotFound from './AlertNotFound';
import { useGetAlertRuleDetails, useRouteTabUtils } from './hooks';
import { AlertDetailsStatusRendererProps } from './types';
@@ -77,7 +80,7 @@ BreadCrumbItem.defaultProps = {
function AlertDetails(): JSX.Element {
const { pathname } = useLocation();
const { routes } = useRouteTabUtils();
- const { t } = useTranslation(['alerts']);
+ const params = useUrlQuery();
const {
isLoading,
@@ -88,10 +91,27 @@ function AlertDetails(): JSX.Element {
alertDetailsResponse,
} = useGetAlertRuleDetails();
+ const isTestAlert = useMemo(() => {
+ return params.get(QueryParams.isTestAlert) === 'true';
+ }, [params]);
+
+ const getDocumentTitle = useMemo(() => {
+ const alertTitle = alertDetailsResponse?.payload?.data?.alert;
+ if (alertTitle) {
+ return alertTitle;
+ }
+ if (isTestAlert) {
+ return 'Test Alert';
+ }
+ if (isLoading) {
+ return document.title;
+ }
+ return 'Alert Not Found';
+ }, [alertDetailsResponse?.payload?.data?.alert, isTestAlert, isLoading]);
+
useEffect(() => {
- const alertTitle = alertDetailsResponse?.payload?.data.alert;
- document.title = alertTitle || document.title;
- }, [alertDetailsResponse?.payload?.data.alert, isRefetching]);
+ document.title = getDocumentTitle;
+ }, [getDocumentTitle]);
const alertRuleDetails = useMemo(
() => alertDetailsResponse?.payload?.data as PostableAlertRuleV2 | undefined,
@@ -106,13 +126,10 @@ function AlertDetails(): JSX.Element {
if (
isError ||
!isValidRuleId ||
- (alertDetailsResponse && alertDetailsResponse.statusCode !== 200)
+ (alertDetailsResponse && alertDetailsResponse.statusCode !== 200) ||
+ (!isLoading && !alertRuleDetails)
) {
- return (
- <div className="alert-empty-card">
- <Empty description={t('alert_rule_not_found')} />
- </div>
- );
+ return <AlertNotFound isTestAlert={isTestAlert} />;
}
const handleTabChange = (route: string): void => {
diff --git a/frontend/src/pages/AlertDetails/AlertNotFound/AlertNotFound.styles.scss b/frontend/src/pages/AlertDetails/AlertNotFound/AlertNotFound.styles.scss
new file mode 100644
index 0000000000..a8ecd2e7ae
--- /dev/null
+++ b/frontend/src/pages/AlertDetails/AlertNotFound/AlertNotFound.styles.scss
@@ -0,0 +1,136 @@
+.alert-not-found {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ height: 60vh;
+ width: 500px;
+ gap: 24px;
+ margin: 0 auto;
+
+ .description {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 6px;
+
+ .not-found-img {
+ height: 32px;
+ width: 32px;
+ }
+
+ .not-found-text {
+ color: var(--bg-vanilla-400);
+ font-family: Inter;
+ font-size: 14px;
+ font-style: normal;
+ font-weight: 500;
+ line-height: 20px;
+ letter-spacing: -0.07px;
+ text-align: center;
+ }
+ }
+
+ .reasons {
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+
+ .reason {
+ display: flex;
+ padding: 12px;
+ align-items: flex-start;
+ gap: 12px;
+ border-radius: 4px;
+ background: rgba(171, 189, 255, 0.04);
+
+ .construction-img,
+ .broom-img {
+ height: 16px;
+ width: 16px;
+ }
+
+ .text {
+ color: var(--bg-vanilla-400);
+ font-family: Inter;
+ font-size: 14px;
+ font-style: normal;
+ font-weight: 400;
+ line-height: 20px;
+ letter-spacing: -0.07px;
+ }
+ }
+ }
+
+ .none-of-above {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 12px;
+
+ .text {
+ color: var(--bg-vanilla-400);
+ font-family: Inter;
+ font-size: 14px;
+ font-style: normal;
+ font-weight: 500;
+ line-height: 20px;
+ letter-spacing: -0.07px;
+ text-align: center;
+ }
+
+ .action-btns {
+ display: flex;
+ gap: 8px;
+
+ .action-btn {
+ display: flex;
+ width: 160px;
+ padding: 4px 8px;
+ justify-content: center;
+ align-items: center;
+ gap: 8px;
+ border-radius: 2px;
+ border: 1px solid var(--bg-slate-400);
+ background: var(--bg-slate-500);
+ box-shadow: none;
+
+ .ant-btn-icon {
+ margin-inline-end: 0px;
+ }
+ }
+ }
+ }
+}
+
+.lightMode {
+ .alert-not-found {
+ .description {
+ .not-found-text {
+ color: var(--bg-ink-400);
+ }
+ }
+
+ .reasons {
+ .reason {
+ background: var(--bg-vanilla-300);
+ .text {
+ color: var(--bg-ink-400);
+ }
+ }
+ }
+
+ .none-of-above {
+ .text {
+ color: var(--bg-ink-400);
+ }
+
+ .action-btns {
+ .action-btn {
+ border: 1px solid var(--bg-vanilla-300);
+ background: var(--bg-vanilla-300);
+ }
+ }
+ }
+ }
+}
diff --git a/frontend/src/pages/AlertDetails/AlertNotFound/AlertNotFound.tsx b/frontend/src/pages/AlertDetails/AlertNotFound/AlertNotFound.tsx
new file mode 100644
index 0000000000..40eae0ff16
--- /dev/null
+++ b/frontend/src/pages/AlertDetails/AlertNotFound/AlertNotFound.tsx
@@ -0,0 +1,96 @@
+import { Button, Typography } from 'antd';
+import ROUTES from 'constants/routes';
+import { useGetTenantLicense } from 'hooks/useGetTenantLicense';
+import { useSafeNavigate } from 'hooks/useSafeNavigate';
+import { LifeBuoy, List } from 'lucide-react';
+import { handleContactSupport } from 'pages/Integrations/utils';
+
+import './AlertNotFound.styles.scss';
+
+interface AlertNotFoundProps {
+ isTestAlert: boolean;
+}
+
+function AlertNotFound({ isTestAlert }: AlertNotFoundProps): JSX.Element {
+ const { isCloudUser: isCloudUserVal } = useGetTenantLicense();
+ const { safeNavigate } = useSafeNavigate();
+
+ const checkAllRulesHandler = (): void => {
+ safeNavigate(ROUTES.LIST_ALL_ALERT);
+ };
+
+ const contactSupportHandler = (): void => {
+ handleContactSupport(isCloudUserVal);
+ };
+
+ return (
+ <div className="alert-not-found">
+ <section className="description">
+ <img src="/Icons/no-data.svg" alt="no-data" className="not-found-img" />
+ <Typography.Text className="not-found-text">
+ Uh-oh! We couldn&apos;t find the given alert rule.
+ </Typography.Text>
+ <Typography.Text className="not-found-text">
+ {isTestAlert
+ ? 'This can happen in the following scenario -'
+ : 'This can happen in either of the following scenarios -'}
+ </Typography.Text>
+ </section>
+ <section className="reasons">
+ {!isTestAlert && (
+ <>
+ <div className="reason">
+ <img
+ src="/Icons/construction.svg"
+ alt="no-data"
+ className="construction-img"
+ />
+ <Typography.Text className="text">
+ The alert rule link is incorrect, please verify it once.
+ </Typography.Text>
+ </div>
+ <div className="reason">
+ <img src="/Icons/broom.svg" alt="no-data" className="broom-img" />
+ <Typography.Text className="text">
+ The alert rule you&apos;re trying to check has been deleted.
+ </Typography.Text>
+ </div>
+ </>
+ )}
+ {isTestAlert && (
+ <div className="reason">
+ <img src="/Icons/broom.svg" alt="no-data" className="broom-img" />
+ <Typography.Text className="text">
+ You clicked on the Alert notification link received when testing a new
+ Alert rule. Once the alert rule is saved, future notifications will link
+ to actual alerts.
+ </Typography.Text>
+ </div>
+ )}
+ </section>
+ <section className="none-of-above">
+ <Typography.Text className="text">
+ If you feel the issue is none of the above, please contact support.
+ </Typography.Text>
+ <div className="action-btns">
+ <Button
+ className="action-btn"
+ icon={<List size={14} />}
+ onClick={checkAllRulesHandler}
+ >
+ Check all rules
+ </Button>
+ <Button
+ className="action-btn"
+ icon={<LifeBuoy size={14} />}
+ onClick={contactSupportHandler}
+ >
+ Contact Support
+ </Button>
+ </div>
+ </section>
+ </div>
+ );
+}
+
+export default AlertNotFound;
diff --git a/frontend/src/pages/AlertDetails/AlertNotFound/index.ts b/frontend/src/pages/AlertDetails/AlertNotFound/index.ts
new file mode 100644
index 0000000000..be70a4b85f
--- /dev/null
+++ b/frontend/src/pages/AlertDetails/AlertNotFound/index.ts
@@ -0,0 +1,3 @@
+import AlertNotFound from './AlertNotFound';
+
+export default AlertNotFound;
diff --git a/frontend/src/pages/AlertDetails/__tests__/AlertNotFound.test.tsx b/frontend/src/pages/AlertDetails/__tests__/AlertNotFound.test.tsx
new file mode 100644
index 0000000000..ab23f333ee
--- /dev/null
+++ b/frontend/src/pages/AlertDetails/__tests__/AlertNotFound.test.tsx
@@ -0,0 +1,92 @@
+import { render, screen } from '@testing-library/react';
+import ROUTES from 'constants/routes';
+import * as useGetTenantLicense from 'hooks/useGetTenantLicense';
+import * as useSafeNavigate from 'hooks/useSafeNavigate';
+import { userEvent } from 'tests/test-utils';
+
+import AlertNotFound from '../AlertNotFound';
+
+jest.mock('lib/history', () => ({
+ __esModule: true,
+ default: {
+ push: jest.fn(),
+ },
+}));
+
+import history from 'lib/history';
+
+const mockSafeNavigate = jest.fn();
+const useGetTenantLicenseSpy = jest.spyOn(
+ useGetTenantLicense,
+ 'useGetTenantLicense',
+);
+const useSafeNavigateSpy = jest.spyOn(useSafeNavigate, 'useSafeNavigate');
+
+describe('AlertNotFound', () => {
+ beforeEach(() => {
+ mockSafeNavigate.mockClear();
+ window.open = jest.fn();
+ useGetTenantLicenseSpy.mockReturnValue({
+ isCloudUser: false,
+ } as ReturnType<typeof useGetTenantLicense.useGetTenantLicense>);
+ useSafeNavigateSpy.mockReturnValue({
+ safeNavigate: mockSafeNavigate,
+ });
+ });
+
+ it('should render the correct error message for test alerts', () => {
+ render(<AlertNotFound isTestAlert />);
+ expect(
+ screen.getByText("Uh-oh! We couldn't find the given alert rule."),
+ ).toBeInTheDocument();
+ expect(
+ screen.getByText('This can happen in the following scenario -'),
+ ).toBeInTheDocument();
+ expect(
+ screen.getByText(
+ 'You clicked on the Alert notification link received when testing a new Alert rule. Once the alert rule is saved, future notifications will link to actual alerts.',
+ ),
+ ).toBeInTheDocument();
+ });
+
+ it('should render the correct error message for non-existing alerts', () => {
+ render(<AlertNotFound isTestAlert={false} />);
+ expect(
+ screen.getByText("Uh-oh! We couldn't find the given alert rule."),
+ ).toBeInTheDocument();
+ expect(
+ screen.getByText('This can happen in either of the following scenarios -'),
+ ).toBeInTheDocument();
+ expect(
+ screen.getByText('The alert rule link is incorrect, please verify it once.'),
+ ).toBeInTheDocument();
+ expect(
+ screen.getByText("The alert rule you're trying to check has been deleted."),
+ ).toBeInTheDocument();
+ });
+
+ it('should navigate to the list all alerts page when the check all rules button is clicked', async () => {
+ const user = userEvent.setup();
+ render(<AlertNotFound isTestAlert={false} />);
+ await user.click(screen.getByText('Check all rules'));
+ expect(mockSafeNavigate).toHaveBeenCalledWith(ROUTES.LIST_ALL_ALERT);
+ });
+
+ it('should navigate to the correct support page for cloud users when button is clicked', async () => {
+ const user = userEvent.setup();
+ useGetTenantLicenseSpy.mockReturnValueOnce({
+ isCloudUser: true,
+ } as ReturnType<typeof useGetTenantLicense.useGetTenantLicense>);
+
+ render(<AlertNotFound isTestAlert={false} />);
+ await user.click(screen.getByText('Contact Support'));
+ expect(history.push).toHaveBeenCalledWith('/support');
+ });
+
+ it('should navigate to the support page for self-hosted users when the contact support button is clicked', async () => {
+ const user = userEvent.setup();
+ render(<AlertNotFound isTestAlert={false} />);
+ await user.click(screen.getByText('Contact Support'));
+ expect(window.open).toHaveBeenCalledWith('https://signoz.io/slack', '_blank');
+ });
+});