<?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: subsearch fields do not appear in the table command.. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/subsearch-fields-do-not-appear-in-the-table-command/m-p/324290#M96782</link>
    <description>&lt;P&gt;No, using &lt;CODE&gt;join&lt;/CODE&gt; subjects you to a low an inescapable &lt;CODE&gt;subsearch&lt;/CODE&gt; limit, so do everything possible to avoid using it.  See here:&lt;/P&gt;

&lt;P&gt;Who: Nick Mealy, Sideview Apps&lt;BR /&gt;
What: Best practices around grouping and aggregating data from different search results&lt;BR /&gt;
Recording: &lt;A href="https://splunk.webex.com/splunk/lsr.php?RCID=051cba772c9cce79c3eb3718b466233a"&gt;https://splunk.webex.com/splunk/lsr.php?RCID=051cba772c9cce79c3eb3718b466233a&lt;/A&gt;&lt;BR /&gt;
Slides: &lt;A href="http://sideviewapps.com/slides/2017_05_02_sideview_let_stats_sort_them_out.pptx"&gt;http://sideviewapps.com/slides/2017_05_02_sideview_let_stats_sort_them_out.pptx&lt;/A&gt; (Updated several times since the talk and since conf)&lt;BR /&gt;
The version from the first virtual conf is &lt;A href="http://sideviewapps.com/slides/2016_04_15_nick_mealy_grouping_talk.pptx"&gt;http://sideviewapps.com/slides/2016_04_15_nick_mealy_grouping_talk.pptx&lt;/A&gt;&lt;BR /&gt;
flowchart (in progress) : &lt;A href="http://sideviewapps.com/slides/grouping_flowchart_INPROGRESS.png"&gt;http://sideviewapps.com/slides/grouping_flowchart_INPROGRESS.png&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 10 Sep 2017 14:13:45 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2017-09-10T14:13:45Z</dc:date>
    <item>
      <title>subsearch fields do not appear in the table command..</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-fields-do-not-appear-in-the-table-command/m-p/324285#M96777</link>
      <description>&lt;P&gt;What is wrong with this search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host="**" source="*BIP*"  NOT source="*BIP98*" NOT source="*BIP99*" |eval path=mvindex(split(source,"-"),0) | 
eval thread=mvindex(split(path,"/"),-1) |search "BIP CONTROL" | search "TASK MODE:      0"  | 
eval EXECUTION_DATE=strftime(strptime(EXECUTION_DATE,"%d %b %Y"),"%Y.%m.%d") | rex "TOTAL\s+ACCOUNTS\s+QUEUED:\s+(?[^,\s]+)" | 
 rex "TOTAL\s+SUCCESSFULLY\s+PROCESSED:\s+(?[^,\s]+)" | rex "TOTAL\s+LOCKED/SKIPPED:\s+(?[^,\s]+)"|
 rex "TOTAL\s+IN\s+ERROR:\s+(?[^,\s]+)" | 
 rex "MISSING\n\W+\s+\W+\s+\W+\s+\W+\s+\W+\s+\W+\s+\W+\s+\W+\s+\W+\s+\W+\s+\W+\s+\W+\s+\W+\n(?[^,\s]+)" |stats sum(total_accounts) 
 as Total_Accounts,sum(processed) as Total_Successful,sum(skipped) as "Total_Skipped",sum(error) as "Total_Error" by Bill_run,EXECUTION_DATE 
| where Bill_run like "%M%"  | 

appendcols

 [search host="****" sourcetype="kenan_pst" | where source like "%pst_pe_arb_bil_run_bip%"  |
 eval date=mvindex(split(mvindex(split(source,"/"),-1),"_"),6) |  stats earliest(_time) as first_event latest(_time) as 
last_event by source ,date | eval first_event=strftime(first_event,"%H:%M:%S") | eval last_event=strftime(last_event,"%H:%M:%S") 
 | eval time_diff=strptime(last_event,"%H:%M:%S") - strptime(first_event,"%H:%M:%S")
 |  table time_diff date] 

 |  table Bill_run  EXECUTION_DATE Total_Accounts Total_Successful Total_Skipped  Total_Error time_diff  date
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Sep 2017 10:30:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-fields-do-not-appear-in-the-table-command/m-p/324285#M96777</guid>
      <dc:creator>smuderasi</dc:creator>
      <dc:date>2017-09-06T10:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch fields do not appear in the table command..</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-fields-do-not-appear-in-the-table-command/m-p/324286#M96778</link>
      <description>&lt;P&gt;Hi smuderasi,&lt;BR /&gt;
which subsearch are you speaking of? there are two subsearches.&lt;/P&gt;

