Getting Data In

How to use inputlookup with csv file to import two multi value fields in a search?

C_Sparn
Communicator

Hello,
I try to use inputlookup with a csv file to import two multi value fields in a search.
The two fields are both filled with numbers seperated with "," like 0012345678101112,5.
The field names are tickets and days.
Now I try to compare another field(Tickets)with the tickets field.
The problem is now that when I compare the 2 fields there are no accordances. I also tried to convert the fields to String and to Numbers but that didn't help either.

The code looks like this:

mainsearch...
|append[|inputlookup input.csv]
|eval tickets = toNumber(tickets)
|where Tickets == tickets
|stats dc(Tickets)

Tickets is typeof Number so it should work.
Where is the error?
Greetings

1 Solution

strive
Influencer

I tried this and it worked.

I created test1.csv with two columns Ticket and Days

Base Search | stats count as Count by TicketCode | appendcols [|inputlookup test1.csv] | where TicketCode == Ticket | stats dc(TicketCode)

The above works when the field values are in same order.

You may try this

Base search | stats count as Count by TicketCode | rename TicketCode as Ticket| join Ticket[|inputlookup test1.csv] | stats dc(Ticket) 

View solution in original post

martin_mueller
SplunkTrust
SplunkTrust

What do your events and your lookup file look like?
What does the desired result look like?

0 Karma

strive
Influencer

I tried this and it worked.

I created test1.csv with two columns Ticket and Days

Base Search | stats count as Count by TicketCode | appendcols [|inputlookup test1.csv] | where TicketCode == Ticket | stats dc(TicketCode)

The above works when the field values are in same order.

You may try this

Base search | stats count as Count by TicketCode | rename TicketCode as Ticket| join Ticket[|inputlookup test1.csv] | stats dc(Ticket) 

C_Sparn
Communicator

I found a solution with testing your code:
My solustion looks like this:

Base search | rename TicketCode as Ticket| join Ticket[|inputlookup test1.csv|rename tickets as Tickets]
|stats dc(Ticket)

Then the join is correct and I can use all other fields of the csv file in the main search.
Thanks for the answers.

Greetings

C_Sparn
Communicator

Hello,
thanks for the answer, but both solutions are not working for me. With appendcols I get a table with each one ticket and one day value. But it is not the right day value like in the csv file. Join just gives no results. Also the where clause after appendcols gives no results in my search.

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...