Splunk Search

lookup two csv pattern match query

surekhasplunk
Communicator

I have a requirement like this

from file1.csv lookup file i am getting 2 fields
field1 field2


"application support" 1

"technology maintenance" 3
"enterprise platform" 4

file2.csv file has many fields out of which one of the field name field3 has data like this

filed3

"application file"
"cto maintenance"
"application file"
"application file"
"application file"
"enterprise security"
"enterprise security"

Now if field1="application support" search for word "application" in file2.csv in field3 And since we got a pattern match for word application now i need the count saying how many "application file" values are there in field3 of file2.csv and get the resulting table as below.

field1 field2 field3


"application support" 1 4
"technology maintenance" 3 1
"enterprise platform" 4 2

Tags (2)
0 Karma
1 Solution

anjambha
Communicator

Hello,

try this..

| inputlookup file1 | join type=outer field1 [| inputlookup file2 | eval field1=case(field3 == "application file", "application support", field3 == "cto maintenance", "technology maintenance") | stats count by field1] | table field1 field2 count

View solution in original post

anjambha
Communicator

Hello,

try this..

| inputlookup file1 | join type=outer field1 [| inputlookup file2 | eval field1=case(field3 == "application file", "application support", field3 == "cto maintenance", "technology maintenance") | stats count by field1] | table field1 field2 count

surekhasplunk
Communicator

Thank you very much @anjambha it worked

0 Karma

elliotproebstel
Champion

Couple of questions:
(1) Is this something you're doing once and could handle a multi-step process, or something you want to run over and over?
(2) How many entries are in file1? A small handful, or a very long list?
(3) In all of your examples, the position of the word in field1 from file1.csv matches the position of matching words in field3. For example, "application support" matches against "application file" - would it also match against "file application" if such an entry existed in field3?

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

Ready to make your IT operations smarter and more efficient? Discover how to automate Splunk alerts with Red ...