Splunk Search

how to join two saved search results based on common field

kavyatim
Path Finder

Hi I have two saved searches lookup1 and lookup2 with line_id as common field ,
low will I join two results based on line_id.
Query I used is as follows:

| savedsearch "lookup2" | eval line_id=DDD.NUMERO_TERMINAL| eval FR=cd_enc
| eval str=substr(FR,2) |eval str1=substr(str,5)| eval str2=substr(str,1,len(str)-2)| eval str3=str2+str1 | table str3|rename str3 as ErrorCode | join line_id [| savedSearch "lookup1"] | table line_id,VendorID_FIELD4,ErrorCode.

Can correct my query to get results based on common line_id

Thanking,

Tags (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

I think you'll get better results by changing 'table str3|rename str3 as ErrorCode' to 'rename str3 as ErrorCode | fields ErrorCode, line_id'.

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

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

I think you'll get better results by changing 'table str3|rename str3 as ErrorCode' to 'rename str3 as ErrorCode | fields ErrorCode, line_id'.

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

somesoni2
SplunkTrust
SplunkTrust

Do you get any result with this ? [you should get results with two fields str3 and line_id]

| savedsearch "lookup2" | eval line_id=DDD.NUMERO_TERMINAL| eval FR=cd_enc | eval str=substr(FR,2) |eval str1=substr(str,5)| eval str2=substr(str,1,len(str)-2)| eval str3=str2+str1 | table str3, line_id|rename str3 as ErrorCode

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Getting no results could mean one of your saved searched is not finding any events or the join command is not finding common events. Verify each command in the pipeline is passing fields needed by subsequent commands.

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

kavyatim
Path Finder

Getting no results found. . What might be the problem?

0 Karma

somesoni2
SplunkTrust
SplunkTrust

Yes, Once your submitted your "|table str3", all other fields were removed from result. Try this.

| savedsearch "lookup2" | eval line_id=DDD.NUMERO_TERMINAL| eval FR=cd_enc | eval str=substr(FR,2) |eval str1=substr(str,5)| eval str2=substr(str,1,len(str)-2)| eval str3=str2+str1 | table str3, line_id|rename str3 as ErrorCode | join line_id [| savedSearch "lookup1"] | table line_id,VendorID_FIELD4,ErrorCode

Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...