Export data using the CLI
The Command Line Interface (CLI) is easy to script, can handle automation, and can process volumes of data faster and more efficiently than Splunk Web. To access Splunk Enterprise through the CLI, you either need shell access to a Splunk Enterprise server, or permission to access the correct port on a remote Splunk server.
Splunk Cloud Platform users don't have shell access to the Splunk Cloud Platform deployment and therefore can't use the CLI to export data.
The syntax for exporting data using the CLI is as follows:
splunk search [eventdata] -preview 0 -maxout 0 -output [rawdata | table | csv | raw | auto | json] > [myfilename.log] ...
If -output
is not specified, the default output depends on the type of search. For non-transforming searches, the default output format is rawdata
. For transforming searches, the default output format is table
.
By default, you can export a maximum of 100 events. To increase this number, use the -maxout
argument. For example, if you include -maxout 300000
you can export 300,000 events. Set -maxout
to 0 to export an unlimited number of events.
To learn more about the Splunk Enterprise CLI, read About the CLI in the Admin Manual.
CLI output command example
This CLI example takes events from the _internal
index that occur within the time range specified by the search string and outputs 200,000 of them in raw data format to the file test123.dmp
.
splunk search "index=_internal earliest=09/14/2024:23:59:00 latest=09/16/2024:01:00:00 " -output rawdata -maxout 200000 > c:/test123.dmp
Export data using Splunk Web | Export data using the Splunk REST API |
This documentation applies to the following versions of Splunk Cloud Platform™: 8.2.2112, 8.2.2201, 8.2.2202, 8.2.2203, 9.0.2205, 9.0.2208, 9.0.2209, 9.0.2303, 9.0.2305, 9.1.2308, 9.1.2312, 9.2.2403, 9.2.2406 (latest FedRAMP release), 9.3.2408
Feedback submitted, thanks!