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!

Continuing Innovation & New Integrations Unlock Full Stack Observability For Your ...

You’ve probably heard the latest about AppDynamics joining the Splunk Observability portfolio, deepening our ...

Monitoring Amazon Elastic Kubernetes Service (EKS)

As we’ve seen, integrating Kubernetes environments with Splunk Observability Cloud is a quick and easy way to ...

Cloud Platform & Enterprise: Classic Dashboard Export Feature Deprecation

As of Splunk Cloud Platform 9.3.2408 and Splunk Enterprise 9.4, classic dashboard export features are now ...