Splunk Search

how to join 2 lookup files to combine all the rows.

Anud
Path Finder

how to join 2 lookup files to combine all the rows.

 I used this query but not giving proper values and used join/append no use.
| inputlookup fileA
table A E F
|join 
[
inputlookup fileB.csv]
table E A B C
One file data looks:

AEF
234CAR2
456BUS3

Second file data:

ABC
234MON3
234TUES4
234WED5
234THUR1
234FRI2
234SAT1
456MON3
456TUES4
456WED5
456THUR1
456FRI2
456SAT1

Final output be like :

EABC
CAR234MON3
CAR234TUES4
CAR234WED5
CAR234THUR1
CAR234FRI2
CAR234SAT1
BUS456MON3
BUS456TUES4
BUS456WED5
BUS456THUR1
BUS456FRI2
BUS456SAT1


Thanks in Advance..!!

Labels (1)
0 Karma

FelixLeh
Contributor
| inputlookup fileB.csv
table A E F
|lookup fileA.csv A OUTPUT E
0 Karma

Anud
Path Finder

sorry i didnt get you 
this is the file flow

One fileA data looks:

AEF
234CAR2
456BUS3

 

Second fileB data:

ABC
234MON3
234TUES4
234WED5
234THUR1
234FRI2
234SAT1
456MON3
456TUES4
456WED5
456THUR1
456FRI2
456SAT1


Final output be like :

EABC
CAR234MON3
CAR234TUES4
CAR234WED5
CAR234THUR1
CAR234FRI2
CAR234SAT1
BUS456MON3
BUS456TUES4
BUS456WED5
BUS456THUR1
BUS456FRI2
BUS456SAT1
0 Karma

FelixLeh
Contributor

Yes.
1. You have to Load the Second lookup into your search.
You do so by loading the lookup file with the inputlookup command.

 

|inputlookup fileB.csv

 

2. A lookup that is inside splunk can be used to add data onto existing events or table data.
To do so you have to use the lookup command. You tell Splunk the name of the lookup, which field it shall use to add the data and which fields to add from the lookup

 

| lookup fileA.csv A OUTPUT E

 

Since field A are both in fileA and fileB you can use it to enrich your table with data from the other lookup. You tell splunk that you want to add data from fileA.csv and that the file that is present in both datasets is A then you tell Splunk to OUTPUT the field E to the current table.

This results in a query like in my previous answer. When the correct fieldnames and lookup file names are used this should lead to your desired output.

 

0 Karma

Anud
Path Finder

Thanks for the explanation..!!

This is not working.

| inputlookup fileB.csv
table A E F
|lookup fileA.csv A OUTPUT E


This is the actual result, but not getting the proper results.

Anud_1-1699464389445.png

 

0 Karma

bowesmana
SplunkTrust
SplunkTrust

@Anud Your search is NOT doing what @FelixLeh suggested.

The idea is that you load the SECOND lookup (fileB) first and then lookup the common field A to get the required field E from the FIRST lookup.

Your example shows that fileB contains the data and fileA contains the missing field E (CAR/BUS) that is needed to enrich fileB data.

Note that your actual search uses append with a subsearch - you should not do it that way, as inputlookup already has an append option and this method does not have the limitations of a subsearch, i.e.

| inputlookup append=t file

 

0 Karma

FelixLeh
Contributor

@bowesmana  am I misunderstanding what @Anud wants to achieve? For me it sounded like a simple lookup combined with a inputlookup.

0 Karma

bowesmana
SplunkTrust
SplunkTrust

@FelixLeh no - you are absolutely right and your suggestion looks fine, but @Anud was using append and a subsearch with inputlookup and not what you suggested...

0 Karma
Get Updates on the Splunk Community!

CX Day is Coming!

Customer Experience (CX) Day is on October 7th!! We're so excited to bring back another day full of wonderful ...

Strengthen Your Future: A Look Back at Splunk 10 Innovations and .conf25 Highlights!

The Big One: Splunk 10 is Here!  The moment many of you have been waiting for has arrived! We are thrilled to ...

Now Offering the AI Assistant Usage Dashboard in Cloud Monitoring Console

Today, we’re excited to announce the release of a brand new AI assistant usage dashboard in Cloud Monitoring ...