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!

Introducing the Splunk Community Dashboard Challenge!

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

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...