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
Revered Legend

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
Revered Legend

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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

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