Skip to content

Add fields connected to rules and alerts #355

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

Merged
merged 11 commits into from
Mar 28, 2023
Merged

Add fields connected to rules and alerts #355

merged 11 commits into from
Mar 28, 2023

Conversation

tomsonpl
Copy link
Contributor

Closes: https://github.com/elastic/security-team/issues/5929

Not sure if we need rule_name, but from what I remember, it was agreed that we wanted it.

@tomsonpl tomsonpl requested a review from pzl March 20, 2023 12:06
@tomsonpl tomsonpl requested a review from a team as a code owner March 20, 2023 12:06
@tomsonpl tomsonpl requested a review from dasansol92 March 20, 2023 12:06
@elasticmachine
Copy link
Contributor

elasticmachine commented Mar 20, 2023

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2023-03-28T07:58:29.773+0000

  • Duration: 8 min 42 sec

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

@tomsonpl
Copy link
Contributor Author

@pzl any idea if rule_name should be a keyword or just text ?

@pzl
Copy link
Member

pzl commented Mar 20, 2023

any idea if rule_name should be a keyword or just text ?

are we ever going to filter/search via name? I would imagine in filtering scenarios we probably know the rule_id and will be exact matching on that, right?

If for some reason we will filter on the name, do we know the full string to match (e.g. find rule by name "Unusual Network Activity")? then keyword. If we expect to filter on partial word matches (e.g. match the previous rule name based on the search string "network") then text could be ok.

If we don't need to filter by name, then I would set it to keyword, and index: false. Or just don't map it at all

@tomsonpl
Copy link
Contributor Author

@pzl @dasansol92 could you take a look please? Thank you!

@pzl pzl requested a review from ashokaditya March 22, 2023 15:46
Copy link
Member

@pzl pzl left a comment

Choose a reason for hiding this comment

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

looks okay, I think things are added in the right place. Added @ashokaditya to review the intent of whats being added

Copy link
Member

@ashokaditya ashokaditya left a comment

Choose a reason for hiding this comment

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

I added some suggestions to update the mappings. Let me know if you need help or have questions.

Comment on lines 79 to 93
- name: data.rule_id
type: alias
path: EndpointActions.data.rule_id
level: custom
short: EndpointActions.data.rule_id
description: >
ID of the rule that triggered the action

- name: data.rule_name
type: alias
path: EndpointActions.data.rule_name
level: custom
short: EndpointActions.data.rule_name
description: >
Name of the rule that triggered the action
Copy link
Member

@ashokaditya ashokaditya Mar 23, 2023

Choose a reason for hiding this comment

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

The rules fields should be updated to use ECS names. That would mean they don't stay under EndpointActions. They would be at the same level as agent and user which are ECS fields.

So the field definitions should not appear here.

EndpointActions is a grouping we created for storing fields that are not available in ECS. Consequently, you'd also need to update the custom_subsets/elastic_endpoint/actions/actions.yaml file to update the action doc mappings. That would end up looking like

...
...
user:
    fields:
      id: {}
rule:
    fields:
      id: {}
      name: {}

By the way, there's also a rule.uuid. Not sure if we want to use that instead of id

https://www.elastic.co/guide/en/ecs/current/ecs-rule.html

Comment on lines 55 to 61
- name: data.alert_ids
type: alias
path: EndpointActions.data.alert_ids
level: custom
short: EndpointActions.data.alert_ids
description: >
List of alert ids that triggered the action
Copy link
Member

Choose a reason for hiding this comment

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

This is good as alert_ids is a custom field.

Comment on lines 61 to 74
- name: data.rule_id
type: keyword
level: custom
short: rule id
description: >
ID of the rule that triggered the action

- name: data.rule_name
type: keyword
index: false
level: custom
short: rule name
description: >
Name of the rule that triggered the action
Copy link
Member

Choose a reason for hiding this comment

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

rule_id and rule_name should not be here as they are not custom fields as I mentioned earlier.

Comment on lines 39 to 44
- name: data.alert_ids
type: keyword
level: custom
short: alert ids
description: >
List of alert ids that triggered the action
Copy link
Member

@ashokaditya ashokaditya Mar 23, 2023

Choose a reason for hiding this comment

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

You would also need to edit the custom_subsets/elastic_endpoint/actions/actions.yaml file instead. If you want the fields to also exist on the response doc then you need to edit the custom_subsets/elastic_endpoint/action_responses/action_responses.yaml.

@@ -52,6 +52,14 @@
description: >
The action request information

- name: data.alert_ids
Copy link
Member

Choose a reason for hiding this comment

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

This should be named with a singular form, i.e. data.alert_id. https://www.elastic.co/guide/en/ecs/8.6/ecs-guidelines.html

@tomsonpl tomsonpl requested a review from ashokaditya March 27, 2023 14:30
Copy link
Member

@ashokaditya ashokaditya left a comment

Choose a reason for hiding this comment

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

Took another pass at reviewing. I have a question and suggestions.

Comment on lines 151 to 152
path: EndpointActions.data.alert_ids
short: EndpointActions.data.alert_ids
Copy link
Member

Choose a reason for hiding this comment

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

These lines also need updates. 😅

Comment on lines +26 to +29
rule:
fields:
id: {}
name: {}
Copy link
Member

Choose a reason for hiding this comment

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

Q: Do we need these fields also in the response index? If yes then we need to add this to the action_responses/action_responses.yml file too.

@tomsonpl tomsonpl requested a review from ashokaditya March 28, 2023 07:59
Comment on lines +39 to +44
- name: data.alert_id
type: keyword
level: custom
short: alert id
description: >
List of alert ids that triggered the action
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the changes. The fact that this is a keyword we can store an array of strings here s, so you can have multiple alert ids in the doc. Just that we should conform to ECS naming best practices.

@tomsonpl
Copy link
Contributor Author

@ashokaditya Thank you for your feedback and bearing with me fixing it so many times :P

@tomsonpl tomsonpl merged commit 8ad9c63 into main Mar 28, 2023
@elasticmachine
Copy link
Contributor

Package endpoint - 8.8.0 containing this change is available at https://epr.elastic.co/search?package=endpoint

@pzl pzl deleted the alert-fields branch August 14, 2023 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants