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. If you have Splunk Cloud, you do not have shell access to your Splunk Cloud deployment, so cannot 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|json|csv|xml] > [myfilename.log] ...
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
splunk search "index=_internal earliest=09/14/2015:23:59:00 latest=09/16/2015: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® Enterprise: 6.4.0, 6.4.1, 6.4.2, 6.4.3, 6.4.4, 6.4.5, 6.4.6, 6.4.7, 6.4.8, 6.4.9, 6.5.0, 6.5.1, 6.5.1612 (Splunk Cloud only), 6.5.2, 6.5.3, 6.5.4, 6.5.5, 6.5.6, 6.5.7, 6.6.0, 6.6.1, 6.6.2, 6.6.3, 6.6.4, 6.6.5, 7.0.0, 7.0.1