Splunk Search

CLI Search - Export JSON File?

cramasta
Builder

Can I run a CLI search that will output the results to a file in json format?
Thanks,
Joe

Tags (1)

scelikok
SplunkTrust
SplunkTrust

Hi @zsbbb,

You can export any search output as json using below sample;

curl -k -u admin:changeme https://localhost:8089/services/search/jobs/export -d search="search sourcetype=access_* earliest=-7d" -d output_mode=json -o /path/to/local/file.json
If this reply helps you an upvote and "Accept as Solution" is appreciated.
0 Karma

zsbbb
Engager

New to splunk and bringing this back up - how does one do this? 

For context, I have a splunk container running on docker, and was hoping to translate the splunk index data into json using a cli search and saving the output as a local file.

 

Thanks!

Tags (3)
0 Karma

araitz
Splunk Employee
Splunk Employee

Coming soon to a Splunk version near you, watch the release notes...

0 Karma
Get Updates on the Splunk Community!

Archived Metrics Now Available for APAC and EMEA realms

We’re excited to announce the launch of Archived Metrics in Splunk Infrastructure Monitoring for our customers ...

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 Dashboard Challenge and Watch the .conf24 Global Broadcast!

The Splunk Community Dashboard Challenge is still happening, and it's not too late to enter for the week of ...