Knowledge Management

Extracting email address from raw events with different formats

Will_powr
Explorer

Good Day Splunkers! I've been banging me my trying to capture all email address as recipients. Is this even possible? 

 

"status":"delivered":"recipient":"some.name@mail.com":"subject":"Thank you!":"

 

"status":"delivered":"recipient":"some.middle.name@mail.com":"subject":"Thank you!":"

 

"status":"delivered":"recipient":"\"Name Some \"<some.name@mail.com>":"subject":"Thank you!":"

 

"status":"delivered":"recipient":"some.name@mail.com,  another.name@mail.com,  more.names@mail.com subject":"Thank you!":"

 

"recipient":"\"different.name@mail.com\" <different.name@mail.com>, \"same.name@mail.com\"<same.name@mail.com>":"subject":"Thank you!":"

 

Labels (1)

gcusello
SplunkTrust
SplunkTrust

Hi @Will_powr,

having you so different formats, you could try using this regex

| rex "(?<mail>(\w+\.)*\w+@\w+\.\w+)"

that probably extract too many values.

Otherwise, you could use more regexes for each format:

| rex "\"(?<mail>(\w+\.)*\w+@\w+\.\w+)"
| rex "\<(?<mail>(\w+\.)*\w+@\w+\.\w+)\>"

that you can test at

https://regex101.com/r/fP9DAo/1

Ciao.

Giuseppe

inventsekar
SplunkTrust
SplunkTrust

Hi @Will_powr ... may we know, if you are trying to do this with SPL Rex search query

or

while log ingestion itself you would like to extract the email address, please suggest, thanks. 

thanks and best regards,
Sekar

PS - If this or any post helped you in any way, pls consider upvoting, thanks for reading !
Tags (1)
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...