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
SplunkTrust
SplunkTrust

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!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...