<?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: How can I append/join the values of sub-search with the main search with the common field in the corresponding row? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-append-join-the-values-of-sub-search-with-the-main/m-p/414112#M119322</link>
    <description>&lt;P&gt;@renjith.nair Awesome!! It works like a charm.. Thank you!!&lt;BR /&gt;
Curious to know if it can be attained using join/append command?&lt;/P&gt;</description>
    <pubDate>Fri, 30 Nov 2018 02:37:24 GMT</pubDate>
    <dc:creator>bollam</dc:creator>
    <dc:date>2018-11-30T02:37:24Z</dc:date>
    <item>
      <title>How can I append/join the values of sub-search with the main search with the common field in the corresponding row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-append-join-the-values-of-sub-search-with-the-main/m-p/414110#M119320</link>
      <description>&lt;P&gt;For an instance, I want to calculate the runtime of each stage of two trains and but there are stages which one of the trains do not have.&lt;BR /&gt;
In such case it should be left empty.&lt;/P&gt;

&lt;P&gt;Query which is written:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main
| search train_name="train_1" 
| stats earliest(start) as start_time latest(finish) as finish_time by stage, train_1
| eval difference = (finish_time - start_time)
| eval final_time = tostring(difference, "duration") 
| join stage type=inner 
    [ search index=main 
    | search train_name="train_2" 
    | stats earliest(start) as start_time latest(finish) as finish_time by stage, train_2 
    | eval difference = (finish_time - start_time)
    | eval final_time_train2 = tostring(difference, "duration") 
    | table stage train_2 final_time_train2 ] 
 | table stage train_1 final_time train_2 final_time_train2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;this is skipping the values which are having common, I want all of them to be listed out.&lt;/P&gt;

&lt;P&gt;The output should look like below.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Stage       train_name      runtime_train1_mins      train2_name     runtime_train2_mins
abc        train_1              20                train_2               40                                    
def           train_1              30                 train_2
123           train_1                                 train_2               50
456           train_1              40                 train_2               30
xyz           train_1                                 train_2               25
gee           train_1              55                 train_2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Nov 2018 06:27:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-append-join-the-values-of-sub-search-with-the-main/m-p/414110#M119320</guid>
      <dc:creator>bollam</dc:creator>
      <dc:date>2018-11-29T06:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: How can I append/join the values of sub-search with the main search with the common field in the corresponding row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-append-join-the-values-of-sub-search-with-the-main/m-p/414111#M119321</link>
      <description>&lt;P&gt;@bollam,&lt;/P&gt;

&lt;P&gt;Give this a try without a join &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main (train_name="train_1" OR train_name="train_2")
| stats earliest(start) as start_time latest(finish) as finish_time by stage, train_name
| eval difference = (finish_time - start_time)
| eval final_time = tostring(difference, "duration") 
| stats values(eval(if(train_name="train_1","train_1",null()))) as  train_name,
            values(eval(if(train_name="train_2","train_2",null()))) as  train2_name,
            values(eval(if(train_name="train_1",final_time,null()))) as  runtime_train1_mins,
            values(eval(if(train_name="train_2",final_time,null()))) as  runtime_train2_mins
        by Stage
| fillnull value="train_1" train_name|fillnull value="train_2" train2_name
| table Stage,train_name,runtime_train1_mins,train2_name,runtime_train2_mins    
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Nov 2018 10:12:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-append-join-the-values-of-sub-search-with-the-main/m-p/414111#M119321</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-11-29T10:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: How can I append/join the values of sub-search with the main search with the common field in the corresponding row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-append-join-the-values-of-sub-search-with-the-main/m-p/414112#M119322</link>
      <description>&lt;P&gt;@renjith.nair Awesome!! It works like a charm.. Thank you!!&lt;BR /&gt;
Curious to know if it can be attained using join/append command?&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 02:37:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-append-join-the-values-of-sub-search-with-the-main/m-p/414112#M119322</guid>
      <dc:creator>bollam</dc:creator>
      <dc:date>2018-11-30T02:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: How can I append/join the values of sub-search with the main search with the common field in the corresponding row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-append-join-the-values-of-sub-search-with-the-main/m-p/414113#M119323</link>
      <description>&lt;P&gt;@bollam, should be possible to do with join as well&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main "first set of data"| join Stage type=outer [search index=main "second set of data" ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, join is bit more expensive in terms of resource utilization. So as a thumb rule, we should avoid join wherever possible &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;

&lt;P&gt;Please accept the above answer if it works for you&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 08:21:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-append-join-the-values-of-sub-search-with-the-main/m-p/414113#M119323</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-11-30T08:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: How can I append/join the values of sub-search with the main search with the common field in the corresponding row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-append-join-the-values-of-sub-search-with-the-main/m-p/414114#M119324</link>
      <description>&lt;P&gt;@bollam, do you have any further questions on  this? If not, please accept as answer to close the thread&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 13:39:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-append-join-the-values-of-sub-search-with-the-main/m-p/414114#M119324</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-12-05T13:39:21Z</dc:date>
    </item>
  </channel>
</rss>

