Examples

1. Put "download" events into an index named "download count"

eventtypetag="download" | collect index=downloadcount

2. Collect statistics on VPN connects and disconnects

You want to collect hourly statistics on VPN connects and disconnects by country.

The addinfo command ensures that the search results contain fields that specify when the search was run to populate these particular index values.

3. Ingest fields using the collect command and HEC formatted output

Say you want to create a few fields in your index by running the following search:

The results look something like this:

_raw _time host sentinel source sourcetype
this is an event with a key=value pair 2024-01-12T19:22:55.000-08:00 myhost 4 mysource mysourcetype

To see what the event we've just generated looks like in the index, run the following search:

index=main

The following image shows that all of the fields that were specified in the search appear as fields in the index.

Shows a partial cutout of search results for the example search. The top shows the date and time as 2024-01-12T19:22:55.000-08:00, as well as the raw event, which is "this is an event with a key=value pair". The first event is expanded. The first 3 rows show that host is set to myhost, source is set to mysource, and sourcetype is set to mysourcetype. In the subsequent rows, the Event is set to key value, the sentinel is set to 4, and the index is set to main.

Note that this search counts against your license usage because the search assigned a value to the source type and didn't use the default stash_hec sourcetype.