Splunk Search

How to count the number of recipients getting an email from a specific domain.

Mitchellsch
Explorer

I have my search currently showing a count of one email to each user when I send a test email. I want to be able to total the number of recipients greater than or equal to 5 and filter on that.

my search currently shows this with a stats count;

subject     src_user      recipient
blah          blah           1
blah          blah           1
blah          blah           1
blah          blah           1
blah          blah           1

I want it to show me me the src_user and a number of recipients total from that specific email. I hope this makes sense.
Thanks.

0 Karma
1 Solution

dcarmack_splunk
Splunk Employee
Splunk Employee
... | stats count by subject src_user | where count >= 5 | rename count AS recipients

View solution in original post

0 Karma

dcarmack_splunk
Splunk Employee
Splunk Employee
... | stats count by subject src_user | where count >= 5 | rename count AS recipients
0 Karma

Mitchellsch
Explorer

Thanks a ton. This works how I wanted.

0 Karma

javiergn
SplunkTrust
SplunkTrust

If you want to count by domain you need to extract the domain using regex and then count by that.

For instance (not tested in Splunk):

yoursearchhere | rex field=src_user "[\w][\w\-\.]+@(?<domain>\w[\w\-\.]+[a-zA-Z]{2,5})" | stats count by domain

Note there are better and more efficient regex patterns to match an email address, but the above is very easy to understand.
You can test you regex here: https://regex101.com/

Thanks,
J

jluo_splunk
Splunk Employee
Splunk Employee

You can use the count function to count events where the emails that have matching subject values, then use the where command to filter. For example:

.. | stats count by subject | where count>5

0 Karma
Get Updates on the Splunk Community!

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

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...