<?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 How to pass base search results to subsearch in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-pass-base-search-results-to-subsearch/m-p/460759#M30233</link>
    <description>&lt;P&gt;Hi Folks,&lt;/P&gt;

&lt;P&gt;We receive several hundred files per day from 20 different sources. The filenames contain the source that we received the file from, and have a three digit sequence number as a suffix.&lt;/P&gt;

&lt;P&gt;Occasionally a file gets lost in transit, so I have designed a dashboard with 20 panels (one for each source) to highlight missing files by doing a  &lt;CODE&gt;makeresults&lt;/CODE&gt; and then a  &lt;CODE&gt;streamstats&lt;/CODE&gt; to generate a list of sequence numbers, and then a  &lt;CODE&gt;join&lt;/CODE&gt; to a  &lt;CODE&gt;search&lt;/CODE&gt; which extracts the sequence numbers from the filenames received, and then any sequence numbers that are not 'joined' to a filename are flagged as missing files.&lt;/P&gt;

&lt;P&gt;To make the dashboard more efficient, I'm trying to implement a base search to list the files from all sources, which I then want to pass to my subsearches - I have to use subsearches because of the  &lt;CODE&gt;makeresults&lt;/CODE&gt; which generates the full list of sequence numbers.&lt;/P&gt;

&lt;P&gt;(please see a cut-down version of the code below)&lt;/P&gt;

&lt;P&gt;However, it seems that the subsearches are unable to read my base search. &lt;/P&gt;

&lt;P&gt;I see that this question has been asked a few times in this forum, but none of the questions I viewed have accepted answers, and none of them were trying to use the same technique.&lt;/P&gt;

&lt;P&gt;So I just wanted to check . . . is there a way to pass base search results to subsearches? &lt;/P&gt;

&lt;P&gt;If not, is there another strategy that I could use to detect missing files?&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Doug.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard&amp;gt;
  &amp;lt;label&amp;gt;Base Post Question&amp;lt;/label&amp;gt;
  &amp;lt;search id="filelist"&amp;gt;
    &amp;lt;query&amp;gt;           
      my base search which extracts filenames and the times that they arrived
      | eval source=substr(filename,1,3)
      | eval seq=ltrim(substr(filename,14,3),"0")
      | table _time filename source seq
    &amp;lt;/query&amp;gt;
    &amp;lt;earliest&amp;gt;-24h&amp;lt;/earliest&amp;gt;
    &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
    &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
    &amp;lt;refresh&amp;gt;1h&amp;lt;/refresh&amp;gt;
    &amp;lt;refreshType&amp;gt;interval&amp;lt;/refreshType&amp;gt;
  &amp;lt;/search&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;
            | makeresults count=99
            | streamstats count as seq
            | join type=left seq
              [ | search base="filelist" source="ABC"
                | table _time filename source seq ]
            | eval filename=if(isnull(filename),"Missing File!",filename)
            | table _time filename
          &amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 03 Feb 2020 18:46:06 GMT</pubDate>
    <dc:creator>dougburdan</dc:creator>
    <dc:date>2020-02-03T18:46:06Z</dc:date>
    <item>
      <title>How to pass base search results to subsearch</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-pass-base-search-results-to-subsearch/m-p/460759#M30233</link>
      <description>&lt;P&gt;Hi Folks,&lt;/P&gt;

&lt;P&gt;We receive several hundred files per day from 20 different sources. The filenames contain the source that we received the file from, and have a three digit sequence number as a suffix.&lt;/P&gt;

&lt;P&gt;Occasionally a file gets lost in transit, so I have designed a dashboard with 20 panels (one for each source) to highlight missing files by doing a  &lt;CODE&gt;makeresults&lt;/CODE&gt; and then a  &lt;CODE&gt;streamstats&lt;/CODE&gt; to generate a list of sequence numbers, and then a  &lt;CODE&gt;join&lt;/CODE&gt; to a  &lt;CODE&gt;search&lt;/CODE&gt; which extracts the sequence numbers from the filenames received, and then any sequence numbers that are not 'joined' to a filename are flagged as missing files.&lt;/P&gt;

&lt;P&gt;To make the dashboard more efficient, I'm trying to implement a base search to list the files from all sources, which I then want to pass to my subsearches - I have to use subsearches because of the  &lt;CODE&gt;makeresults&lt;/CODE&gt; which generates the full list of sequence numbers.&lt;/P&gt;

&lt;P&gt;(please see a cut-down version of the code below)&lt;/P&gt;

&lt;P&gt;However, it seems that the subsearches are unable to read my base search. &lt;/P&gt;

&lt;P&gt;I see that this question has been asked a few times in this forum, but none of the questions I viewed have accepted answers, and none of them were trying to use the same technique.&lt;/P&gt;

