Splunk Search

How to join two search using condition if ,case, or where?

Cs80
Loves-to-Learn Lots

Hi there,

I am new to splunk and  struggling to join two searches based on conditions .eg. left join  with field 1 from index2  if field1!=" " otherwise  left join with field 2 from index 2. Field 2 is only present in index 2.and Field 1 is common in 

I  have two spl  giving right result when executing separately . I don't know how to merge both spl based on above condition to get complete result.  Thanks

Labels (1)
0 Karma

Cs80
Loves-to-Learn Lots

I tried using coalesce but no luck.  I am trying to find all domains in our scope  using many different indexes  and multiple joins. I am currently using two separate searches and  both search queries are working fine when executing separately. I want to join both search queries to get complete result. I tried using coalesce with eval Domain in my search where some of  public IP are missing .I want to use Private_IP when Public_IP is not there. Then I plan to Join both queries based on Domain.

| eval Domain= coalesce( Public_IP, Private_IP)  . After using coalesce command  new field Domain showing up  empty space as in Public _IP. In other works new filed Domain is replicating Public_IP .  I also tried using if  with eval bit  no luck.

| eval Domain=if(isnull(Public_IP),Private_IP, Public_IP).

 

0 Karma

PickleRick
SplunkTrust
SplunkTrust

That would meant that you do not have a field named Private_IP in events which do not have Public_IP. Remember that with Splunk case in field names is important.

0 Karma

PickleRick
SplunkTrust
SplunkTrust

As an extension of what @richgalloway already wrote - in Splunk usually join is not the way to go. Try to describe what you have (it's best if you give some examples of the events you have) and what you want to achieve. We'll see what can be done 😉

0 Karma

richgalloway
SplunkTrust
SplunkTrust

There's no such thing as a "conditional join" in Splunk.  The join must always be on the same field(s).  Any conditions must be satisfied before the join is performed.

<<search 1>>
| eval joinField = field1
| join type=left joinField [
  <<search 2>>
  | eval joinField = coalesce(field1, field2)
  ]
---
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!

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Event Series: Level up your SOC: Advancing with Splunk Enterprise Security

AI has fundamentally raised the stakes for security operations, and this three-part series is your guide to ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...