<?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 changing `host` and persisting the result in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/changing-host-and-persisting-the-result/m-p/454798#M128674</link>
    <description>&lt;P&gt;I am trying to make this query work:&lt;BR /&gt;
&lt;CODE&gt;index="main" | eval host=asset_id | collect index="scanned_app"&lt;/CODE&gt;&lt;BR /&gt;
where &lt;CODE&gt;asset_id&lt;/CODE&gt; is a field, not a static value.&lt;/P&gt;

&lt;P&gt;Two observations regarding the query:&lt;BR /&gt;
- without &lt;CODE&gt;| collect ...&lt;/CODE&gt;, the search shows data as i expect it - with the meta-field &lt;CODE&gt;host&lt;/CODE&gt; changed&lt;BR /&gt;
- with &lt;CODE&gt;| collect ...&lt;/CODE&gt;, the resulting index carries &lt;CODE&gt;host&lt;/CODE&gt; unchanged from the &lt;CODE&gt;main&lt;/CODE&gt; index&lt;/P&gt;

&lt;P&gt;Q: how do i change the &lt;CODE&gt;host&lt;/CODE&gt;, so that it can be persisted in another index ?&lt;BR /&gt;
&lt;CODE&gt;index="main" | eval *magic_here* | collect index="scanned_app"&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Sep 2018 23:22:47 GMT</pubDate>
    <dc:creator>mushkevych</dc:creator>
    <dc:date>2018-09-11T23:22:47Z</dc:date>
    <item>
      <title>changing `host` and persisting the result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/changing-host-and-persisting-the-result/m-p/454798#M128674</link>
      <description>&lt;P&gt;I am trying to make this query work:&lt;BR /&gt;
&lt;CODE&gt;index="main" | eval host=asset_id | collect index="scanned_app"&lt;/CODE&gt;&lt;BR /&gt;
where &lt;CODE&gt;asset_id&lt;/CODE&gt; is a field, not a static value.&lt;/P&gt;

&lt;P&gt;Two observations regarding the query:&lt;BR /&gt;
- without &lt;CODE&gt;| collect ...&lt;/CODE&gt;, the search shows data as i expect it - with the meta-field &lt;CODE&gt;host&lt;/CODE&gt; changed&lt;BR /&gt;
- with &lt;CODE&gt;| collect ...&lt;/CODE&gt;, the resulting index carries &lt;CODE&gt;host&lt;/CODE&gt; unchanged from the &lt;CODE&gt;main&lt;/CODE&gt; index&lt;/P&gt;

&lt;P&gt;Q: how do i change the &lt;CODE&gt;host&lt;/CODE&gt;, so that it can be persisted in another index ?&lt;BR /&gt;
&lt;CODE&gt;index="main" | eval *magic_here* | collect index="scanned_app"&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2018 23:22:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/changing-host-and-persisting-the-result/m-p/454798#M128674</guid>
      <dc:creator>mushkevych</dc:creator>
      <dc:date>2018-09-11T23:22:47Z</dc:date>
    </item>
    <item>
      <title>Re: changing `host` and persisting the result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/changing-host-and-persisting-the-result/m-p/454799#M128675</link>
      <description>&lt;P&gt;can you elaborate? is &lt;CODE&gt;asset_id&lt;/CODE&gt; a field or a static value?&lt;BR /&gt;
also, what is it that you are trying to accomplish? i sense &lt;CODE&gt;lookup&lt;/CODE&gt; will serve you better here&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2018 23:57:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/changing-host-and-persisting-the-result/m-p/454799#M128675</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2018-09-11T23:57:40Z</dc:date>
    </item>
    <item>
      <title>Re: changing `host` and persisting the result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/changing-host-and-persisting-the-result/m-p/454800#M128676</link>
      <description>&lt;P&gt;&lt;CODE&gt;asset_id&lt;/CODE&gt; is a field.&lt;BR /&gt;
my goal is to transform the data set by changing &lt;CODE&gt;host&lt;/CODE&gt; value and persist it in another index.&lt;BR /&gt;
P.S. Updated the question to reflect your comment&lt;/P&gt;</description>
      <pubDate>Wed, 12 Sep 2018 15:53:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/changing-host-and-persisting-the-result/m-p/454800#M128676</guid>
      <dc:creator>mushkevych</dc:creator>
      <dc:date>2018-09-12T15:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: changing `host` and persisting the result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/changing-host-and-persisting-the-result/m-p/454801#M128677</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;P&gt;index="main" | eval _raw=_raw.",host=".asset_id | collect index="scanned_app"&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:41:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/changing-host-and-persisting-the-result/m-p/454801#M128677</guid>
      <dc:creator>pwild_splunk</dc:creator>
      <dc:date>2020-09-29T21:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: changing `host` and persisting the result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/changing-host-and-persisting-the-result/m-p/454802#M128678</link>
      <description>&lt;P&gt;This may not do what you want. The events in the summary index will contain a host field that is multi-valued, containing the indexed host field as well as the auto-extracted host value. If the purpose of this is to create a dashboard or graph, you may be able to work with the data by removing the first value with something like this.&lt;/P&gt;