&lt;P&gt;Anyway your first subsearch is used to filter events resulting from the main search, so it doesn't add any field to results.&lt;/P&gt;

&lt;P&gt;If you're speaking of appendcols subsearch, remember that this command append to all rows of main search fields of first row of the subsearch.&lt;BR /&gt;
if you want to join main search results with subsearch results use join command.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2017 11:10:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-fields-do-not-appear-in-the-table-command/m-p/324286#M96778</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-09-06T11:10:31Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch fields do not appear in the table command..</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-fields-do-not-appear-in-the-table-command/m-p/324287#M96779</link>
      <description>&lt;P&gt;when you run just your subsearch, do you get &lt;STRONG&gt;time_diff&lt;/STRONG&gt; and &lt;STRONG&gt;date&lt;/STRONG&gt;? &lt;/P&gt;

&lt;P&gt;as a housekeeping question, why are you putting &lt;STRONG&gt;first_event&lt;/STRONG&gt; and &lt;STRONG&gt;last_event&lt;/STRONG&gt; in human readable time? you aren't actually using those two evals in your subsearch, since you need them in epoch to eval &lt;STRONG&gt;time_diff&lt;/STRONG&gt;. &lt;/P&gt;

&lt;P&gt;have you tried using &lt;CODE&gt;fields&lt;/CODE&gt; instead of &lt;CODE&gt;table&lt;/CODE&gt;?&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;appendcols&lt;/CODE&gt; doesn't join any of the fields together, so if you need &lt;STRONG&gt;EXECUTION_DATE&lt;/STRONG&gt; joined with &lt;STRONG&gt;date&lt;/STRONG&gt;, you might what to use &lt;CODE&gt;join&lt;/CODE&gt;, also, if your subsearch has 5 results and your base search has 1000, there won't be a &lt;STRONG&gt;time_diff&lt;/STRONG&gt; and &lt;STRONG&gt;date&lt;/STRONG&gt; for every line of your base search, just the first 5.&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/6.6.1/SearchReference/Appendcols"&gt;http://docs.splunk.com/Documentation/SplunkCloud/6.6.1/SearchReference/Appendcols&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2017 12:05:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-fields-do-not-appear-in-the-table-command/m-p/324287#M96779</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-09-06T12:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch fields do not appear in the table command..</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-fields-do-not-appear-in-the-table-command/m-p/324288#M96780</link>
      <description>&lt;P&gt;There is no way that this is doing what you think it should; in order to have &lt;CODE&gt;appendcols&lt;/CODE&gt; work, you must take great pains to ensure that both datasets have identical keys with no gaps in the exact same order.  You would be better off showing us sample events from both datasets and explaining &lt;EM&gt;exactly&lt;/EM&gt; what you need to do, including a mockup of the final desired results.&lt;/P&gt;</description>
      <pubDate>Sun, 10 Sep 2017 05:58:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-fields-do-not-appear-in-the-table-command/m-p/324288#M96780</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-09-10T05:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch fields do not appear in the table command..</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-fields-do-not-appear-in-the-table-command/m-p/324289#M96781</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;
As stated above you can not use appencols if you dont have at least one common field with common field values as keys for both rows.&lt;BR /&gt;
For example, if you use appendclos with a common field say name, then ALL the values for name should be present in both the main search and sub search,&lt;BR /&gt;
If name is main search has John, Marry, Suki  and Arsene&lt;BR /&gt;
And the sub search  returns values with John, Marry and Arsene append cols will match the first 2 common values and put the value of Arsene against Suki in the out table.&lt;BR /&gt;
What you need is join - &lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/6.6.1/SearchReference/Join"&gt;http://docs.splunk.com/Documentation/SplunkCloud/6.6.1/SearchReference/Join&lt;/A&gt; &lt;BR /&gt;
refer to the link for the various join types, it will resolve your issue&lt;/P&gt;</description>
      <pubDate>Sun, 10 Sep 2017 09:14:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-fields-do-not-appear-in-the-table-command/m-p/324289#M96781</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2017-09-10T09:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch fields do not appear in the table command..</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-fields-do-not-appear-in-the-table-command/m-p/324290#M96782</link>
      <description>&lt;P&gt;No, using &lt;CODE&gt;join&lt;/CODE&gt; subjects you to a low an inescapable &lt;CODE&gt;subsearch&lt;/CODE&gt; limit, so do everything possible to avoid using it.  See here:&lt;/P&gt;

