Splunk Search

How to write a search to extract and only display email addresses from XML events?

hbcit
New Member

Each event found in my search, is always similar to the example below, but with a different email address found within the square brackets [email@myemaildomain].

    <EMAIL><![CDATA[email@myemaildomain]]></EMAIL>
    <BODY_TYPE>HTML</BODY_TYPE>
    <PERSONALIZATION>

I am trying to understand and find a way to extract just the email address from the many events. My goal is to create an hourly alert and have it email me a text file with just those email addresses. The email alert I can do, but I am struggling to get the filtering of just the email address in the event.

0 Karma

javiergn
Super Champion

Try the following:

| your search here
| spath input=yourinputfield
| table EMAIL

For example:

| stats count
| eval event = "<EMAIL><![CDATA[email@myemaildomain]]></EMAIL>
     <BODY_TYPE>HTML</BODY_TYPE>
     <PERSONALIZATION>"
| spath input=event
| table EMAIL

Output:

EMAIL
email@myemaildomain 
0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...