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] Mark disabled alerts as Untracked in both Stack and o11y #164788

Merged
merged 62 commits into from
Sep 27, 2023

Conversation

Zacqary
Copy link
Contributor

@Zacqary Zacqary commented Aug 24, 2023

Summary

Part of #164059

Implements the Untracked lifecycle status, and applies it to alerts when their corresponding rule is disabled.

Screenshot 2023-08-24 at 4 24 45 PM Screenshot 2023-08-24 at 4 56 32 PM Screenshot 2023-08-24 at 4 56 17 PM

Checklist

@Zacqary Zacqary added release_note:enhancement Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) Feature:Alerting/RulesManagement Issues related to the Rules Management UX Team: Actionable Observability - DEPRECATED For Observability Alerting and SLOs use "Team:obs-ux-management", for AIops "Team:obs-knowledge" v8.11.0 labels Aug 24, 2023
@apmmachine
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • /oblt-deploy-serverless : Deploy a serverless Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@Zacqary Zacqary marked this pull request as ready for review August 28, 2023 17:04
@Zacqary Zacqary requested review from a team as code owners August 28, 2023 17:04
@elasticmachine
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

Pinging @elastic/actionable-observability (Team: Actionable Observability)

…sabled-alerts

# Conflicts:
#	x-pack/plugins/alerting/server/rule_type_registry.test.ts
#	x-pack/plugins/alerting/server/rule_type_registry.ts
@Zacqary Zacqary requested a review from a team as a code owner September 26, 2023 15:37
@Zacqary Zacqary enabled auto-merge (squash) September 26, 2023 16:10
@@ -151,7 +151,7 @@ export default function createDisableRuleTests({ getService }: FtrProviderContex
savedObjects: [
{ type: 'alert', id: ruleId, rel: 'primary', type_id: 'test.cumulative-firing' },
],
message: "instance 'instance-0' has recovered due to the rule was disabled",
message: "instance 'instance-0' has been untracked because the rule was disabled",
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to update this functional test (or add a new FT) that creates a rule with alerts, disables it and checks that the alert is marked as untracked and then re-enables it and sees a new alert doc created.

Copy link
Contributor

@ymao1 ymao1 left a comment

Choose a reason for hiding this comment

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

LGTM! Verified alerts are marked as untracked when rule is disabled and new alerts are created when alert is re-enabled. Left one question about a change to a detection rule test. Also left a comment about a FT but that can be added as a followup.

@Zacqary Zacqary removed the request for review from a team September 26, 2023 19:05
Copy link
Contributor

@yctercero yctercero left a comment

Choose a reason for hiding this comment

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

Pulled down and just checked all good in security alerts page - LGTM.

@kibana-ci
Copy link
Collaborator

kibana-ci commented Sep 27, 2023

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #49 / saved objects security and spaces enabled _bulk_create dual-privileges readonly user within the default space "before all" hook for "should return 403 forbidden [isolatedtype/defaultspace-isolatedtype-id]"

Metrics [docs]

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/rule-data-utils 107 108 +1
alerting 741 742 +1
triggersActionsUi 551 552 +1
total +3

Async chunks

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

id before after diff
infra 2.0MB 2.0MB +306.0B
observability 1.0MB 1.0MB +395.0B
securitySolution 12.8MB 12.8MB +322.0B
stackConnectors 467.0KB 467.1KB +116.0B
triggersActionsUi 1.4MB 1.4MB +56.0B
total +1.2KB

Page load bundle

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

id before after diff
infra 105.3KB 105.3KB +51.0B
observability 100.2KB 100.5KB +254.0B
triggersActionsUi 92.0KB 92.2KB +243.0B
total +548.0B
Unknown metric groups

API count

id before after diff
@kbn/rule-data-utils 110 111 +1
alerting 772 773 +1
triggersActionsUi 577 578 +1
total +3

History

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

@Ikuni17 Ikuni17 disabled auto-merge September 27, 2023 22:27
@Ikuni17 Ikuni17 merged commit 107239c into elastic:main Sep 27, 2023
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Sep 27, 2023
XavierM added a commit that referenced this pull request Oct 4, 2023
## Summary

Part of #164059

<img width="301" alt="Screenshot 2023-09-28 at 5 38 45 PM"
src="https://github.com/elastic/kibana/assets/1445834/1b9ae224-7dad-43d7-a930-adf9458e1613">
<img width="486" alt="Screenshot 2023-09-28 at 5 38 11 PM"
src="https://github.com/elastic/kibana/assets/1445834/82eeec3d-af2c-4257-b78e-99aea5a6b66f">

This PR:

- Moves the `setAlertStatusToUntracked` function from the `AlertsClient`
into the `AlertsService`. This function doesn't actually need any Rule
IDs to do what it's supposed to do, only indices and Alert UUIDs.
Therefore, we want to make it possible to use outside of a created
`AlertsClient`, which requires a Rule to initialize.
- Creates a versioned internal API to bulk untrack a given set of
`alertUuids` present on `indices`. Both of these pieces of information
are readily available from the ECS fields sent to the alert table
component, from where this bulk action will be called.
- Switches the `setAlertStatusToUntracked` query to look for alert UUIDs
instead of alert instance IDs.
#164788 dealt with untracking
alerts that were bound to a single rule at a time, but this PR could be
untracking alerts generated by many different rules at once. Multiple
rules may generate the same alert instance ID names with different
UUIDs, so using UUID increases the specificity and prevents us from
untracking alert instances that the user didn't intend.
- Adds a `bulkUpdateState` method to the task scheduler.
#164788 modified the `bulkDisable`
method to clear untracked alerts from task states, but this new method
allows us to untrack a given set of alert instances without disabling
the task that generated them.

#### Why omit rule ID from this API?

The rule ID is technically readily available from the alert table, but
it becomes redundant when we already have immediate access to the alert
document's index. #164788 used the
rule ID to get the `ruleTypeId` and turn this into a corresponding
index, which we don't have to do anymore.

Furthermore, it helps to omit the rule ID from the `updateByQuery`
request, because the user can easily select alerts that were generated
by a wide variety of different rules, and untrack them all at once. We
could include the rule ID in a separate `should` query, but this adds
needless complexity to the query.

We do need to know the rule ID after performing `updateByQuery`, because
it corresponds to the task state we want to modify, but it's easier to
retrieve this using the same query params provided.

### Checklist

Delete any items that are not applicable to this PR.

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Jiawei Wu <jiawei.wu@cmd.com>
Co-authored-by: Xavier Mouligneau <xavier.mouligneau@elastic.co>
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:enhancement Team: Actionable Observability - DEPRECATED For Observability Alerting and SLOs use "Team:obs-ux-management", for AIops "Team:obs-knowledge" Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.