Getting Data In

How to load a CSV file into Splunk & Change the csv file dynamically, so that data is refreshed.

alenseb
Communicator

Hi All,

I am trying to load a .csv file into splunk, using sourcetype(csv). Upload of data is working fine but the only issue if i change the data in this .csv file, new data get appended to the old data. what i need is to replace the old with new.
Example: if i have 4 lines in the csv initially & if i delete one of its line and add 2 new lines.
My new csv data should contain only 4 lines.
Right now when i am doing this, i am getting 9 lines(4-Old & 5-New) of data.

Please help me with the configurations.

Tags (2)
1 Solution

Paolo_Prigione
Builder

CSVs the way you mean them are treated in a different way than regular log files.
There are 2 basic kinds:

  1. "just CSVs", which are only accessed via "| inputcsv" and "| outputcsv"
  2. lookup CSVs, which are accessed with commands "| lookup", "| inputlookup" and "| outputlookup"

In the former case you can:

  1. load your CSV in $SPLUNK_HOME/var/run/splunk/filename.csv
  2. execute the search:

    | inputcsv filename.csv

In the latter you can:

  1. configure it from the Manager and upload the csv file
  2. you will be able to replace the file under this directory $SPLUNK_HOME/etc/apps/APPNAME/lookups/filename.csv.
  3. execute searches like:

    .... | lookup configname inputfield OUTPUT outputfield

View solution in original post

Paolo_Prigione
Builder

CSVs the way you mean them are treated in a different way than regular log files.
There are 2 basic kinds:

  1. "just CSVs", which are only accessed via "| inputcsv" and "| outputcsv"
  2. lookup CSVs, which are accessed with commands "| lookup", "| inputlookup" and "| outputlookup"

In the former case you can:

  1. load your CSV in $SPLUNK_HOME/var/run/splunk/filename.csv
  2. execute the search:

    | inputcsv filename.csv

In the latter you can:

  1. configure it from the Manager and upload the csv file
  2. you will be able to replace the file under this directory $SPLUNK_HOME/etc/apps/APPNAME/lookups/filename.csv.
  3. execute searches like:

    .... | lookup configname inputfield OUTPUT outputfield

Paolo_Prigione
Builder

It will probably will be slower than with the "| lookup" command and limited to some 50k results, but | join joinfield [|inputcsv ... | fields + joinfield otherfield] might do

0 Karma

alenseb
Communicator

Thanks!! Appending worked Just fine!

Can i use this "| inputcsv" command to Join with another log file?

0 Karma

MHibbin
Influencer

Do you not want to do this as a lookup?... http://docs.splunk.com/Documentation/Splunk/latest/User/CreateAndConfigureFieldLookups

If not you should be able to use the dedup command to show the latest event (i.e. the latest csv) depending on how you are indexing it.

MHIbbin

0 Karma

alenseb
Communicator

Thanks in advance!!

0 Karma

alenseb
Communicator

I tried the lookup but it didn't serve my purpose since the replacement of data wasn't happening.
Also i need to join this .csv file with another log file.
Therefore wen the data in csv file change, the result of the Join Query also should change.
Any Configuration files i need to look into. I am basically trying to automate it.

0 Karma

jpmackl
New Member

Any luck completing this effort? I'm trying to do the same thing. I have tool the produces a CSV report every hour, I would like to pull the data into Splunk in an automated fashion and then build real time dashboards from the data. Thank you for any help!

0 Karma

colinmchugo
Explorer

Any luck with this jpmackl ? I want to do something similar

0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...