Archive

how to join two saved search results based on common field

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

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, an upvote would be appreciated.

View solution in original post

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, an upvote would be appreciated.

View solution in original post

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

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, an upvote would be appreciated.
0 Karma

Path Finder

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

0 Karma

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

State of Splunk Careers

Access the Splunk Careers Report to see real data that shows how Splunk mastery increases your value and job satisfaction.

Find out what your skills are worth!