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!

CX Day is Coming!

Customer Experience (CX) Day is on October 7th!! We're so excited to bring back another day full of wonderful ...

Strengthen Your Future: A Look Back at Splunk 10 Innovations and .conf25 Highlights!

The Big One: Splunk 10 is Here!  The moment many of you have been waiting for has arrived! We are thrilled to ...

Now Offering the AI Assistant Usage Dashboard in Cloud Monitoring Console

Today, we’re excited to announce the release of a brand new AI assistant usage dashboard in Cloud Monitoring ...