Splunk Search

Can we save the search result in SPLUNK SERVER?

gpant
Explorer

I have a command on splunk server i.e..

" /splunk search ' .. | stats dc(f_name)' -uri "

I have save the result of this in a file, can I do it?

0 Karma
1 Solution

javiergn
Super Champion

Yes, you can either use the outputlookup or the outputcsv commands.
There are other alternatives too, but those are the ones you can run from the search gui.

View solution in original post

fdi01
Motivator

try like :

 " ./splunk search ' .. | stats dc(f_name) | outputcsv  file_name' -uri "

The file_name.csv file should be located in $SPLUNK_HOME/var/run/splunk. Directory.

0 Karma

gpant
Explorer

this search is for "Splunk link".

But I need to do in the server itself, by using SPLUNK command?

0 Karma

javiergn
Super Champion

Yes, you can either use the outputlookup or the outputcsv commands.
There are other alternatives too, but those are the ones you can run from the search gui.

javiergn
Super Champion

Hi, did this work for you?

0 Karma

javiergn
Super Champion

Hi, I'm a bit confused about your comments.

In summary, if you want to run your command and save the results to disk from the Splunk server:

./splunk search 'yoursearch | stats dc(f_name)' > yourfilename.txt

If you want to run it from the Splunk GUI:

yoursearch | stats dc(f_name) | outputcsv  yourfilename.csv

If none of those two work for you please provide more information.

Thanks,
J

0 Karma

gpant
Explorer

Both are working fine .

Thanks for the help.

Kind Grass,

Gaurav Pant

0 Karma

gpant
Explorer

@javiergn .
by the above query I will get the distinct count of field., but with this I also want the current date. Can this be done with this query only?

Ex:- RESULT should be:

dc(f_name) date
100 10th JAN, 2016

can you please help me in this?

0 Karma

javiergn
Super Champion

Sure, something like this should do the trick:

yoursearch 
| timechart span=1d dc(f_name)

If you want to group by week, month, etc simply play with the span values

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 ...