&lt;P&gt;So I just wanted to check . . . is there a way to pass base search results to subsearches? &lt;/P&gt;

&lt;P&gt;If not, is there another strategy that I could use to detect missing files?&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Doug.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard&amp;gt;
  &amp;lt;label&amp;gt;Base Post Question&amp;lt;/label&amp;gt;
  &amp;lt;search id="filelist"&amp;gt;
    &amp;lt;query&amp;gt;           
      my base search which extracts filenames and the times that they arrived
      | eval source=substr(filename,1,3)
      | eval seq=ltrim(substr(filename,14,3),"0")
      | table _time filename source seq
    &amp;lt;/query&amp;gt;
    &amp;lt;earliest&amp;gt;-24h&amp;lt;/earliest&amp;gt;
    &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
    &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
    &amp;lt;refresh&amp;gt;1h&amp;lt;/refresh&amp;gt;
    &amp;lt;refreshType&amp;gt;interval&amp;lt;/refreshType&amp;gt;
  &amp;lt;/search&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;
            | makeresults count=99
            | streamstats count as seq
            | join type=left seq
              [ | search base="filelist" source="ABC"
                | table _time filename source seq ]
            | eval filename=if(isnull(filename),"Missing File!",filename)
            | table _time filename
          &amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Feb 2020 18:46:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-pass-base-search-results-to-subsearch/m-p/460759#M30233</guid>
      <dc:creator>dougburdan</dc:creator>
      <dc:date>2020-02-03T18:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass base search results to subsearch</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-pass-base-search-results-to-subsearch/m-p/460760#M30234</link>
      <description>&lt;P&gt;base searches do not work like that. you can't add it as an identifier inside of a search string, it only works inside of the  node. You'll probably want to use &lt;CODE&gt;|loadjob&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;create a token with the sid from your base search, something like &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;done&amp;gt;
&amp;lt;set token="sid"&amp;gt;$job.sid$&amp;lt;/set&amp;gt;
&amp;lt;/done&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and then within your subsearch, something like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|loadjob $sid$.....
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Feb 2020 21:43:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-pass-base-search-results-to-subsearch/m-p/460760#M30234</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2020-02-03T21:43:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass base search results to subsearch</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-pass-base-search-results-to-subsearch/m-p/460761#M30235</link>
      <description>&lt;P&gt;Thanks cmerriman, I did see a similar answer in this forum, but I couldn't get it to work.&lt;/P&gt;

&lt;P&gt;It used  &lt;CODE&gt;index=_internal&lt;/CODE&gt;, which I didn't have access to (I'm just a user - not admin), so I applied for and got access, but it still didn't work, so maybe the _internal index was just because it was a 'run anywhere' example?&lt;/P&gt;

&lt;P&gt;Here is an example where I've removed  &lt;CODE&gt;index=_internal&lt;/CODE&gt; and added some code to show that the SID has been assigned to the token, but my  &lt;CODE&gt;loadjob&lt;/CODE&gt; still shows no results - are you able to tell me where I am going wrong?&lt;/P&gt;

&lt;P&gt;(I'm relatively new to Splunk so it's probably some rookie mistake ;o)&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Doug.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard&amp;gt;
&amp;lt;label&amp;gt;Test SID&amp;lt;/label&amp;gt;
  &amp;lt;search&amp;gt;
    &amp;lt;query&amp;gt;
      | makeresults count=99
      | streamstats count as seq
    &amp;lt;/query&amp;gt;
    &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
    &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
    &amp;lt;done&amp;gt;
      &amp;lt;condition&amp;gt;
        &amp;lt;set token="subsearch_sid"&amp;gt;$job.sid$&amp;lt;/set&amp;gt;
      &amp;lt;/condition&amp;gt;
    &amp;lt;/done&amp;gt;
  &amp;lt;/search&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;title&amp;gt;Token Values&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;
            | makeresults
            | eval subsearch_sid = "$subsearch_sid$"
            | table subsearch_sid
          &amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;row&amp;gt;
  &amp;lt;panel&amp;gt;
    &amp;lt;event&amp;gt;
      &amp;lt;search&amp;gt;
        &amp;lt;query&amp;gt;
          | loadjob $subsearch_sid$
          | table seq
        &amp;lt;/query&amp;gt;
        &amp;lt;earliest&amp;gt;-24s@s&amp;lt;/earliest&amp;gt;
        &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
        &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
      &amp;lt;/search&amp;gt;
      &amp;lt;option name="list.drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
    &amp;lt;/event&amp;gt;
  &amp;lt;/panel&amp;gt;
&amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Feb 2020 22:57:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-pass-base-search-results-to-subsearch/m-p/460761#M30235</guid>
      <dc:creator>dougburdan</dc:creator>
      <dc:date>2020-02-03T22:57:25Z</dc:date>
    </item>
  </channel>
</rss>

