This documentation does not apply to the most recent version of Splunk. Click here for the latest version.
Puts search results into a summary index.
collect index [arg-options]*
- Syntax: index=<string>
- Description: Name of the index where Splunk should add the events. The index must exist for events to be added to it, the index is NOT created automatically.
- Syntax: addtime | file | spool | marker | testmode
- Description: Optional arguments for the collect command.
- Syntax: addtime=<bool>
- Description: Specify whether to prefix a time into each event if the event does not contain a
_rawfield. Splunk adds the time based on the first field that it finds:
info_min_time, _time, now(). Default is true.
- Syntax: file=<string>
- Description: Name of the file where to write the events. Optional, default "<random-num>_events.stash". The following placeholders can be used in the file name $timestamp$, $random$ and will be replaced with a timestamp and a random number, respectively.
- Syntax: marker=<string>
- Description: A string, usually of key-value pairs, to append to each event written out. Optional, default is empty.
- Syntax: spool=<bool>
- Description: If set to true (default is true), the summary indexing file will be written to Splunk's spool directory, where it will be indexed automatically. If set to false, file will be written to $SPLUNK_HOME/var/run/splunk.
- 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. (defaults to false)
Adds the results of the search into the specified index. Behind the scenes, the events are written to a file whose name format is: events_random-num.stash, unless overwritten, in a directory which is watched for new events by splunk. If the events contain a _raw field then the raw field is saved, if they don't a _raw field is constructed by concatenating all the fields into a comma separated key=value pairs list.
Example 1: Put "download" events into an index named "downloadcount".
eventtypetag="download" | collect index=downloadcount
Have questions? Visit Splunk Answers and see what questions and answers the Splunk community has using the collect command.