<?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: Add a for loop on eval command for number of hosts in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Add-a-for-loop-on-eval-command-for-number-of-hosts/m-p/501847#M139702</link>
    <description>&lt;P&gt;That's the way &lt;CODE&gt;appendcols&lt;/CODE&gt; works.  The results from search 2 are added to the results from search 1 on a one-to-one basis.  If there are fewer results in search 2 then some results from search 1 will not have the added columns.  Also, note that the order in which the results are returned from each search should be the same so the one-to-one pairing of results makes sense.&lt;/P&gt;

&lt;P&gt;If you need the results from search 2 to be replicated to all results of search 1 then perhaps &lt;CODE&gt;filldown&lt;/CODE&gt; will do.&lt;/P&gt;</description>
    <pubDate>Thu, 21 May 2020 12:46:48 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2020-05-21T12:46:48Z</dc:date>
    <item>
      <title>Add a for loop on eval command for number of hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-a-for-loop-on-eval-command-for-number-of-hosts/m-p/501846#M139701</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;i have a query that returns two lines of results based on two hosts.&lt;BR /&gt;
i then get a result from another query that only returns one line.&lt;BR /&gt;
When i do the eval command i get a correct 'Match' for the first line but no entry for the second.&lt;/P&gt;

&lt;P&gt;How do i apply the 'appendcol' result to both lines?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index =systems sourcetype = stream_stack PID=0x0055 
|  eval Packets=packets*208 
 | stats  latest(Packets) AS Packets by host 
|  appendcols 
    [ search index=systems sourcetype=soms_file_size process=soms  | stats  latest(file_size) AS file_size latest(file_name) AS file_name by process ]
     | eval match=if(Packets=file_size,"OK","Error")
     | table process match Packets file_size file_name host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;RESULT&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;process  match            file_size file_name                                                   host
soms       OK                     27666832  DR_270919_P_5068_719_750_750.out                             chietrp01
           Error                                                                               chietrp02
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;thanks,&lt;/P&gt;</description>
      <pubDate>Thu, 21 May 2020 11:19:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-a-for-loop-on-eval-command-for-number-of-hosts/m-p/501846#M139701</guid>
      <dc:creator>ssaenger</dc:creator>
      <dc:date>2020-05-21T11:19:59Z</dc:date>
    </item>
    <item>
      <title>Re: Add a for loop on eval command for number of hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-a-for-loop-on-eval-command-for-number-of-hosts/m-p/501847#M139702</link>
      <description>&lt;P&gt;That's the way &lt;CODE&gt;appendcols&lt;/CODE&gt; works.  The results from search 2 are added to the results from search 1 on a one-to-one basis.  If there are fewer results in search 2 then some results from search 1 will not have the added columns.  Also, note that the order in which the results are returned from each search should be the same so the one-to-one pairing of results makes sense.&lt;/P&gt;

&lt;P&gt;If you need the results from search 2 to be replicated to all results of search 1 then perhaps &lt;CODE&gt;filldown&lt;/CODE&gt; will do.&lt;/P&gt;</description>
      <pubDate>Thu, 21 May 2020 12:46:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-a-for-loop-on-eval-command-for-number-of-hosts/m-p/501847#M139702</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-05-21T12:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: Add a for loop on eval command for number of hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-a-for-loop-on-eval-command-for-number-of-hosts/m-p/501848#M139703</link>
      <description>&lt;P&gt;Thank you richgalloway this worked.&lt;/P&gt;

&lt;P&gt;For those seeking solution, here is the code for filldown, nice and easy - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index =systems sourcetype = stream_stack PID=0x0055 
 |  eval Packets=packets*208 
  | stats  latest(Packets) AS Packets by host 
 |  appendcols 
     [ search index=systems sourcetype=soms_file_size process=soms  | stats  latest(file_size) AS file_size latest(file_name) AS file_name by process ]
      | filldown process, file_size, file_name
      | eval match=if(Packets=file_size,"OK","Error")
      | table process match Packets file_size file_name host
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 24 May 2020 08:43:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-a-for-loop-on-eval-command-for-number-of-hosts/m-p/501848#M139703</guid>
      <dc:creator>ssaenger</dc:creator>
      <dc:date>2020-05-24T08:43:48Z</dc:date>
    </item>
  </channel>
</rss>

