Splunk Search

Parse Email Subject and populate fields

jc_najera15
Engager

Hi Splunkers!

Im running a very simple query to get the subject of all the emails we are getting. Something like this:


index=o365_email_data
|table Subject

Results look like this:

Subject
Ticket ID: INC3333333 - Prio: 1 - High- "Description of the Incident" - has been updated
Ticket ID: INC1111111 - Prio: 4 - Low- "Description of the Incident" - has been resolved
Ticket ID: INC2222222 - Prio: 3 - Normal - "Description of the Incident" - has been created


What I would like to accomplish is to be able to parse certain parts of that Subject and fill a table like this:

TicketPriorityDescriptionStatus
INC3333333 HighDescription of the Incidentupdated
INC1111111 LowDescription of the Incidentresolved
INC2222222 NormalDescription of the Incidentcreated

 

This resembles a lot like the "Text to Column" function in Excel. Im completely lost on how I can achieve this.

Many thanks!

Labels (3)
0 Karma
1 Solution

s2_splunk
Splunk Employee
Splunk Employee

The rex command is your friend to do this in search:

Screen Shot 2021-04-26 at 6.37.56 PM.png

Here is the run anywhere search for the sample event above:

|  makeresults 
|  eval subject="Ticket ID: INC3333333 - Prio: 1 - High- Description of the Incident - has been updated" 
| rex field=subject "Ticket ID:\s(?<Ticket>\w+) - Prio: \d - (?<Priority>\w+)-\s(?<Description>[\w\s]+)- has been (?<Status>\w+)" 
|  table Ticket, Priority, Description, Status

 

You can also add these field extractions to your sourcetype, so the fields get parsed out automatically whenever you search. 

HTH, Happy Splunking!

View solution in original post

s2_splunk
Splunk Employee
Splunk Employee

The rex command is your friend to do this in search:

Screen Shot 2021-04-26 at 6.37.56 PM.png

Here is the run anywhere search for the sample event above:

|  makeresults 
|  eval subject="Ticket ID: INC3333333 - Prio: 1 - High- Description of the Incident - has been updated" 
| rex field=subject "Ticket ID:\s(?<Ticket>\w+) - Prio: \d - (?<Priority>\w+)-\s(?<Description>[\w\s]+)- has been (?<Status>\w+)" 
|  table Ticket, Priority, Description, Status

 

You can also add these field extractions to your sourcetype, so the fields get parsed out automatically whenever you search. 

HTH, Happy Splunking!

jc_najera15
Engager

I just had an AHA moment, thanks so much for showing me how to do this 🙂

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...