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(logs-infra): body filtering on infra monitoring; enable new drawer view (#12623)
Aditya Singhafe62d77b09b
diff --git a/frontend/src/components/LogDetail/LogDetail.interfaces.ts b/frontend/src/components/LogDetail/LogDetail.interfaces.tsindex 92c248e7c5..718a65d836 100644--- a/frontend/src/components/LogDetail/LogDetail.interfaces.ts+++ b/frontend/src/components/LogDetail/LogDetail.interfaces.ts@@ -19,6 +19,7 @@ export type LogDetailProps = {onScrollToLog?: (logId: string) => void;handleOpenInExplorer?: MouseEventHandler;getContainer?: DrawerProps['getContainer'];+ onApplyLogFilter?: (expression: string) => void;} & Pick<AddToQueryHOCProps, 'onAddToQuery'> &Partial<Pick<ActionItemProps, 'onClickActionItem'>> &Pick<DrawerProps, 'onClose'>;diff --git a/frontend/src/components/LogDetail/index.tsx b/frontend/src/components/LogDetail/index.tsxindex 5ae8f9f503..887923186f 100644--- a/frontend/src/components/LogDetail/index.tsx+++ b/frontend/src/components/LogDetail/index.tsx@@ -75,6 +75,7 @@ function LogDetailInner({onScrollToLog,handleOpenInExplorer,getContainer,+ onApplyLogFilter,}: LogDetailInnerProps): JSX.Element {const initialContextQuery = useInitialQuery(log);const [contextQuery, setContextQuery] = useState<Query | undefined>(@@ -519,6 +520,7 @@ function LogDetailInner({selectedOptions={options}listViewPanelSelectedFields={listViewPanelSelectedFields}handleChangeSelectedView={handleChangeSelectedView}+ onApplyLogFilter={onApplyLogFilter}/>)}{!isLogDetailsV2 && selectedView === VIEW_TYPES.JSON && (diff --git a/frontend/src/components/LogDetail/useIsLogDetailsV2.ts b/frontend/src/components/LogDetail/useIsLogDetailsV2.tsindex 2b15a48693..24f18f57e6 100644--- a/frontend/src/components/LogDetail/useIsLogDetailsV2.ts+++ b/frontend/src/components/LogDetail/useIsLogDetailsV2.ts@@ -1,9 +1,10 @@import ROUTES from 'constants/routes';import { useLocation } from 'react-router-dom';-// v2 is rolled out only on the logs explorer route for now; every other surface-// (dashboards, infra monitoring, etc.) keeps the v1 log details view.export function useIsLogDetailsV2(): boolean {const { pathname } = useLocation();- return pathname === ROUTES.LOGS_EXPLORER;+ return (+ pathname === ROUTES.LOGS_EXPLORER ||+ pathname.startsWith(ROUTES.INFRASTRUCTURE_MONITORING_BASE)+ );}diff --git a/frontend/src/container/InfraMonitoringK8sV2/EntityDetailsUtils/EntityLogs/EntityLogs.tsx b/frontend/src/container/InfraMonitoringK8sV2/EntityDetailsUtils/EntityLogs/EntityLogs.tsxindex 878536fcea..c101ba9912 100644--- a/frontend/src/container/InfraMonitoringK8sV2/EntityDetailsUtils/EntityLogs/EntityLogs.tsx+++ b/frontend/src/container/InfraMonitoringK8sV2/EntityDetailsUtils/EntityLogs/EntityLogs.tsx@@ -82,6 +82,7 @@ function EntityLogsContent({const { activeLog, selectedTab, handleSetActiveLog, handleCloseLogDetail } =useLogDetailHandlers();+ // TODO: Move away from using onAddToQuery after old drawer cleanupconst onAddToQuery = useCallback((fieldKey: string, fieldValue: string, operator: string): void => {handleCloseLogDetail();@@ -104,6 +105,21 @@ function EntityLogsContent({[userExpression, querySearchOnRun, handleCloseLogDetail, category],);+ const onApplyLogFilter = useCallback(+ (expression: string): void => {+ handleCloseLogDetail();++ const newUser = userExpression.trim()+ ? `${userExpression} AND ${expression}`+ : expression;++ querySearchOnRun(newUser);++ logInfraDrawerFilterCustomizedEvent(category, 'logs', newUser, 'logs');+ },+ [userExpression, querySearchOnRun, handleCloseLogDetail, category],+ );+const {logs,loadMoreLogs,@@ -328,6 +344,7 @@ function EntityLogsContent({selectedTab={selectedTab}onAddToQuery={onAddToQuery}onClickActionItem={onAddToQuery}+ onApplyLogFilter={onApplyLogFilter}onScrollToLog={handleScrollToLog}handleOpenInExplorer={(e) => handleOpenInExplorer(e, activeLog)}getContainer={(): HTMLElement =>diff --git a/frontend/src/container/LogDetailedView/Overview.tsx b/frontend/src/container/LogDetailedView/Overview.tsxindex bb128c7990..5e614b19a4 100644--- a/frontend/src/container/LogDetailedView/Overview.tsx+++ b/frontend/src/container/LogDetailedView/Overview.tsx@@ -41,6 +41,7 @@ interface OverviewProps {selectedOptions: OptionsQuery;listViewPanelSelectedFields?: IField[] | null;handleChangeSelectedView?: ChangeViewFunctionType;+ onApplyLogFilter?: (expression: string) => void;}type Props = OverviewProps &@@ -55,6 +56,7 @@ function Overview({selectedOptions,listViewPanelSelectedFields,handleChangeSelectedView,+ onApplyLogFilter,}: Props): JSX.Element {const [isWrapWord, setIsWrapWord] = useState<boolean>(true);const [isSearchVisible, setIsSearchVisible] = useState<boolean>(true);@@ -67,6 +69,7 @@ function Overview({const { actions, visibleActions } = useLogAttributeActions({handleChangeSelectedView,isListViewPanel,+ onApplyLogFilter,});const isLogDetailsV2 = useIsLogDetailsV2();diff --git a/frontend/src/container/LogDetailedView/hooks/useLogAttributeActions.tsx b/frontend/src/container/LogDetailedView/hooks/useLogAttributeActions.tsxindex 0565cdc960..aec5dacde0 100644--- a/frontend/src/container/LogDetailedView/hooks/useLogAttributeActions.tsx+++ b/frontend/src/container/LogDetailedView/hooks/useLogAttributeActions.tsx@@ -1,6 +1,7 @@import { useCallback, useMemo } from 'react';import { useLocation } from 'react-router-dom';import { CircleMinus, CirclePlus, Layers, RefreshCw } from '@signozhq/icons';+import { convertFiltersToExpression } from 'components/QueryBuilderV2/utils';import { FeatureKeys } from 'constants/features';import { QueryParams } from 'constants/query';import ROUTES from 'constants/routes';@@ -15,6 +16,7 @@ import {VisibleActionsConfig,} from 'periscope/components/PrettyView/PrettyView';import { useAppContext } from 'providers/App/App';+import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';import { LogDetailsAction } from '../constants';import {@@ -27,6 +29,7 @@ import {interface UseLogAttributeActionsParams {handleChangeSelectedView?: ChangeViewFunctionType;isListViewPanel?: boolean;+ onApplyLogFilter?: (expression: string) => void;}interface UseLogAttributeActionsResult {@@ -50,6 +53,7 @@ const ALL_LEAF_ACTIONS = [export function useLogAttributeActions({handleChangeSelectedView,isListViewPanel = false,+ onApplyLogFilter,}: UseLogAttributeActionsParams): UseLogAttributeActionsResult {const { pathname } = useLocation();const { stagedQuery, updateQueriesData } = useQueryBuilder();@@ -65,9 +69,6 @@ export function useLogAttributeActions({const filterFor = useCallback((context: FieldContext, isFilterIn: boolean): void => {- if (!stagedQuery) {- return;- }const target = buildLogFilterTarget(context.fieldKeyPath,context.fieldValue,@@ -77,6 +78,29 @@ export function useLogAttributeActions({? target.filterInOperator: target.filterOutOperator;+ // Non-explorer surfaces (infra monitoring, etc.) apply a ready v5+ // expression fragment to their own query.+ if (onApplyLogFilter) {+ const base = {+ filters: { items: [], op: 'AND' },+ } as unknown as IBuilderQuery;+ const nextFilters = getFilterQueryData(+ base,+ target,+ context.fieldValue,+ operator,+ ).filters ?? { items: [], op: 'AND' };+ const { expression } = convertFiltersToExpression(nextFilters);+ if (expression) {+ onApplyLogFilter(expression);+ }+ return;+ }++ if (!stagedQuery) {+ return;+ }+const updatedQuery = updateQueriesData(stagedQuery,'queryData',@@ -99,6 +123,7 @@ export function useLogAttributeActions({updateQueriesData,viewName,handleChangeSelectedView,+ onApplyLogFilter,],);@@ -179,20 +204,25 @@ export function useLogAttributeActions({buildLogFilterTarget(fieldKeyPath, undefined, isBodyJsonQueryEnabled).isRestricted;+ // The using surface must provide an apply path.+ const canApplyFilter = !!handleChangeSelectedView || !!onApplyLogFilter;+return [{key: LogDetailsAction.FILTER_IN,label: 'Filter for value',icon: <CirclePlus size={12} />,onClick: (context): void => filterFor(context, true),- shouldHide: (_key, fieldKeyPath): boolean => isRestricted(fieldKeyPath),+ shouldHide: (_key, fieldKeyPath): boolean =>+ !canApplyFilter || isRestricted(fieldKeyPath),},{key: LogDetailsAction.FILTER_OUT,label: 'Filter out value',icon: <CircleMinus size={12} />,onClick: (context): void => filterFor(context, false),- shouldHide: (_key, fieldKeyPath): boolean => isRestricted(fieldKeyPath),+ shouldHide: (_key, fieldKeyPath): boolean =>+ !canApplyFilter || isRestricted(fieldKeyPath),},{key: LogDetailsAction.GROUP_BY,@@ -200,8 +230,10 @@ export function useLogAttributeActions({icon: <Layers size={12} />,onClick: groupBy,shouldHide: (_key, fieldKeyPath): boolean =>+ !handleChangeSelectedView ||!buildLogFilterTarget(fieldKeyPath, undefined, isBodyJsonQueryEnabled)- .groupBySupported || isOldExplorerOrLive,+ .groupBySupported ||+ isOldExplorerOrLive,},{key: LogDetailsAction.REPLACE_FILTER,@@ -209,7 +241,9 @@ export function useLogAttributeActions({icon: <RefreshCw size={12} />,onClick: replaceFilter,shouldHide: (_key, fieldKeyPath): boolean =>- isRestricted(fieldKeyPath) || isOldExplorerOrLive,+ !handleChangeSelectedView ||+ isRestricted(fieldKeyPath) ||+ isOldExplorerOrLive,},];}, [@@ -218,6 +252,8 @@ export function useLogAttributeActions({replaceFilter,isBodyJsonQueryEnabled,isOldExplorerOrLive,+ handleChangeSelectedView,+ onApplyLogFilter,]);const visibleActions = useMemo<VisibleActionsConfig>(