Skip to content

[Security Solution] Enables telemetry for endpoint rules#120225

Merged
madirey merged 10 commits intoelastic:mainfrom
madirey:rac-events-telemetry
Dec 17, 2021
Merged

[Security Solution] Enables telemetry for endpoint rules#120225
madirey merged 10 commits intoelastic:mainfrom
madirey:rac-events-telemetry

Conversation

@madirey
Copy link
Contributor

@madirey madirey commented Dec 2, 2021

Summary

This PR passes the eventsTelemetry object through to the siem.queryRule and siem.indicatorRule rule type executors. This enables those rules to queue telemetry data when alerts are created. The data includes the _source of each alert that is written.

Additionally, the unit tests for createQueryAlertType have been fixed and a test was added to ensure that alerts are queued for telemetry appropriately. This is adequate to test telemetry for all rule types for which it is enabled, since the telemetry is queued from a common codepath in searchAfterAndBulkCreate (just after calling bulkCreate to create the alerts).

Finally, unit tests for all other rule types have been removed. For those tests, the executors were exiting early due to thrown exceptions when missing mocks were encountered. The tests are fragile, since they rely on internals of the executors to function, and they were producing passing results even though the executors were not running to completion. The tests were therefore misleading, as the test conditions were met without actually testing those conditions.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@madirey madirey added v8.0.0 release_note:skip Skip the PR/issue when compiling release notes auto-backport Deprecated - use backport:version if exact versions are needed v8.1.0 labels Dec 2, 2021
@madirey madirey requested a review from a team as a code owner December 2, 2021 14:49
@madirey madirey added Feature:Detection Alerts Security Solution Detection Alerts Feature Feature:RAC label obsolete Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Detection Alerts Security Detection Alerts Area Team Team:Detections and Resp Security Detection Response Team Theme: rac label obsolete labels Dec 3, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

@elasticmachine
Copy link
Contributor

Pinging @elastic/security-detections-response (Team:Detections and Resp)

@madirey
Copy link
Contributor Author

madirey commented Dec 3, 2021

@stevewritescode @pjhampton @marshallmain This re-enables telemetry for query and threat match rules. As discussed, some code on the receiving end may need to be updated to handle the new alertTypeIds outlined here. Let me know if you have any questions or concerns!

Did we want to enable telemetry for any other rule types? It looked like these were the only ones we had enabled in the past.

@madirey madirey requested review from marshallmain and rylnd December 3, 2021 15:41
@madirey
Copy link
Contributor Author

madirey commented Dec 3, 2021

jenkins test this

@madirey
Copy link
Contributor Author

madirey commented Dec 3, 2021

@elasticmachine merge upstream

1 similar comment
@madirey
Copy link
Contributor Author

madirey commented Dec 6, 2021

@elasticmachine merge upstream

Copy link
Contributor

@marshallmain marshallmain left a comment

Choose a reason for hiding this comment

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

Detection engine code changes LGTM

@stevewritescode @pjhampton what's the process for testing telemetry end-to-end?

Copy link
Contributor

@pjhampton pjhampton left a comment

Choose a reason for hiding this comment

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

If I'm understanding the scope of this PR correctly is that you have enabled detection rule alert telemetry on query + threat match rules. I think that is great! it doesn't resolve the telemetry issue described here with the usage collector: #119047. What you have done is on the roadmap fwiw.

One concern I have with this approach is that it is going to go into the data stream where endpoint alerts go in the security analytic cluster. The buffer we have only holds 100 items or 10MB a minute. Could these detection rule alerts create so many alerts that it drowns out the endpoint telemetry?

@rylnd
Copy link
Contributor

rylnd commented Dec 7, 2021

it doesn't resolve the telemetry issue described here with the usage collector: #119047.

@pjhampton there's not detail as to what's broken in the linked issue, and I mistakenly conflated that issue with this one. Would you be able to write up a ticket describing what's broken with the existing usage collectors? Or I'd be happy to do so if you can provide details. Thanks!

edit: It looks like @FrankHassanabad is working on fixing the outdated queries used by the usage collectors 👍

@rylnd
Copy link
Contributor

rylnd commented Dec 7, 2021

One concern I have with this approach is that it is going to go into the data stream where endpoint alerts go in the security analytic cluster. The buffer we have only holds 100 items or 10MB a minute. Could these detection rule alerts create so many alerts that it drowns out the endpoint telemetry?

This sounds like a valid concern for a probable situation; do you have a recommendation for how to proceed? We could write to a new data stream, or disable this functionality until your cluster is ready, or both?

@madirey madirey marked this pull request as draft December 13, 2021 17:48
@madirey
Copy link
Contributor Author

madirey commented Dec 13, 2021

@elasticmachine merge upstream

@pjhampton
Copy link
Contributor

It is possible this is broken on second look, based on https://github.com/elastic/kibana/blob/main/x-pack/plugins/security_solution/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security.json being of type 'query'. It's possible the 8.0 telemetry documents are from old clusters and test data. Please hold fire while I investigate.

@madirey madirey changed the title [Security Solution] Enables telemetry for query and threat match rules [Security Solution] Enables telemetry for endpoint rules Dec 16, 2021
@madirey madirey marked this pull request as ready for review December 16, 2021 22:42
@madirey
Copy link
Contributor Author

madirey commented Dec 16, 2021

@elasticmachine merge upstream

@kibana-ci
Copy link

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

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

@madirey madirey merged commit 47a5d97 into elastic:main Dec 17, 2021
@madirey madirey deleted the rac-events-telemetry branch December 17, 2021 18:57
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Dec 21, 2021
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 120225 or prevent reminders by adding the backport:skip label.

9 similar comments
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 120225 or prevent reminders by adding the backport:skip label.

@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 120225 or prevent reminders by adding the backport:skip label.

@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 120225 or prevent reminders by adding the backport:skip label.

@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 120225 or prevent reminders by adding the backport:skip label.

@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 120225 or prevent reminders by adding the backport:skip label.

@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 120225 or prevent reminders by adding the backport:skip label.

@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 120225 or prevent reminders by adding the backport:skip label.

@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 120225 or prevent reminders by adding the backport:skip label.

@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 120225 or prevent reminders by adding the backport:skip label.

@pjhampton pjhampton added auto-backport Deprecated - use backport:version if exact versions are needed and removed auto-backport Deprecated - use backport:version if exact versions are needed labels Jan 4, 2022
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Jan 4, 2022
)

* Add eventsTelemetry to query and threatMatch executors

* Temp commit

* Add query rule telemetry test

* How'd that get in there?

* Remove useless tests

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
8.0

This backport PR will be merged automatically after passing CI.

@pjhampton pjhampton removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Jan 4, 2022
kibanamachine added a commit that referenced this pull request Jan 4, 2022
…122254)

* Add eventsTelemetry to query and threatMatch executors

* Temp commit

* Add query rule telemetry test

* How'd that get in there?

* Remove useless tests

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Madison Caldwell <madison.rey.caldwell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Deprecated - use backport:version if exact versions are needed Feature:Detection Alerts Security Solution Detection Alerts Feature Feature:RAC label obsolete release_note:skip Skip the PR/issue when compiling release notes Team:Detection Alerts Security Detection Alerts Area Team Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Theme: rac label obsolete v8.0.0 v8.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants