-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[RAM] Add shareable rule status filter #130705
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b337f96
rule state filter
JiaweiWu 0576f50
turn off experiment
JiaweiWu 31aa11b
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine 2e6ded4
Merge branch 'main' into issue-130160-state-filter
kibanamachine b42c959
Status filter API call
JiaweiWu 10ece1c
Fix tests
JiaweiWu 6f1b580
Merge branch 'main' into issue-130160-state-filter
kibanamachine c18a582
rename state to status, added tests
JiaweiWu be1505c
merge conflicts
JiaweiWu 6882021
Address comments and fix tests
JiaweiWu 82170a2
Revert experiment flag
JiaweiWu 1084bbb
Remove unused translations
JiaweiWu c59e3d8
Addressed comments
JiaweiWu 0be9814
Merge branch 'main' into issue-130160-state-filter
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...i/public/application/internal/shareable_components_sandbox/rule_status_filter_sandbox.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React, { useState } from 'react'; | ||
import { RuleStatusFilterProps } from '../../../types'; | ||
import { getRuleStatusFilterLazy } from '../../../common/get_rule_status_filter'; | ||
|
||
export const RuleStatusFilterSandbox = () => { | ||
const [selectedStatuses, setSelectedStatuses] = useState< | ||
RuleStatusFilterProps['selectedStatuses'] | ||
>([]); | ||
|
||
return ( | ||
<div style={{ flex: 1 }}> | ||
{getRuleStatusFilterLazy({ | ||
selectedStatuses, | ||
onChange: setSelectedStatuses, | ||
})} | ||
<div>Selected states: {JSON.stringify(selectedStatuses)}</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,14 +32,62 @@ describe('mapFiltersToKql', () => { | |
]); | ||
}); | ||
|
||
test('should handle ruleStatusesFilter', () => { | ||
test('should handle ruleExecutionStatusesFilter', () => { | ||
expect( | ||
mapFiltersToKql({ | ||
ruleStatusesFilter: ['alert', 'statuses', 'filter'], | ||
ruleExecutionStatusesFilter: ['alert', 'statuses', 'filter'], | ||
}) | ||
).toEqual(['alert.attributes.executionStatus.status:(alert or statuses or filter)']); | ||
}); | ||
|
||
test('should handle ruleStatusesFilter', () => { | ||
expect( | ||
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. should we add a test for just 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. yep, good idea! |
||
mapFiltersToKql({ | ||
ruleStatusesFilter: ['enabled'], | ||
}) | ||
).toEqual([ | ||
'alert.attributes.enabled:(true) and not (alert.attributes.muteAll:true OR alert.attributes.snoozeEndTime > now)', | ||
]); | ||
|
||
expect( | ||
mapFiltersToKql({ | ||
ruleStatusesFilter: ['disabled'], | ||
}) | ||
).toEqual([ | ||
'alert.attributes.enabled:(false) and not (alert.attributes.muteAll:true OR alert.attributes.snoozeEndTime > now)', | ||
]); | ||
|
||
expect( | ||
mapFiltersToKql({ | ||
ruleStatusesFilter: ['snoozed'], | ||
}) | ||
).toEqual(['(alert.attributes.muteAll:true OR alert.attributes.snoozeEndTime > now)']); | ||
|
||
expect( | ||
mapFiltersToKql({ | ||
ruleStatusesFilter: ['enabled', 'snoozed'], | ||
}) | ||
).toEqual([ | ||
'alert.attributes.enabled:(true) or (alert.attributes.muteAll:true OR alert.attributes.snoozeEndTime > now)', | ||
]); | ||
|
||
expect( | ||
mapFiltersToKql({ | ||
ruleStatusesFilter: ['disabled', 'snoozed'], | ||
}) | ||
).toEqual([ | ||
'alert.attributes.enabled:(false) or (alert.attributes.muteAll:true OR alert.attributes.snoozeEndTime > now)', | ||
]); | ||
|
||
expect( | ||
mapFiltersToKql({ | ||
ruleStatusesFilter: ['enabled', 'disabled', 'snoozed'], | ||
}) | ||
).toEqual([ | ||
'alert.attributes.enabled:(true or false) or (alert.attributes.muteAll:true OR alert.attributes.snoozeEndTime > now)', | ||
]); | ||
}); | ||
|
||
test('should handle typesFilter and actionTypesFilter', () => { | ||
expect( | ||
mapFiltersToKql({ | ||
|
@@ -52,12 +100,12 @@ describe('mapFiltersToKql', () => { | |
]); | ||
}); | ||
|
||
test('should handle typesFilter, actionTypesFilter and ruleStatusesFilter', () => { | ||
test('should handle typesFilter, actionTypesFilter and ruleExecutionStatusesFilter', () => { | ||
expect( | ||
mapFiltersToKql({ | ||
typesFilter: ['type', 'filter'], | ||
actionTypesFilter: ['action', 'types', 'filter'], | ||
ruleStatusesFilter: ['alert', 'statuses', 'filter'], | ||
ruleExecutionStatusesFilter: ['alert', 'statuses', 'filter'], | ||
}) | ||
).toEqual([ | ||
'alert.attributes.alertTypeId:(type or filter)', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@JiaweiWu Out of curiosity I was wondering why the new ruleStatusesFilter is not included here. Is it because the options of the rule status filter is a static hardcoded list (
enabled
,disabled
,snoozed
)?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.
do we want to filter the aggregate results as well? I suppose we do, I can add it