Splunk Search

How can I use the results from search 1 in search 2?

brandonpal
Explorer

Hi,

We are using VSFTP and I have two logs: xferlog and vsftp.log.

In my xferlog we have FTPUser & client and in vsftp.log I have client. Client = Client IP in both logs.

I need to run a search from my xferlog based on FTPUser to figure out IP's. I then need to run a search based on those IP addresses.

I'm trying to see if we are seeing errors in our vsftp.log when the user is trying to download files.

To get the IP I'm currently using this:

index=ftp FTPUser="test" sourcetype=vsftpd | stats values(client) by FTPUser

To then run a search based on that IP I'm using this:

index=ftp sourcetype=vsftpd_accessLog client="162.X.X.X"

Any help is greatly appreciated.

Tags (3)
1 Solution

somesoni2
Revered Legend

Try this

index=ftp sourcetype=vsftpd_accessLog [search index=ftp FTPUser="test" sourcetype=vsftpd | stats count by client | fields - count]

This should give you all vsftpd_accessLog entries for client (client IP) used by user test

View solution in original post

somesoni2
Revered Legend

Try this

index=ftp sourcetype=vsftpd_accessLog [search index=ftp FTPUser="test" sourcetype=vsftpd | stats count by client | fields - count]

This should give you all vsftpd_accessLog entries for client (client IP) used by user test

yannK
Splunk Employee
Splunk Employee

What about using the results of a sub search as a search condition for the main search.

see http://docs.splunk.com/Documentation/Splunk/6.1.3/Search/Usesubsearchtocorrelateevents

example:


index=ftp sourcetype=vsftpd_accessLog [ search index=ftp FTPUser="test" sourcetype=vsftpd | stats count by client | table client ]

The sub search return the list of "client" field, they will be converted to client=A OR client=B OR client=C etc....
Remark : the sub search are limited to 10000 lines of result, so only the first 10000 ips.

Get Updates on the Splunk Community!

.conf25 Community Recap

Hello Splunkers, And just like that, .conf25 is in the books! What an incredible few days — full of learning, ...

Splunk App Developers | .conf25 Recap & What’s Next

If you stopped by the Builder Bar at .conf25 this year, thank you! The retro tech beer garden vibes were ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...