Syntax
The required syntax is in bold.
collect
index=<string>
[<arg-options>...]
Required arguments
index
Syntax: index=<string>
Description: Name of the summary index where the events are added. The index must exist before the events are added. The index is not created automatically.
Optional arguments
arg-options
Syntax: addinfo=<bool> | addtime=<bool> | file=<string> | spool=<bool> | marker=<string> | uselb=<bool> | output_format [raw | hec] | testmode=<bool> | run_in_preview=<bool> | host=<string> | source=<string> | sourcetype=<string> | timeformat=<string>
Description: Optional arguments for the collect command. See the arg-options section for the descriptions for each option.
arg-options
addinfo
Syntax: addinfo=<bool>
Description: Use this option to specify whether to prefix search time and time-range information fields on to each summary index event. If set to true, adds fields to each event in the following format:
info_min_time=<search_earliest_time>, info_max_time=<search_latest_time>, info_search_time=<search_exec_time>
Default: True when summary events are destined for an events index or when output_format=raw. False when summary events are destined for a metrics index.
addtime
Syntax: addtime=<bool>
Description: Use this option to specify whether to prefix a time field on to each event. Some commands return results that do not have a _raw field, such as the stats, chart, timechart commands. If you specify addtime=false, the Splunk software uses its generic date detection against fields in whatever order they happen to be in the summary rows. If you specify addtime=true, the Splunk software uses the search time range info_min_time. This time range is added by the sistats command or _time. Splunk software adds the time field based on the first field that it finds: info_min_time, _time, or now().
This option is not valid when output_format=hec.
Default: True when summary events are destined for an events index. False when summary events are destined for a metrics index.
file
Syntax: file=<string>
Description: The file name where you want the events to be written. You can use a timestamp or a random number for the file name by specifying either file=$timestamp$ or file=$random$.
Usage: ".stash" needs to be added at the end of the file name when used with "index=". Otherwise, the data is added to the main index.
Default: <random-number>_events.stash
host
Syntax: host=<string>
Description: The name of the host that you want to specify for the events.
This option is not valid when output_format=hec.
marker
Syntax: marker=<string>
Description: A string, usually of key-value pairs, to append to each event written out. Each key-value pair must be separated by a comma and a space.
If the value contains spaces or commas, it must be escape quoted. For example if the key-value pair is search_name=vpn starts and stops, you must change it to search_name=\"vpn starts and stops\".
This option is not valid when output_format=hec.
output_format
Syntax: output_format=[raw | hec]
Description: Specifies the output format for the summary indexing. If set to raw, uses the traditional non-structured log style summary indexing stash output format.
If set to hec, the collect command generates HTTP Event Collector (HEC) JSON formatted output.
- When
output_format=rawand the source type is the internal stash source type (stash). - When
output_format=hecand the source type is the internal stash source type (stash_hec).
To confirm whether the source type is stash or stash_hec, expand the event in the search results after you run your search.
License usage is counted when output_format=hec and the original source type is used instead of stash_hec.
output_format=hec, note that:
- All fields are automatically indexed when the stash file is indexed.
- The file that is written to the
var/spool/splunkpath ends in.stash_hecinstead of.stash. - The source, source type, and host from the original data are used directly in the summary index. These fields are not remapped to the
extract_host/extracted_sourcetype/...path. - The
indexandsplunk_serverfields in the original data are ignored. - You can't use the
addtime,host,marker,source,sourcetype, oruselboptions.
Default: raw
run_in_preview
Syntax: run_in_preview=<bool>
Description: Controls whether the collect command is enabled during preview generation. Generally, you do not want to insert preview results into the summary index, run_in_preview=false. In some cases, such as when a custom search command is used as part of the search, you might want to turn this on to ensure correct summary indexable previews are generated.
Default: false
spool
Syntax: spool=<bool>
Description: If set to true, the summary indexing file is written to the Splunk spool directory, where it is indexed automatically. If set to false, the file is written to the $SPLUNK_HOME/var/run/splunk directory. The file remains in this directory unless some form of further automation or administration is done. If you have Splunk Enterprise, you can use this command to troubleshoot summary indexing by dumping the output file to a location on disk where it will not be ingested as data.
Default: true
source
Syntax: source=<string>
Description: The name of the source that you want to specify for the events.
This option is not valid when output_format=hec.
sourcetype
Syntax: sourcetype=<string>
Description: The name of the source type that you want to specify for the events. If you specify a source type other than stash, the ingested summary data will count against your license usage.
This option is not valid when output_format=hec.
Default: stash
testmode
Syntax: testmode=<bool>
Description: Toggle between testing and real mode. In testing mode the results are not written into the new index but the search results are modified to appear as they would if sent to the index.
Default: false
timeformat
Syntax: timeformat=<string>
Description: Controls the format of the timestamp that is written to the stash file before it is indexed. The addtime argument must be set to true for the same invocation of the command in order to take advantage of this functionality.
Use this argument only if you need precise control over the format of output files that the collect command generates.
This option is not valid when output_format=hec.
Default: %m/%d/%Y %H:%M:%S %z
uselb
Syntax: uselb=<bool>
- When set to
true, the data that is ingested using thecollectcommand is split into individual events. A string identical to the LINE_BREAKER setting defined for thestash_newsource type in theprops.conffile is used. - When set to
false, a simple line break is used to split events. - Do not use this argument unless you are intentionally generating events with the
collectcommand in a line-oriented format. - This option is not valid when
output_format=hec. - NOTE: While the default behavior of the
collectcommand is to use a LINE_BREAKER setting identical to that used in theprops.conffile, the default LINE_BREAKER for thecollectcommand is hardcoded. Changes to props.conf setting do NOT affect the behavior of theuselboption.
Default: true