All Apps and Add-ons

inputlookup usage to fetch fields having another name in data

ksharma7
Path Finder

I have a query like :

index=rxc sourcetype=rxcapp splunk_server_group="" status=2 [| inputlookup quote.csv | fields name | rename name as questname]

I have a data which has field named questname which has all values that are there in name column of my csv and some other values too ....I want to use the same csv without manipulating it but want data in my query specific to name present in cvs and not for all questname and then work on it how to do that .

the above does not seems to be working

0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @ksharma7,
At first I always put the fields command at the end of the subsearch:

index=rxc sourcetype=rxcapp splunk_server_group="" status=2 [ | inputlookup quote.csv | rename name as questname | fields questname  ]

but it souldn't be the solution to you problem.

One question: data in index rxc and in the quote.csv lookup are exactly the same or a part of them, in othe words, do you have e.g. "server_one" in both or "server_one" in the first and "server" in the second?
if the first case, the search is correct, otherwise, you have to use "*" or the ful text search:

index=rxc sourcetype=rxcapp splunk_server_group="" status=2 [ | inputlookup quote.csv | rename name as query| fields query ]

Ciao.
Giuseppe

View solution in original post

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @ksharma7,
At first I always put the fields command at the end of the subsearch:

index=rxc sourcetype=rxcapp splunk_server_group="" status=2 [ | inputlookup quote.csv | rename name as questname | fields questname  ]

but it souldn't be the solution to you problem.

One question: data in index rxc and in the quote.csv lookup are exactly the same or a part of them, in othe words, do you have e.g. "server_one" in both or "server_one" in the first and "server" in the second?
if the first case, the search is correct, otherwise, you have to use "*" or the ful text search:

index=rxc sourcetype=rxcapp splunk_server_group="" status=2 [ | inputlookup quote.csv | rename name as query| fields query ]

Ciao.
Giuseppe

0 Karma

ksharma7
Path Finder

Hi @gcusello

actually lookup has only some fields which are important to us like
name id part branch

I just to to look for those name in my query which are there in my lookup

also in my index=rxc sourcetype=rxcapp the field has name questname which has similar values to the "name" in my csv. so what should be right approach
or can I just use |lookup quote.csv name as questname|

and the look or do stats whatever I want to do with questname

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @ksharma7,
the use of lookup or inputlookup command depends on your requirement: if you need to search for the values of lookup, you have to use inputllokup, if you want to add lookup informations to the search, you use lookup.
For what I understood, you have to filter your search results for the names in the lookup, in this case the solution is:

index=rxc sourcetype=rxcapp splunk_server_group="" status=2 [ | inputlookup quote.csv | rename name as questname | fields questname  ]

but, as I said, the question is: names in lookup fully match questnames or not?

Having a different name in lookup isn't a problem because you can use the rename; even if, when possible, I try to give to the lookup fields the same name of the fields search .

Ciao.
Giuseppe

0 Karma

ksharma7
Path Finder

I think I got it..mistake was using fields before ...using it afterwards is working .thanks

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...