<?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 Pass parameters from one search to a second in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Pass-parameters-from-one-search-to-a-second/m-p/87272#M22332</link>
    <description>&lt;P&gt;On a daily basis a series of publications are distributed to a number of different accounts. The list of publications changes on a daily basis and is never repeated. The publications are transferred by a server named jkcs1. I have a search that gathers the names of publications created in the past 24 hours from that server. That search looks like this:&lt;/P&gt;

&lt;PRE&gt;
sourcetype="iis" jkcs1 /tm/ .pdf 
|makemv delim="/" cs_uri_stem 
| eval pubName=mvindex(cs_uri_stem,3) 
| fields pubName 
| stats list(pubName)
&lt;/PRE&gt;
 

&lt;P&gt;I need a second search that will take the output from the first search (pubName) and tell me how many of those publications were downloaded by each account. Not all accounts will download the same number of publications. I have a search that works perfectly if I hardcode the publication name. It looks like this:&lt;/P&gt;

&lt;PRE&gt;
sourcetype="iis" 01-110hcg-1b.pdf cs_username!="-" 
| eval cs_uri_stem=lower(cs_uri_stem) 
| chart count(cs_uri_stem) as Accounts by cs_uri_stem 
| rename cs_uri_stem as Publications 
| where Accounts &amp;gt;1
&lt;/PRE&gt;

&lt;P&gt;The output looks like this:&lt;/P&gt;

&lt;PRE&gt;
Publications       Accounts
01-110hcg-1b.pdf   24
&lt;/PRE&gt;

&lt;P&gt;What I want is something that combines both searches so that the second part gathers data based on the pubName field from the first search. The output would then look like this:&lt;/P&gt;

&lt;PRE&gt;
Publications                   Accounts
01-110hcg-1b.pdf               24
16-35mx3160-2.pdf              18
a1-v22ac-mrc-000.pdf           22
01-75pac-2-9.pdf               24
&lt;/PRE&gt;

&lt;P&gt;I’ve tried subsearches, appends, appendcols, outputcsv and inputcsv, map  and just about everything else I can think of. I can easily get the list of publications but the Accounts column is always blank.&lt;/P&gt;

&lt;P&gt;Is it possible to do what I want?&lt;/P&gt;</description>
    <pubDate>Wed, 05 Oct 2011 18:33:00 GMT</pubDate>
    <dc:creator>kmattern</dc:creator>
    <dc:date>2011-10-05T18:33:00Z</dc:date>
    <item>
      <title>Pass parameters from one search to a second</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-parameters-from-one-search-to-a-second/m-p/87272#M22332</link>
      <description>&lt;P&gt;On a daily basis a series of publications are distributed to a number of different accounts. The list of publications changes on a daily basis and is never repeated. The publications are transferred by a server named jkcs1. I have a search that gathers the names of publications created in the past 24 hours from that server. That search looks like this:&lt;/P&gt;

&lt;PRE&gt;
sourcetype="iis" jkcs1 /tm/ .pdf 
|makemv delim="/" cs_uri_stem 
| eval pubName=mvindex(cs_uri_stem,3) 
| fields pubName 
| stats list(pubName)
&lt;/PRE&gt;
 

&lt;P&gt;I need a second search that will take the output from the first search (pubName) and tell me how many of those publications were downloaded by each account. Not all accounts will download the same number of publications. I have a search that works perfectly if I hardcode the publication name. It looks like this:&lt;/P&gt;

&lt;PRE&gt;
sourcetype="iis" 01-110hcg-1b.pdf cs_username!="-" 
| eval cs_uri_stem=lower(cs_uri_stem) 
| chart count(cs_uri_stem) as Accounts by cs_uri_stem 
| rename cs_uri_stem as Publications 
| where Accounts &amp;gt;1
&lt;/PRE&gt;

&lt;P&gt;The output looks like this:&lt;/P&gt;

&lt;PRE&gt;
Publications       Accounts
01-110hcg-1b.pdf   24
&lt;/PRE&gt;

&lt;P&gt;What I want is something that combines both searches so that the second part gathers data based on the pubName field from the first search. The output would then look like this:&lt;/P&gt;

&lt;PRE&gt;
Publications                   Accounts
01-110hcg-1b.pdf               24
16-35mx3160-2.pdf              18
a1-v22ac-mrc-000.pdf           22
01-75pac-2-9.pdf               24
&lt;/PRE&gt;

&lt;P&gt;I’ve tried subsearches, appends, appendcols, outputcsv and inputcsv, map  and just about everything else I can think of. I can easily get the list of publications but the Accounts column is always blank.&lt;/P&gt;

&lt;P&gt;Is it possible to do what I want?&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2011 18:33:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-parameters-from-one-search-to-a-second/m-p/87272#M22332</guid>
      <dc:creator>kmattern</dc:creator>
      <dc:date>2011-10-05T18:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: Pass parameters from one search to a second</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-parameters-from-one-search-to-a-second/m-p/87273#M22333</link>
      <description>&lt;P&gt;You need:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="iis cs_username!="-" 
[ search sourcetype="iis" jkcs1 /tm/ .pdf
  | makemv delim="/" cs_uri_stem | eval pubName=mvindex(cs_uri_stem,3) 
  | fields pubName | rename pubName as query ]
| eval cs_uri_stem=lower(cs_uri_stem) 
| chart count(cs_uri_stem) as Accounts by cs_uri_stem 
| rename cs_uri_stem as Publications 
| where Accounts &amp;gt;1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You use a standard subsearch, but the trick is to name your field "query". I have no idea if this is even documented.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2011 20:14:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-parameters-from-one-search-to-a-second/m-p/87273#M22333</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2011-10-05T20:14:52Z</dc:date>
    </item>
    <item>
      <title>Re: Pass parameters from one search to a second</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-parameters-from-one-search-to-a-second/m-p/87274#M22334</link>
      <description>&lt;P&gt;Thanks! That's pretty close to what I want. I'll have to parse cs_uri_stem to remove the rest of the path for the file name. I have never seen anything about renaming teh field to "query" but if it works...&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 09:57:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-parameters-from-one-search-to-a-second/m-p/87274#M22334</guid>
      <dc:creator>kmattern</dc:creator>
      <dc:date>2020-09-28T09:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: Pass parameters from one search to a second</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-parameters-from-one-search-to-a-second/m-p/87275#M22335</link>
      <description>&lt;P&gt;It does get touched on in the docs a bit.  &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/User/HowSubsearchesWork"&gt;http://docs.splunk.com/Documentation/Splunk/latest/User/HowSubsearchesWork&lt;/A&gt; under the section titled "change the format of subsearch results" (which is now that I look at it, a bit of a misleading title for this info).&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2011 03:15:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-parameters-from-one-search-to-a-second/m-p/87275#M22335</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2011-10-06T03:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: Pass parameters from one search to a second</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Pass-parameters-from-one-search-to-a-second/m-p/87276#M22336</link>
      <description>&lt;P&gt;YOU ARE AMAZING&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2013 20:20:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Pass-parameters-from-one-search-to-a-second/m-p/87276#M22336</guid>
      <dc:creator>hiyer</dc:creator>
      <dc:date>2013-07-12T20:20:13Z</dc:date>
    </item>
  </channel>
</rss>

