Splunk Search

How do I run a stats search to display a count and other fields by another field?

Makinde
New Member

How can I run the stats command to generate a count and display the count and other fields by another field. i.e

How do i get a display like;

Src_ip          dest_port       Count
10.1.34.5           25            3
                    30           67
10.64.34.8         443           34
                    80           25
                    56            9

I already have the search that generates the events with these fields, I just want to generate the display to look this way.

0 Karma
1 Solution

somesoni2
Revered Legend

Try something like this

your current search giving single value table with Src_ip dest_port and count | stats list(*) as * by Src_ip

View solution in original post

somesoni2
Revered Legend

Try something like this

your current search giving single value table with Src_ip dest_port and count | stats list(*) as * by Src_ip

Makinde
New Member

I guess i have to replace * with the fields I want right? How do I fill in the multiple fields because it's reporting an error also.

Using the * alone doesn't return any value.

0 Karma

somesoni2
Revered Legend

What is the search that you tried? The above one is assuming that you're already getting result in a table format with only the field Src_ip, dest_port, count. If that's not the case specify every field that you want to list, based on Src_ip.

...| stats list(dest_port) as dest_port list(count) as count by Src_ip
0 Karma

Makinde
New Member

This display in the question didn't come out as well as I wanted it in the question above.

It is a table with columns Src Ip, dest_port and count. There is only one src_IP address for multiple dest_ports and count. I hope this explanation helps to visualize it.

Thanks,

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...