Splunk Search

Group results by common value

dcarriger
Engager

Alright. My current query looks something like this:

sourcetype=email action=accept ip=127.0.0.1 | stats count(subject), dc(recipients) by ip, subject

And this produces output like the following:

ip subject count dc(recipients)

127.0.0.1 email1 10 10

127.0.0.1 email2 5 2

127.0.0.1 email3 1 1

How would I query this instead so I can group those results together by IP so I'd be looking at a format like this?

ip subject count dc(recipients)

127.0.0.1 email1 10 10

email2 5 2

email3 1 1

I haven't figured out a query yet that will let me group by IP while still getting a count for each subject value, and a distinct count for the number of recipients for each subject value.

Tags (1)
0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

Try this,

sourcetype=email action=accept ip=127.0.0.1 | stats count(subject) as count, dc(recipients) as recipients by ip, subject | stats list(subject) as subject , list(count) as count, list(recipients) as recipients by ip

View solution in original post

somesoni2
SplunkTrust
SplunkTrust

Try this,

sourcetype=email action=accept ip=127.0.0.1 | stats count(subject) as count, dc(recipients) as recipients by ip, subject | stats list(subject) as subject , list(count) as count, list(recipients) as recipients by ip

bbsoc1
Engager

Beautiful solution. Thanks for providing. Found this independently 2 yrs after you posted it.

0 Karma

dcarriger
Engager

Awesome! This does exactly what I need it to. Thanks!

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