&lt;P&gt;Who: Nick Mealy, Sideview Apps&lt;BR /&gt;
What: Best practices around grouping and aggregating data from different search results&lt;BR /&gt;
Recording: &lt;A href="https://splunk.webex.com/splunk/lsr.php?RCID=051cba772c9cce79c3eb3718b466233a"&gt;https://splunk.webex.com/splunk/lsr.php?RCID=051cba772c9cce79c3eb3718b466233a&lt;/A&gt;&lt;BR /&gt;
Slides: &lt;A href="http://sideviewapps.com/slides/2017_05_02_sideview_let_stats_sort_them_out.pptx"&gt;http://sideviewapps.com/slides/2017_05_02_sideview_let_stats_sort_them_out.pptx&lt;/A&gt; (Updated several times since the talk and since conf)&lt;BR /&gt;
The version from the first virtual conf is &lt;A href="http://sideviewapps.com/slides/2016_04_15_nick_mealy_grouping_talk.pptx"&gt;http://sideviewapps.com/slides/2016_04_15_nick_mealy_grouping_talk.pptx&lt;/A&gt;&lt;BR /&gt;
flowchart (in progress) : &lt;A href="http://sideviewapps.com/slides/grouping_flowchart_INPROGRESS.png"&gt;http://sideviewapps.com/slides/grouping_flowchart_INPROGRESS.png&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Sep 2017 14:13:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-fields-do-not-appear-in-the-table-command/m-p/324290#M96782</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-09-10T14:13:45Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch fields do not appear in the table command..</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-fields-do-not-appear-in-the-table-command/m-p/324291#M96783</link>
      <description>&lt;P&gt;Your posted code won't work.  I don't know what this will do...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where Bill_run like "%M%"  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;... but it seems like you want this instead...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where like(Bill_run,"%M%")  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;... and you want it as high in the code as that field can be tested, if I have guessed right, that is immediately before the &lt;CODE&gt;stats&lt;/CODE&gt; in your code, but it can be moved (along with the &lt;CODE&gt;rex&lt;/CODE&gt; that extracts it) to right after the searches..&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;Most of the work in the subsearch can be simplified to a single &lt;CODE&gt;stats range()&lt;/CODE&gt;  presumably, the &lt;CODE&gt;date&lt;/CODE&gt; in the subsearch has to be the same as &lt;CODE&gt;EXECUTION_DATE&lt;/CODE&gt;, or there's nothing concrete to connect the two searches.  The resulting code looks something like this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; host="**" source="*BIP*"  NOT source="*BIP98*" NOT source="*BIP99*" 
| eval path=mvindex(split(source,"-"),0) 
| eval thread=mvindex(split(path,"/"),-1) 
| search "BIP CONTROL" 
| search "TASK MODE:      0"  
| rex "MISSING\n\W+\s+\W+\s+\W+\s+\W+\s+\W+\s+\W+\s+\W+\s+\W+\s+\W+\s+\W+\s+\W+\s+\W+\s+\W+\n(?&amp;lt;Bill_run&amp;gt;[^,\s]+)" 
| where like(Bill_run,"%M%")  
| eval EXECUTION_DATE=strftime(strptime(EXECUTION_DATE,"%d %b %Y"),"%Y.%m.%d") 
| rex "TOTAL\s+ACCOUNTS\s+QUEUED:\s+(?&amp;lt;total_accounts&amp;gt;[^,\s]+)" 
| rex "TOTAL\s+SUCCESSFULLY\s+PROCESSED:\s+(?&amp;lt;processed&amp;gt;[^,\s]+)" 
| rex "TOTAL\s+LOCKED/SKIPPED:\s+(?&amp;lt;skipped&amp;gt;[^,\s]+)"
| rex "TOTAL\s+IN\s+ERROR:\s+(?&amp;lt;error&amp;gt;[^,\s]+)" 
| stats sum(total_accounts) as Total_Accounts, 
        sum(processed) as Total_Successful, 
        sum(skipped) as "Total_Skipped", 
        sum(error) as "Total_Error" by Bill_run, EXECUTION_DATE 
| left join EXECUTION_DATE
    [search host="****" sourcetype="kenan_pst" 
    | where source like "%pst_pe_arb_bil_run_bip%"   
    | eval mydate=mvindex(split(mvindex(split(source,"/"),-1),"_"),6)  
    | stats range(_time) as time_diff by source ,mydate 
    | eval EXECUTION_DATE = strftime(strptime(mydate,"formate for mydate"),"%Y.%m.%d") 
    | table time_diff EXECUTION_DATE
    ] 
|  table Bill_run  EXECUTION_DATE Total_Accounts Total_Successful Total_Skipped  Total_Error time_diff 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 10 Sep 2017 20:43:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-fields-do-not-appear-in-the-table-command/m-p/324291#M96783</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-09-10T20:43:47Z</dc:date>
    </item>
  </channel>
</rss>

