Splunk Search

How to add columns from lookup table file to main search

mzn1979
Explorer

Hi everyone

I do a search in Splunk and this is the results

NamePriceDate
apple235689/18/2020
apple233469/18/2020
apple226979/18/2020
apple209/18/2020
apple226749/19/2020
apple259879/19/2020
apple267969/19/2020
apple253419/19/2020

 

I have a lookuptable file named apple.csv which is comprised of these contents.

NameDateMax_PriceMin_Price
apple9/18/20202425022120
apple9/19/20202692024250

 

So I want to add the Max_Price and Min_Price to the main search something like this

NamePriceDateMax_PriceMin_Price
apple235689/18/20202425022120
apple233469/18/20202425022120
apple226979/18/20202425022120
apple209/18/20202425022120
apple226749/19/20202692024250
apple259879/19/20202692024250
apple267969/19/20202692024250
apple253419/19/20202692024250

 

and then I can determine the wrong result. I mean the following result is not acceptable to me and they're may be wrong or something else.

apple209/18/2020
apple226749/19/2020

 

Thanks in advance

Labels (2)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @mzn1979,

you have to run something like this:

your_search
| lookup apple.csv Name Date OUTPUT Max_Price Min_Price
| Table Name Price Date Max_Price Min_Price

so you can list all the items adding the two columns from the lookup.

Then, if you want to check the Price with Max and Min, you have to add an eval statement:

| eval check=if(Price>Min_price AND Price<MaxPrice, "OK","NOK")

so you can filter the results:

| where check="NOK"

to have only the ones with Price outside the Min-Max range.

Ciao.

Giuseppe

View solution in original post

gcusello
SplunkTrust
SplunkTrust

Hi @mzn1979,

you have to run something like this:

your_search
| lookup apple.csv Name Date OUTPUT Max_Price Min_Price
| Table Name Price Date Max_Price Min_Price

so you can list all the items adding the two columns from the lookup.

Then, if you want to check the Price with Max and Min, you have to add an eval statement:

| eval check=if(Price>Min_price AND Price<MaxPrice, "OK","NOK")

so you can filter the results:

| where check="NOK"

to have only the ones with Price outside the Min-Max range.

Ciao.

Giuseppe

mzn1979
Explorer

Thank you. That worked perfectly

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @mzn1979,

good.

Ciao and happy splunking.

Giuseppe

P.S.: Karma Points are appreciated 😉

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...