&lt;P&gt;| eval host=mvindex(host,1)&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 04:36:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/changing-host-and-persisting-the-result/m-p/454802#M128678</guid>
      <dc:creator>pwild_splunk</dc:creator>
      <dc:date>2018-10-16T04:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: changing `host` and persisting the result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/changing-host-and-persisting-the-result/m-p/454803#M128679</link>
      <description>&lt;P&gt;You can try and wrap you search in the map command that dynamically let's you generate another search.&lt;/P&gt;

&lt;P&gt;This generates an event in the summary index with host=hello set from the outer search.&lt;/P&gt;

&lt;P&gt;|makeresults count=1&lt;BR /&gt;
| eval asset_id="hello"&lt;BR /&gt;
| map search="&lt;BR /&gt;
search&lt;BR /&gt;
index=\"main\"&lt;BR /&gt;
| collect index=scanned_app host=$asset_id$&lt;BR /&gt;
"&lt;/P&gt;

&lt;P&gt;j&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:37:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/changing-host-and-persisting-the-result/m-p/454803#M128679</guid>
      <dc:creator>jbjerke_splunk</dc:creator>
      <dc:date>2020-09-29T21:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: changing `host` and persisting the result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/changing-host-and-persisting-the-result/m-p/454804#M128680</link>
      <description>&lt;P&gt;This will work. Remember that the map command, by default, is limited to only 10 sub-search iterations. Use the option maxsearches=10000 or something more appropriate for your data set.&lt;/P&gt;

&lt;P&gt;Converting the above to your actual search, see below. You probably don't need "_time=$orig_time$," in the eval.&lt;/P&gt;

&lt;P&gt;index="main" &lt;BR /&gt;
| eval orig_time=_time, orig_raw=_raw&lt;BR /&gt;
| map maxsearches=10000 search="|makeresults=1&lt;BR /&gt;
                            |eval _time=$orig_time$, _raw=$orig_raw$ &lt;BR /&gt;
                            | collect index="scanned_app" sourcetype=X host=$asset_id$"&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:41:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/changing-host-and-persisting-the-result/m-p/454804#M128680</guid>
      <dc:creator>pwild_splunk</dc:creator>
      <dc:date>2020-09-29T21:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: changing `host` and persisting the result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/changing-host-and-persisting-the-result/m-p/454805#M128681</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/123053"&gt;@jbjerke_splunk&lt;/a&gt;  and &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/66668"&gt;@pwild_splunk&lt;/a&gt; thank you for comments. could you perhaps help me understand why the SPL &lt;CODE&gt;index="main" | eval host=asset_id | collect index="scanned_app"&lt;/CODE&gt; works without &lt;CODE&gt;|collect...&lt;/CODE&gt; and does not work with &lt;CODE&gt;|collect...&lt;/CODE&gt; ? What is happening during &lt;CODE&gt;|collect...&lt;/CODE&gt;? &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:37:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/changing-host-and-persisting-the-result/m-p/454805#M128681</guid>
      <dc:creator>mushkevych</dc:creator>
      <dc:date>2020-09-29T21:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: changing `host` and persisting the result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/changing-host-and-persisting-the-result/m-p/454806#M128682</link>
      <description>&lt;P&gt;@mushkevych -Since host is a default field , and collect command will look for default fields for source sourcetype host unless you override it in collect command&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 16:31:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/changing-host-and-persisting-the-result/m-p/454806#M128682</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2018-10-16T16:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: changing `host` and persisting the result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/changing-host-and-persisting-the-result/m-p/454807#M128683</link>
      <description>&lt;P&gt;@Vijeta thank you for reply. Perhaps you can advise how to &lt;STRONG&gt;override&lt;/STRONG&gt; default field &lt;CODE&gt;host&lt;/CODE&gt; in &lt;CODE&gt;collect&lt;/CODE&gt; command?&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 16:35:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/changing-host-and-persisting-the-result/m-p/454807#M128683</guid>
      <dc:creator>mushkevych</dc:creator>
      <dc:date>2018-10-16T16:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: changing `host` and persisting the result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/changing-host-and-persisting-the-result/m-p/454808#M128684</link>
      <description>&lt;P&gt;Since you want host value to be assigned to a variable asset_id , you will have to use map command as mentioned by &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/66668"&gt;@pwild_splunk&lt;/a&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:37:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/changing-host-and-persisting-the-result/m-p/454808#M128684</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2020-09-29T21:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: changing `host` and persisting the result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/changing-host-and-persisting-the-result/m-p/522139#M147217</link>
      <description>&lt;P&gt;To understand why this doesn't work as you're expecting you have to understand how the collect command works. When you pipe a search result into collect, it dumps the output of the command into a text file on your splunk server, which is then picked up by a monitor input for indexing in the same way as any other input. Just like when configuring a monitor input, you can specify the host field once for the input, you can't set it on an event by event basis. With collect, when you define fields like index=A, sourcetype=B, host=C you are defining them in the same way you would in an inputs.conf. Those fields are applied to the output for processing by Splunk's data pipeline.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:17:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/changing-host-and-persisting-the-result/m-p/522139#M147217</guid>
      <dc:creator>pwild_splunk</dc:creator>
      <dc:date>2020-09-30T03:17:46Z</dc:date>
    </item>
  </channel>
</rss>

