Splunk Search

Use subsearch to gather ip addresses for use in another type off search?

einars
Engager

Playing around to find a way to gather IP-Addresses from one type of search, to gather other type of information about the ip-addresses.

In this example I try to gather all ip-addresses that is in the source type threat log, this source type does not contain session_end_reason, that is in the traffic log. So, I try to fetch all ip addresses that accsess *sonos.com* and use this to get all session_end_reason for those ip addresses. Mayby it’s not possible, and it’s a proof of concept i try achieving here.

index="paloalto" src_ip="*" src_ip="*"
[search index="paloalto" url="*sonos.com*" src_ip="*"]
| table url src_ip session_end_reason

The result from this gives blank session_end_reason

If I have this in my first search:

index="paloalto" src_ip="*" src_ip="*" session_end_reason="*"

All ends up blank.

This at the end:

| table src_ip session_end_reason

Ends up with only ip addresses, and no session_end_reason

Is this possible?

Best regards

 

Labels (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

When testing query that contains a subsearch, start with the subsearch by itself.  Remember that the results of the subsearch will become part of the main search.  That means every field returned by the subsearch will be searched for by the main search.  If the main search only needs one field from the subsearch then be sure to include a fields command in the subsearch to return only that one field.

index="paloalto" 
[search index="paloalto" url="*sonos.com*" src_ip="*" | fields src_ip | format ]
| table url src_ip session_end_reason
---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

When testing query that contains a subsearch, start with the subsearch by itself.  Remember that the results of the subsearch will become part of the main search.  That means every field returned by the subsearch will be searched for by the main search.  If the main search only needs one field from the subsearch then be sure to include a fields command in the subsearch to return only that one field.

index="paloalto" 
[search index="paloalto" url="*sonos.com*" src_ip="*" | fields src_ip | format ]
| table url src_ip session_end_reason
---
If this reply helps you, Karma would be appreciated.

einars
Engager

Perfect, works like I want it to do:

index="paloalto"  [search index="paloalto" "*sonos.com*" src_ip="*" 
| fields src_ip | format ]  
| stats count by src_ip session_end_reason 
| sort by src_ip

@richgalloway 

thanks a lot, spent a good amount of time digging. Really good explanation you provided.

0 Karma
Get Updates on the Splunk Community!

Observability Unlocked: Kubernetes Monitoring with Splunk Observability Cloud

 Ready to master Kubernetes and cloud monitoring like the pros? Join Splunk’s Growth Engineering team for an ...

Update Your SOAR Apps for Python 3.13: What Community Developers Need to Know

To Community SOAR App Developers - we're reaching out with an important update regarding Python 3.9's ...

October Community Champions: A Shoutout to Our Contributors!

As October comes to a close, we want to take a moment to celebrate the people who make the Splunk Community ...