Splunk Search

Grouping IP subnet and also show the IPs that it has grouped

anlePRH
Observer

I currently have this to group IPs into subnets and list the counts, I want it to also show the IP it has listed aswell

| rex field=SourceIP "(?<Subnet>\d+\.\d+\.\d+\.*)"

example

Subnet    Count   IPs

1.1.1       20            1.1.1.1, 1.1.1.2,1.1.1.3 

How do I create another field or use the existing field to show what it has grouped?

Labels (3)
Tags (2)
0 Karma

livehybrid
SplunkTrust
SplunkTrust

Hi @anlePRH 

Are you already producing the table you shared in your original post, or is that what you are wanting to get to?

You should be able to use the following after your REX:

| stats list(SourceIP) as IPs, count as Count by Subnet

🌟 Did this answer help you? If so, please consider:

  • Adding karma to show it was useful
  • Marking it as the solution if it resolved your issue
  • Commenting if you need any clarification

Your feedback encourages the volunteers in this community to continue contributing

0 Karma

PickleRick
SplunkTrust
SplunkTrust

In this case values(SourceIP) might be more desirable than list(SourceIP). The former will show unique values while the latter will show a list of fields, however many times they appear.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

It would be helpful to know what you've tried already and those efforts failed to meet expectations.

Perhaps this will help.

| rex field=SourceIP "(?<Subnet>\d+\.\d+\.\d+\.*)"
| stats count as Count, values(SourceIP) as IPs by Subnet
---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Unlock Database Monitoring with Splunk Observability Cloud

  In today’s fast-paced digital landscape, even minor database slowdowns can disrupt user experiences and ...

Purpose in Action: How Splunk Is Helping Power an Inclusive Future for All

At Cisco, purpose isn’t a tagline—it’s a commitment. Cisco’s FY25 Purpose Report outlines how the company is ...

[Upcoming Webinar] Demo Day: Transforming IT Operations with Splunk

Join us for a live Demo Day at the Cisco Store on January 21st 10:00am - 11:00am PST In the fast-paced world ...