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
Alerting: Add fuzzy search to alert list view #63931
Conversation
@@ -2693,9 +2693,6 @@ exports[`better eslint`] = { | |||
"public/app/features/alerting/unified/components/rules/RuleDetailsDataSources.tsx:5381": [ | |||
[0, 0, 0, "Do not use any type assertions.", "0"] | |||
], | |||
"public/app/features/alerting/unified/components/rules/RulesFilter.tsx:5381": [ |
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.
🎉
public/app/features/alerting/unified/components/rules/RulesFilter.tsx
Outdated
Show resolved
Hide resolved
public/app/features/alerting/unified/components/rules/RulesFilter.tsx
Outdated
Show resolved
Hide resolved
public/app/features/alerting/unified/components/rules/RulesFilter.tsx
Outdated
Show resolved
Hide resolved
@@ -76,37 +77,64 @@ export const useFilteredRules = (namespaces: CombinedRuleNamespace[], filterStat | |||
return useMemo(() => filterRules(namespaces, filterState), [namespaces, filterState]); | |||
}; | |||
|
|||
const ufuzzy = new uFuzzy({ |
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.
nit: Can we add a link to the ufuzzy docs here so we can find out what these params mean?
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.
or just note that they're effectively Damerau–Levenshtein distance allowances for each term/word in the needle. (typo tolerance)
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.
Yea I kinda guessed as much (though I'm not familiar with the Damerau variant) :)
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.
I'm not familiar with the Damerau variant
it just treats adjacent transpositions as an edit distance of 1 instead of 2 (removal + insertion). now you're familiar with it 🤣
but i'll tell you a secret: uFuzzy just constructs a regex with all the variations 🐵. since building actual M x N string distance tables in JS for every item would be 🐢 🐌 🦥
@@ -26,32 +26,37 @@ beforeAll(() => { | |||
}); | |||
|
|||
describe('filterRules', function () { | |||
it('should filter out rules by name filter', function () { | |||
// Typos there are deliberate to test the fuzzy search | |||
it.each(['cpu', 'hi usage', 'usge'])('should filter out rules by name filter = "%s"', function (nameFilter) { |
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.
Nice!
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.
Nice one! 🙌
…-alert-rules-fuzzy-search
…-alert-rules-fuzzy-search
* Add basic fuzzy search * Add fuzzy search to rule name, group and namespace filters * Add tests * Apply sort order when filtering * Filter rules on Enter instead of onChange * Add minor rule stats performance improvements * Fix tests * Remove unused code, add ufuzzy inline docs * Use form submit to set query string, add debounce docs
What is this feature?
This feature adds fuzzy search to the alert list view search
Entities capable of being fuzzy searched:
Additionally changes the search behavior to only apply on
enter
instead of debouncing on input.Why do we need this feature?
We want to allow users to make typos and non-full names when searching
Who is this feature for?
Alerting users
Which issue(s) does this PR fix?:
Fixes #62587
Search in multiple words
Typos