Repository navigation
feat(app): filter for or exclude a pattern from Event Patterns #3665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: alex/FR-385-compact-pattern-predicate
Are you sure you want to change the base?
Changes from all commits
540fceb
b425513
819afc5
b8a40ec
26c9359
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| --- | ||
| '@hyperdx/app': minor | ||
| --- | ||
|
|
||
| feat: filter for or exclude a pattern from Event Patterns | ||
|
|
||
| Each row in Event Patterns now has "Filter for this pattern" and "Exclude this | ||
| pattern" buttons on hover. Each adds a filter for every event that fits the | ||
| pattern in the time range, not only the sampled rows, so the results table, | ||
| histogram and counts all update. Exclusions stack, show as pills next to the | ||
| other filters, survive sidebar filter changes, and are kept in the URL and in | ||
| saved searches. A new include replaces the previous one, and switching source | ||
| removes pattern filters. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,7 @@ import { | |
| import { | ||
| BuilderChartConfigWithDateRange, | ||
| ChartConfigWithDateRange, | ||
| ConditionFilter, | ||
| DisplayType, | ||
| Filter, | ||
| isPersistableUserId, | ||
|
|
@@ -102,6 +103,13 @@ import ResourceTerraformPopover from '@/components/Iac/ResourceTerraformPopover' | |
| import { InlineNameInput } from '@/components/InlineNameInput/InlineNameInput'; | ||
| import { InputControlled } from '@/components/InputControlled'; | ||
| import OnboardingModal from '@/components/OnboardingModal'; | ||
| import { | ||
| isPatternFilter, | ||
| parsePatternFilter, | ||
| PatternFilter, | ||
| PatternFilterAction, | ||
| withPatternFilter, | ||
| } from '@/components/Patterns/patternFilter'; | ||
| import { | ||
| isCustomSearchGroupBy, | ||
| resolveSearchGroupBy, | ||
|
|
@@ -1468,8 +1476,37 @@ function DBSearchPageContent() { | |
| onFilterChange: handleSetFilters, | ||
| dateTimeColumns, | ||
| knownColumns, | ||
| isPreservedFilter: isPatternFilter, | ||
| }); | ||
|
|
||
| const patternFilters = useMemo( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 minor — Pattern-filter state (parse list, add, remove) is hand-written inside DBSearchPage, which also tracks the same filters a second way
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond |
||
| () => | ||
| (filters ?? []).flatMap(filter => { | ||
| const parsed = parsePatternFilter(filter); | ||
| return parsed ? [parsed] : []; | ||
| }), | ||
| [filters], | ||
| ); | ||
| const removePatternFilter = useCallback( | ||
| (removed: PatternFilter) => | ||
| handleSetFilters( | ||
| (filters ?? []).filter( | ||
| f => f.type !== 'sql' || f.condition !== removed.condition, | ||
| ), | ||
| ), | ||
| [filters, handleSetFilters], | ||
| ); | ||
| // Showing matches switches to the results view. | ||
| const addPatternFilter = useCallback( | ||
| (added: ConditionFilter, action: PatternFilterAction) => { | ||
| handleSetFilters(withPatternFilter(filters ?? [], added)); | ||
| if (action === 'include') { | ||
| setAnalysisMode('results'); | ||
| } | ||
| }, | ||
| [filters, handleSetFilters, setAnalysisMode], | ||
| ); | ||
|
|
||
| useEffect(() => { | ||
| // If the user changes the source dropdown, reset the select and orderby fields | ||
| // to match the new source selected | ||
|
|
@@ -2659,6 +2696,8 @@ function DBSearchPageContent() { | |
| searchFilters={searchFilters} | ||
| chartConfig={filtersChartConfig} | ||
| dateTimeColumns={dateTimeColumns} | ||
| patternFilters={patternFilters} | ||
| onRemovePatternFilter={removePatternFilter} | ||
| mt={6} | ||
| /> | ||
| </form> | ||
|
|
@@ -2800,6 +2839,7 @@ function DBSearchPageContent() { | |
| draftPatternColumn={draftPatternColumn} | ||
| onDraftPatternColumnChange={setDraftPatternColumn} | ||
| onSubmit={onSubmit} | ||
| onPatternFilter={addPatternFilter} | ||
| totalCountConfig={totalCountConfig} | ||
| totalCountQueryKeyPrefix={QUERY_KEY_PREFIX} | ||
| /> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔵 minor — Two separate derivations of the pattern-filter set
useSearchPageFilterStatealready splits pattern filters out offiltersthroughisPreservedFilter(searchFilters.tsx:129). DBSearchPage then parsesfiltersagain for the pills and adds its own remove/add handlers inline. Have the hook return the preserved filters and a remover, or move this into ausePatternFiltershook inpatternFilter.ts, so the pills and the facet-preservation logic use one source.Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
searchFilters.tsxstays pattern-agnostic on purpose: it only knowsisPreservedFilter, and the page derives the pills from the samefiltersthe hook reads, so the two always agree.