Splunk Search

Join 2 fields with the same value in the same search.

LeandroKopke
Explorer

Hi.
I need help to be able to unify 2 fields that have the same value, however, in separate searches.
Here is an example:

Search 1:
source=* sourcetype=fortigate user=* action=tunnel-up reason="tunnel established"| table _time user group action remip reason tunnelip

Search 2:
source=* sourcetype=fortigate dstport=6443 action=close |table srcip, srcintf

The "srcip" and "remip" fields have the same values. I need both searches together, to be able to use the user field of the first search in the second search.

0 Karma

woodcock
Esteemed Legend

This does not make sense. Please explain what fields from what search are to be used to program details in what other search OR explain how data from both searches need to be merged together.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

If search 1 returns 10,000 or fewer results, try a subsearch. Don't forget to specify index(es) in the searches.

source=* sourcetype=fortigate dstport=6443 action=close 
  [ source= sourcetype=fortigate user=* action=tunnel-up reason="tunnel established" | fields user remip | rename remip as srcip | format ]
|table srcip, srcintf
---
If this reply helps you, Karma would be appreciated.
0 Karma

LeandroKopke
Explorer

hi richgalloway, thanks for you reply.
I did the execution of the command only, it doesn't return any results.
I've tried using append and join, but to no avail.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Keep in mind my answer is mostly a copy-and-paste of your example queries so any errors there are errors in mine as well.
Try running the subsearch (the part inside [] by itself. Once that is working correctly, add it to the main search.

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

LeandroKopke
Explorer

Separate, both queries return results.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

And when you paste the results of the subsearch onto the end of the main search, what do you get?

---
If this reply helps you, Karma would be appreciated.
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...

Network to App: Observability Unlocked [May & June Series]

In today’s digital landscape, your environment is no longer confined to the data center. It spans complex ...

SPL2 Deep Dives, AppDynamics Integrations, SAML Made Simple and Much More on Splunk ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...