Skip to content

[Cisco Secure Email Gateway] Fix wrong grok for mail_logs and add new field.#8573

Merged
efd6 merged 4 commits intoelastic:mainfrom
leandrojmp:fix_recipient_id_add_email_participants
Nov 30, 2023
Merged

[Cisco Secure Email Gateway] Fix wrong grok for mail_logs and add new field.#8573
efd6 merged 4 commits intoelastic:mainfrom
leandrojmp:fix_recipient_id_add_email_participants

Conversation

@leandrojmp
Copy link
Contributor

  • Enhancement

Proposed commit message

This PR fix an error on a grok pattern for the mail_logs ingest pipelines and creates a new field named cisco_secure_email_gateway.log.email_participants as keyword and with a multi-field as text.

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.

Related issues

fix wrong grok on mail_logs ingest pipelines and add new field
@leandrojmp leandrojmp requested a review from a team as a code owner November 24, 2023 19:29
@elasticmachine
Copy link

elasticmachine commented Nov 24, 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-11-30T06:19:21.937+0000

  • Duration: 17 min 15 sec

Test stats 🧪

Test Results
Failed 0
Passed 25
Skipped 0
Total 25

🤖 GitHub comments

Expand to view the GitHub comments

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

  • /test : Re-trigger the build.

Comment on lines 6 to 9
link: https://github.com/elastic/integrations/pull/XXXX
- description: Add new field cisco_secure_email_gateway.log.email_participants.
type: enhancement
link: https://github.com/elastic/integrations/pull/XXXX
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
link: https://github.com/elastic/integrations/pull/XXXX
- description: Add new field cisco_secure_email_gateway.log.email_participants.
type: enhancement
link: https://github.com/elastic/integrations/pull/XXXX
link: https://github.com/elastic/integrations/pull/8573
- description: Add new field cisco_secure_email_gateway.log.email_participants.
type: enhancement
link: https://github.com/elastic/integrations/pull/8573

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, sorry, I added the PR number, but forget to send the push to my branch.

- '^%{DATA:cisco_secure_email_gateway.log.message_status} %{WORD:network.protocol} DCID %{NUMBER:cisco_secure_email_gateway.log.delivery_connection_id} interface %{IP:cisco_secure_email_gateway.log.interface} address %{IP:cisco_secure_email_gateway.log.address}$'
- '^%{GREEDYDATA:cisco_secure_email_gateway.log.message_status} DCID %{NUMBER:cisco_secure_email_gateway.log.delivery_connection_id} MID %{NUMBER:email.message_id} to RID \[%{DATA:cisco_secure_email_gateway.log.recipient_id}\]$'
- '^%{GREEDYDATA:cisco_secure_email_gateway.log.message_status} DCID %{NUMBER:cisco_secure_email_gateway.log.delivery_connection_id} MID %{NUMBER:email.message_id} to RID \[%{DATA:cisco_secure_email_gateway.log.recipient_id}\]$'
- '^%{GREEDYDATA:cisco_secure_email_gateway.log.message_status} DCID %{NUMBER:cisco_secure_email_gateway.log.delivery_connection_id} MID %{NUMBER:email.message_id} to RID \[%{DATA:cisco_secure_email_gateway.log.recipient_id}\]\s\[%{DATA:cisco_secure_email_gateway.log.email_participants}\]$'
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider populating email.{from,reply_to,to}.address form this?

Copy link
Contributor Author

@leandrojmp leandrojmp Nov 27, 2023

Choose a reason for hiding this comment

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

Yeah, I'm still working on that and planned to do that on another PR.

The content that would go to the field email_participants can have multiple patterns, the order for from, reply-to and to can change, some of those may not be always present, you can have the emails between < and > sometimes, you also can have just the email or the name and the email, you can have multiple emais with a \r\n\t separator and a couple of more different patterns, so it is not a simple grok in this case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, fair enough. That sounds like it should be in a separate PR.

@efd6
Copy link
Contributor

efd6 commented Nov 27, 2023

/test

@leandrojmp
Copy link
Contributor Author

@efd6

It seems that the test failed because some issue related to the README.md file.

[2023-11-27T01:08:08.125Z] README.md is outdated. Rebuild the package with 'elastic-package build'
[2023-11-27T01:08:08.125Z] --- want
[2023-11-27T01:08:08.125Z] +++ got
[2023-11-27T01:08:08.125Z] @@ -400,2 +400,4 @@
[2023-11-27T01:08:08.125Z]  | cisco_secure_email_gateway.log.email |  | keyword |
[2023-11-27T01:08:08.125Z] +| cisco_secure_email_gateway.log.email_participants |  | keyword |
[2023-11-27T01:08:08.125Z] +| cisco_secure_email_gateway.log.email_participants.text | Multi-field of `cisco_secure_email_gateway.log.email_participants`. | text |
[2023-11-27T01:08:08.125Z]  | cisco_secure_email_gateway.log.email_tracker_header | Header consisting of (but not typically displaying) critical information for efficient email tracking and delivery. | keyword |
[2023-11-27T01:08:08.125Z] Error: checking package failed: checking readme files are up-to-date failed: files do not match

Since I'm adding a new field it seems that I also need to add it in the table in the README.md file.

Is that correct?

@efd6
Copy link
Contributor

efd6 commented Nov 27, 2023

If you run elastic-package build it will resolve this for you.

@leandrojmp
Copy link
Contributor Author

If you run elastic-package build it will resolve this for you.

Thanks! Just added a description on fields.yml and ran elastic-package build to update the README.md

@leandrojmp
Copy link
Contributor Author

Hello @efd6,

Can we try to run the tests again?

@efd6
Copy link
Contributor

efd6 commented Nov 28, 2023

/test

@elasticmachine
Copy link

elasticmachine commented Nov 28, 2023

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 100.0% (1/1) 💚
Files 84.615% (11/13) 👎 -15.385
Classes 84.615% (11/13) 👎 -15.385
Methods 89.831% (53/59) 👍 64.831
Lines 89.215% (761/853) 👎 -10.785
Conditionals 100.0% (0/0) 💚

Comment on lines 191 to 193
multi_fields:
- name: text
type: text
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the first multi_fields field in the set. Do we need this if the field will be further dissected into ECS fields in a future PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is useful because it enables you to search for a string and see if it was present as a participant on the e-mail, for example we had some use cases where we need to search if a particular email address appears as the sender or receiver, so without this we would need to search twice, one on the from field and another on the to field.

Also, all the email.*.address should have the e-mail address only, so if in the from field we have something like Sender Name <anythingelse@example.com>, we need to have just sender@example.com in the email.from.address, and this way we wouldn't be able to search for Sender Name as an email participant.

But, I can remove it and use an alternate custom field in my case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove it for now, but if you file a feature request we can look into adding it in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, removed the multi-field, I will just keep the mapping on my side because it is useful for our use case.

@efd6
Copy link
Contributor

efd6 commented Nov 30, 2023

/test

Copy link
Contributor

@efd6 efd6 left a comment

Choose a reason for hiding this comment

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

Thanks

@efd6 efd6 merged commit 86964ce into elastic:main Nov 30, 2023
@elasticmachine
Copy link

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

1 similar comment
@elasticmachine
Copy link

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

@leandrojmp leandrojmp deleted the fix_recipient_id_add_email_participants branch December 1, 2023 19:50
@andrewkroh andrewkroh added the Integration:cisco_secure_email_gateway Cisco Secure Email Gateway label Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Integration:cisco_secure_email_gateway Cisco Secure Email Gateway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Cisco Secure Email Gateway] Mail Logs Ingest Pipeline broken Grok

4 participants