Splunk Search

How to combine Fw: and Fwd in email Subjects

smurfy_91
New Member

Let's say I had used a search like:

index=mail RecipientUserDomain=user@domain.com | stats count by Subject | sort-count |

and returned results such as:

Subject

Fwd: This is a subject
Fw: This is a subject
Random Subject
Fwd: Another subject
Different Subject
Fw: Another Subject

What can I use to remove the "Fwd:" & "Fw:" from the Subject to combine the counts?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

There are a few ways to do that.

... | replace "Fw*: " with "" in Subject | stats ...

... | rex field=Subject mode=sed "s/Fwd?:\s(.*)/\1/" | stats ...

... | rex field=Subject "Fwd?: (?<Subject>.*)" | stats ...
---
If this reply helps you, Karma would be appreciated.
0 Karma

koshyk
Super Champion

Please have a try

index=mail RecipientUserDomain=user@domain.com | rex field=Subject "(Fw(.?)\:(\s+))?(?<mysubject>.+)" | stats count by mysubject | sort -count 

Example

|makeresults| eval Subject="Fwd: This is a subject||Fw: This is a subject||Random Subject||Fwd: Another Subject||Different Subject||Fw: Another Subject"| makemv delim="||" Subject | mvexpand Subject | rex field=Subject "(Fw(.?)\:(\s+))?(?<mysubject>.+)" | stats count by mysubject | sort -count

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

0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...