Splunk Search

Get totals of sessions for each IP

gryfon
New Member

Hello, everyone.
I have a series of logs that have, among other data, the source address from which they come (src_ip) and the session of which they are part (session). How do I get a table showing the total number of unique sessions in which each source IP address is involved?

0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Have you tried ... | stats dc(session) by src_ip ?

---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Have you tried ... | stats dc(session) by src_ip ?

---
If this reply helps you, Karma would be appreciated.
0 Karma

gryfon
New Member

Thanks richgalloway.

The correct query is: "| table src_ip, session | stats dc(session) by src_ip"

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Are you saying this is your current query? If so, what results do you get?

---
If this reply helps you, Karma would be appreciated.
0 Karma

gryfon
New Member

Yes. I get the table with the src_ip and the corresponding numbers of unique sessions involved to each IP.

0 Karma

niketn
Legend

@gryfon there is no need to add table command which is transforming (non-streaming) command and brings all the data to search head for further processing. So if you have clustered environment with multiple indexers you will not leverage the search performance improvement through parallelization (map) and subsequently no advantage of map-reduce in stats command which merely works on the result of table command in your case. If your index has too many fields, you can try fields (streaming command) instead of table or directly stats after your main query.

Refer to documentation: https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Table#Command_type

And also read about search optimization and parallel reduce documentation.

PS: I have converted @richgalloway 's comment to answer. Please accept the answer if your issue is resolved.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

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