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
Get Updates on the Splunk Community!

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...