Skip to content
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][Maintenance Window] Maintenance window scoped query frontend changes #171949

Merged
merged 20 commits into from
Dec 4, 2023

Conversation

JiaweiWu
Copy link
Contributor

@JiaweiWu JiaweiWu commented Nov 26, 2023

Summary

Partially resolves: #164255, this is 2/3 of the scoped query changes.

Maintenance window scoped query frontend changes. Adds the ability to add and edit scoped query for maintenance windows. Due to limitations with the alerts search bar and each solution fetches AAD fields, we only allow users to associate scoped query with 1 category (manangement, o11y, or security solution). The intended usage in this case is for the user to create multiple maintenance windows if they wish to apply scoped queries to multiple solutions.

To test:

go to x-pack/plugins/alerting/public/pages/maintenance_windows/constants.ts and set IS_SCOPED_QUERY_ENABLED to true

Scoped query off, multiple category allowed:

image

Scoped query on, multiple category disallowed:

image

Checklist

@JiaweiWu JiaweiWu added release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) Feature:Alerting/RulesManagement Issues related to the Rules Management UX v8.12.0 labels Nov 26, 2023
@JiaweiWu
Copy link
Contributor Author

@elasticmachine merge upstream

@JiaweiWu JiaweiWu marked this pull request as ready for review November 27, 2023 17:21
@JiaweiWu JiaweiWu requested a review from a team as a code owner November 27, 2023 17:21
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@JiaweiWu
Copy link
Contributor Author

@elasticmachine merge upstream

@@ -0,0 +1,3 @@
# @kbn/alerting-types
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to add some explanation for future user?

Comment on lines +62 to +85
const filteredIndex = data ? getFilteredIndex(data, filteredRuleTypes) : new Map();

const hasAnyAuthorizedRuleType = filteredIndex.size > 0;
const authorizedRuleTypes = [...filteredIndex.values()];
const authorizedToCreateAnyRules = authorizedRuleTypes.some(
(ruleType) => ruleType.authorizedConsumers[ALERTS_FEATURE_ID]?.all
);
const authorizedToReadAnyRules =
authorizedToCreateAnyRules ||
authorizedRuleTypes.some((ruleType) => ruleType.authorizedConsumers[ALERTS_FEATURE_ID]?.read);

return {
ruleTypesState: {
initialLoad: isLoading || isInitialLoading,
isLoading: isLoading || isFetching,
data: filteredIndex,
},
hasAnyAuthorizedRuleType,
authorizedRuleTypes,
authorizedToReadAnyRules,
authorizedToCreateAnyRules,
isSuccess,
};
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks to @cnasikas, I just learned that we can do all this in the select property.

image

DOC

Copy link
Contributor Author

@JiaweiWu JiaweiWu Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not going to make this change in this PR because #171417 is also touching this hook and now we have 2 copies of it and it'll be a big mess.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok but know we know how to do it.

);

const modal = useMemo(() => {
let m;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that jsx, we will not like to render an undefined value but it will be ok with null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

react is too smart

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it just got smarter!

Copy link
Contributor

@XavierM XavierM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To test this PR, I used #172117.

The different scenario that I created to test this PR are the follows:

  1. I created 4 different window maintenances under main with different categories and all of them, then upgraded to your PR. I was able to see my window maintenances set up as previously.
  2. I created two log threshold rules with different tags and create a window maintenance with scope query around one of my tag. I was able to confirm that we still send the recover notification when the alert was active outside of the window maintenance but after that we kept this rule muted. I was also able to confirm that the other rule in the same category was still notifying me.
  3. I tested that when we toggle the scope query then we keep in memory the query but we do not keep the history of our category. I thing we should fix that.
  4. In future PR, we should make sure to validate all the fields that we use in the query by querying the fields caps API to make sure that these fields belong to index associated to our category. That will help us to be closer to the versioning API requirements and also making sure user do not use something that we will never support.

@JiaweiWu, I think we should fix #3 and I will be all good to give the green light on this awesome feature. Well done!

@XavierM

This comment was marked as resolved.

@JiaweiWu

This comment was marked as resolved.

@XavierM

This comment was marked as abuse.

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
alerting 101 151 +50
observability 517 531 +14
securitySolution 4773 4787 +14
triggersActionsUi 623 640 +17
total +95

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/actions-types - 5 +5
@kbn/alerting-types - 29 +29
@kbn/alerts-ui-shared 10 82 +72
@kbn/triggers-actions-ui-types - 11 +11
alerting 783 791 +8
triggersActionsUi 558 559 +1
total +126

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
alerting 70.4KB 89.1KB +18.7KB
observability 1.1MB 1.1MB +152.0B
securitySolution 12.8MB 12.8MB +153.0B
total +19.0KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
triggersActionsUi 55 54 -1

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
alerting 23.3KB 23.5KB +180.0B
triggersActionsUi 104.1KB 104.2KB +148.0B
total +328.0B
Unknown metric groups

API count

id before after diff
@kbn/actions-types - 5 +5
@kbn/alerting-types - 29 +29
@kbn/alerts-ui-shared 11 83 +72
@kbn/triggers-actions-ui-types - 11 +11
alerting 814 822 +8
triggersActionsUi 584 585 +1
total +126

ESLint disabled line counts

id before after diff
@kbn/alerts-ui-shared 3 5 +2

Total ESLint disabled count

id before after diff
@kbn/alerts-ui-shared 3 5 +2

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@JiaweiWu JiaweiWu merged commit e4805fc into elastic:main Dec 4, 2023
33 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Alerting/RulesManagement Issues related to the Rules Management UX release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Maintenance Windows] Support "filtering" what Rules/Alerts Maintenance Windows affect
5 participants