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!

Index This | Why did the turkey cross the road?

November 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...