<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to log results to an index? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-log-results-to-an-index/m-p/653612#M110858</link>
    <description>&lt;P&gt;The first two are nearly equivalent with the only difference being whether or not ingestion license is charged.&amp;nbsp; There is nothing "supposed" about the stash sourcetype not incurring license usage.&amp;nbsp; It's documented at &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.2.6/SearchReference/Collect#Syntax:~:text=By%20specifying%20a%20sourcetype%20outside%20of%20stash%2C%20you%20will%20incur%20license%20usage" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/7.2.6/SearchReference/Collect#Syntax:~:text=By%20specifying%20a%20sourcetype%20outside%20of%20stash%2C%20you%20will%20incur%20license%20usage&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;Unlike collect, the &lt;FONT face="courier new,courier"&gt;sendalert&lt;/FONT&gt; command does not write to an index.&amp;nbsp; As the command name implies, it sends an alert.&amp;nbsp; While it may be possible, I've never encountered an alert that writes to an index.&lt;/P&gt;&lt;P&gt;FTR, the &lt;FONT face="courier new,courier"&gt;collect&lt;/FONT&gt; command can write to any event index to which you have access.&amp;nbsp; It does not have to be a summary index.&amp;nbsp; Technically, all event indexes are the same, whether summary or not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 08 Aug 2023 19:38:49 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2023-08-08T19:38:49Z</dc:date>
    <item>
      <title>How to log results to an index?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-log-results-to-an-index/m-p/653601#M110856</link>
      <description>&lt;P&gt;I'm trying to figure out why you would use the various methods for sending search results to an index. Note, I'm not trying to speed up searches, I'm just looking at methods for writing search results to an index.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Pipe to the "collect" command with the default "stash" source type, supposedly avoiding license usage.&lt;/LI&gt;
&lt;LI&gt;Pipe to the "collect" command with a specified source type, incurring license usage.&lt;/LI&gt;
&lt;LI&gt;Pipe to the "sendalert" command with the "logevent" alert action specified, or if it's a saved search or alert, use the Log Event alert action&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Effectively, I think they all do the same thing. Option 1 seems like a sneaky way around license usage. However, I think "collect" can only be used with summary indexes. Any thoughts on this?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 18:52:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-log-results-to-an-index/m-p/653601#M110856</guid>
      <dc:creator>ejwade</dc:creator>
      <dc:date>2023-08-08T18:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to log results to an index?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-log-results-to-an-index/m-p/653612#M110858</link>
      <description>&lt;P&gt;The first two are nearly equivalent with the only difference being whether or not ingestion license is charged.&amp;nbsp; There is nothing "supposed" about the stash sourcetype not incurring license usage.&amp;nbsp; It's documented at &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.2.6/SearchReference/Collect#Syntax:~:text=By%20specifying%20a%20sourcetype%20outside%20of%20stash%2C%20you%20will%20incur%20license%20usage" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/7.2.6/SearchReference/Collect#Syntax:~:text=By%20specifying%20a%20sourcetype%20outside%20of%20stash%2C%20you%20will%20incur%20license%20usage&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;Unlike collect, the &lt;FONT face="courier new,courier"&gt;sendalert&lt;/FONT&gt; command does not write to an index.&amp;nbsp; As the command name implies, it sends an alert.&amp;nbsp; While it may be possible, I've never encountered an alert that writes to an index.&lt;/P&gt;&lt;P&gt;FTR, the &lt;FONT face="courier new,courier"&gt;collect&lt;/FONT&gt; command can write to any event index to which you have access.&amp;nbsp; It does not have to be a summary index.&amp;nbsp; Technically, all event indexes are the same, whether summary or not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 19:38:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-log-results-to-an-index/m-p/653612#M110858</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-08-08T19:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to log results to an index?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-log-results-to-an-index/m-p/653651#M110866</link>
      <description>&lt;P&gt;There is another way to write to an index (as&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;says there is no difference between a normal index or a summary index, it's just a notional idea that a summary index will typically contain events that are summarising other data).&lt;/P&gt;&lt;P&gt;If you have a scheduled saved search, you can enable 'Summary Indexing' from the Edit Summary Indexing option in the Searches Reports and Alerts view for that saved search.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.splunk.com/t5/Splunk-Search/How-to-create-summary-index/m-p/632465" target="_blank" rel="noopener"&gt;https://community.splunk.com/t5/Splunk-Search/How-to-create-summary-index/m-p/632465&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This is effectively the same as using collect.&lt;/P&gt;&lt;P&gt;Note when using collect, the documentation is unclear and wrong about the various aspects of how time gets defined in the collected event.&lt;/P&gt;&lt;P&gt;I have previously posted this information about collect and time&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------&lt;/P&gt;&lt;DIV class=""&gt;Any _time field is totally ignored in the collected event.&amp;nbsp; The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;best&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;way to get the time into your event is by creating _raw and setting a time field as the first part of the _raw. If _raw exists it is used in the collected data. You can see the data that is written to the file before it's ingested by setting&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;spool=f&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and looking at the raw stash file created in the file system.&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;Generally the use of addtime will put the info_* values at the START of the line in the data, so when the file is ingested, these are the first "timestamps" to be found.&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;Note that if you have a saved search that is running scheduled, then it will put an additional field&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;search_now&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;into the start of the data.&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;These are true&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;PRE&gt;* _time field is NEVER passed if no _raw field is present.
* Using addinfo=t will always PREPEND the fields to the summary row, this destroying the ability to define _time
* Scheduled saved searches will always PREPEND the search_* fields, again destroying the ability to define _time&lt;/PRE&gt;&lt;DIV class=""&gt;We normally use this construct in a macro to collect to indexes.&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval _raw=printf("_time=%d", desired_time_field)
| fields - desired_time_field
| foreach *
    [| eval _raw=_raw.", &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=\"".if(isnull('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'),"",'&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')."\"") 
     | fields - "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;" ] 
| collect index=bla source="bla" addtime=f testmode=f&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;and this can reliably be controlled as needed whether the search is run ad-hoc, as a report or as a scheduled saved search.&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 01:59:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-log-results-to-an-index/m-p/653651#M110866</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-08-09T01:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to log results to an index?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-log-results-to-an-index/m-p/653977#M110882</link>
      <description>&lt;P&gt;Thank you, &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;. That is good to know that the collect command can write to any event index; it does not have to be a summary index.&lt;/P&gt;&lt;P&gt;The sendalert command invokes an alert action. I'm using it to invoke logevent, which would effectively leverage the Log event alert action.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2023 17:49:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-log-results-to-an-index/m-p/653977#M110882</guid>
      <dc:creator>ejwade</dc:creator>
      <dc:date>2023-08-10T17:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to log results to an index?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-log-results-to-an-index/m-p/653989#M110883</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;thank you so much. This was extremely helpful. We created a similar macro using your foreach logic. Thank you again!&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2023 21:39:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-log-results-to-an-index/m-p/653989#M110883</guid>
      <dc:creator>ejwade</dc:creator>
      <dc:date>2023-08-10T21:39:03Z</dc:date>
    </item>
  </channel>
</rss>

