Splunk Search

How to correlate 3 different CSV files with different column names?

krishnacasso
Path Finder

I have 3 different source CSV (file1, file2, file3) files.
In file 1, I have field(place) with value NJ and
In file 2, I have a field(city) with value NJ.
NJ is unique value in file 1 and file 2. I need to merge field names to City.
In file 2, I have a field(country) with value USA and
In file 3, I have a field(origin) with value USA.
USA is unique value in file 2 and file 3. I need to merge field names to Country.

I am trying to correlate the fields and join them and create a single table.

0 Karma
1 Solution

somesoni2
Revered Legend

Try something like this

source=csv1 OR source=csv2 OR source=csv3
| eval city=coalesce(city,place) | eval country=coalesce(country, origin)
| eventstats values(country) as country by city 
| eventstats values(city) as city by country
| stats values(field1) as field1 values(field2) as field2... by city country

View solution in original post

surakshita
New Member

I also same type question. I have 3 excel files generating from the servers as reports,two files are in same format and one file has different columns. I wanted to consolidate 3 files and need to analyze for start time and start date for the job.Can anyone give us the inputs on this?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try this.

| inputlookup file1.csv | lookup file2.csv city AS place | lookup file3.csv origin AS country | eval City=coalesce(place, city), Country=coalesce(country,origin) | ...
---
If this reply helps you, Karma would be appreciated.
0 Karma

krishnacasso
Path Finder

Can we add a condition to the search like to display the chart only for the Manhattan city and USA

0 Karma

somesoni2
Revered Legend

Try something like this

source=csv1 OR source=csv2 OR source=csv3
| eval city=coalesce(city,place) | eval country=coalesce(country, origin)
| eventstats values(country) as country by city 
| eventstats values(city) as city by country
| stats values(field1) as field1 values(field2) as field2... by city country
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

WATCH NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If exploited, ...

Enter the Splunk Community Dashboard Challenge for Your Chance to Win!

The Splunk Community Dashboard Challenge is underway! This is your chance to showcase your skills in creating ...

.conf24 | Session Scheduler is Live!!

.conf24 is happening June 11 - 14 in Las Vegas, and we are thrilled to announce that the conference catalog ...