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!

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

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...