<?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 to join two searches? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches/m-p/435022#M124076</link>
    <description>&lt;P&gt;I've updated the answer to reflect your additional data.&lt;/P&gt;</description>
    <pubDate>Fri, 21 Jun 2019 15:43:54 GMT</pubDate>
    <dc:creator>jnudell_2</dc:creator>
    <dc:date>2019-06-21T15:43:54Z</dc:date>
    <item>
      <title>How to join two searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches/m-p/435013#M124067</link>
      <description>&lt;P&gt;First search: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=A source="FunctionHandler@*" "ul-ctx-caller-span-id"=null
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;With this search, I can get several row data with different methods in the field ul-log-data.method, so the table will be:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ul-ctx-head-span-id | ul-log-data.method
------------A-----------|---------------1-------------
------------B-----------|---------------2-------------
------------C-----------|---------------3-------------
------------D-----------|---------------2-------------        
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Second search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=A source="FunctionHandler@*" "ul-ctx-caller-span-id"!=null ul-ctx-head-span-id=1-5D0A0438-736C50A33B81102B75CBA44D
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;With the field "ul-ctx-head-span-id", second search will return 2 row data with different ul-log-data.function, ul-span-duration, so the table will be:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ul-ctx-head-span-id | ul-log-data.function|ul-span-duration
------------A-----------|---------------get------------- |--------xx-----------
------------A-----------|---------------post--------------|--------xx---------
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please note: the second search depends on the field "ul-ctx-head-span-id" in the result of first search.&lt;/P&gt;

&lt;P&gt;Finally, I want get a table like below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ul-ctx-head-span-id | ul-log-data.method | ul-log-data.function|ul-span-duration
------------A-----------|---------------1-------------|-----------get------------ |--------xx-----------
------------A-----------|---------------1-------------|-----------post---------- |--------xx----------
------------B-----------|---------------2-------------|-----------get------------ |--------xx-----------
------------B-----------|---------------2-------------|-----------post---------- |--------xx----------
------------C-----------|---------------3-------------|-----------get------------ |--------xx-----------
------------C-----------|---------------3-------------|-----------post---------- |--------xx----------
------------D-----------|---------------2-------------|-----------get------------ |--------xx-----------
------------D-----------|---------------2-------------|-----------post---------- |--------xx----------
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It means if I get 4 row data in first search, then after join, I need show 8 row data&lt;/P&gt;

&lt;P&gt;Forgive my poor English, can someone help on this? &lt;BR /&gt;
Thanks in advance&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 15:53:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches/m-p/435013#M124067</guid>
      <dc:creator>jerrytao</dc:creator>
      <dc:date>2019-06-19T15:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches/m-p/435014#M124068</link>
      <description>&lt;P&gt;Hi @jerrytao ,&lt;/P&gt;

&lt;P&gt;The easiest way to do this would be to use a join command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=cosv2 ul-ctx-source=c4rupgrd source="FunctionHandler@*" "ul-ctx-caller-span-id"!=null "ul-log-data.function"="GetRemainingAsync" OR "ul-log-data.http_url"="https://string/validatetoken"
| join ul-ctx-head-span-id 
   [ search index=cosv2 ul-ctx-source=c4rupgrd source="FunctionHandler@*" "ul-ctx-caller-span-id"=null "ul-log-data.http_url"!="*/health" "ul-log-data.http_url" IN ("https://string/queries*", "https://string/jobs*") ]
| rename ul-log-data.* as *
| replace ... put your replace stuff here ...        
| eval function = tostring(function) . "___" . tostring(http_url)
| table _time ul-ctx-head-span-id http_url function ul-span-duration
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Try that and see if you get the results you're looking for.&lt;/P&gt;

&lt;P&gt;Edit: Another way to accomplish this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=cosv2 ul-ctx-source=c4rupgrd source="FunctionHandler@*")  ( ("ul-ctx-caller-span-id"=null) OR ("ul-ctx-caller-span-id"!=null "ul-log-data.method"="*") )
| eval func_dur = 'ul-log-data.function' . "|" . 'ul-span-duration'
| stats values(ul-log-data.method) as ul-log-data.method values(func_dur) as func_dur by ul-ctx-head-span-id
| mvexpand func_dur
| eval ul-log-data.function = mvindex(split(func_dur, "|"), 0), ul-span-duration = mvindex(split(func_dur, "|"), 1)
| table ul-ctx-head-span-id ul-log-data.method ul-log-data.function ul-span-duration
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Jun 2019 17:15:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches/m-p/435014#M124068</guid>
      <dc:creator>jnudell_2</dc:creator>
      <dc:date>2019-06-19T17:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches/m-p/435015#M124069</link>
      <description>&lt;P&gt;Hi @jnudell_2 , thanks for help, unfortunately, it doesn't work as my expectation.&lt;BR /&gt;
In my example, I need show 8 rows if first search returns 4 rows, but with your command, it only returns 4 rows whose ul-log-data.function is "get".&lt;BR /&gt;
I update the request to make it much clearer, could you help to take a look? Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2019 15:49:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches/m-p/435015#M124069</guid>
      <dc:creator>jerrytao</dc:creator>
      <dc:date>2019-06-20T15:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches/m-p/435016#M124070</link>
      <description>&lt;P&gt;Can you provide some sample data in non-formatted view (raw json)?  If I had some sample data, I could put something together for you.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2019 16:02:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches/m-p/435016#M124070</guid>
      <dc:creator>jnudell_2</dc:creator>
      <dc:date>2019-06-20T16:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches/m-p/435017#M124071</link>
      <description>&lt;P&gt;Sorry, the join was wrong also... I have updated it above.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2019 16:28:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches/m-p/435017#M124071</guid>
      <dc:creator>jnudell_2</dc:creator>
      <dc:date>2019-06-20T16:28:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches/m-p/435018#M124072</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/186296"&gt;@jnudell_2&lt;/a&gt; , thanks for your quick response! &lt;BR /&gt;
Actually, there are other filter rules in ul-log-data, so I simplified the description in the post. But I don't know how to process your command with other filters.&lt;BR /&gt;
So I attached new screenshot with 2 single search results, hopes it can help to make the problem clearer. And I hided some private information, sorry for this.&lt;/P&gt;

&lt;P&gt;The final table I want is as below:&lt;BR /&gt;
_time | ul-ctx-head-span-id | http_url | duration | function | ul-span-duration&lt;/P&gt;

&lt;P&gt;And for the second search, do you have better way to combine the function? as the original result is &lt;BR /&gt;
id | function1 | function2&lt;BR /&gt;
--A-- GetRemainingAsync---(null)--&lt;BR /&gt;
--A--------(null)----|------outgoing-----&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:01:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches/m-p/435018#M124072</guid>
      <dc:creator>jerrytao</dc:creator>
      <dc:date>2020-09-30T01:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches/m-p/435019#M124073</link>
      <description>&lt;P&gt;@jerrytao  Try below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=cosv2 ul-ctx-source=c4rupgrd source="FunctionHandler@*" "ul-ctx-caller-span-id"!=null ul-ctx-head-span-id=1-5D0A0438-736C50A33B81102B75CBA44D | join ul-ctx-head-span-id [search index=cosv2 ul-ctx-source=c4rupgrd source="FunctionHandler@*" "ul-ctx-caller-span-id"=null| fields ul-ctx-caller-span-id , ul-log-data.method] | table  ul-ctx-head-span-id ul-log-data.method ul-log-data.function ul-span-duration
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Jun 2019 19:27:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches/m-p/435019#M124073</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2019-06-20T19:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches/m-p/435020#M124074</link>
      <description>&lt;P&gt;@Vijeta , I need join the result of second search for every ul-ctx-head-span-id, not only that single one. So I should not see "ul-ctx-head-span-id=1-5D0A0438-736C50A33B81102B75CBA44D". You can refer to newly added screenshot "full.PNG". Thanks for reply.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2019 23:57:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches/m-p/435020#M124074</guid>
      <dc:creator>jerrytao</dc:creator>
      <dc:date>2019-06-20T23:57:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches/m-p/435021#M124075</link>
      <description>&lt;P&gt;Hi @jerrytao,&lt;BR /&gt;
consider your Search1 with table result -&amp;gt; *&lt;STRONG&gt;&lt;EM&gt;A | B&lt;/EM&gt;&lt;/STRONG&gt;* and your Search2 with table result -&amp;gt; &lt;STRONG&gt;A | C | D&lt;/STRONG&gt;, try this below to join table result -&amp;gt; &lt;STRONG&gt;A| B |C |D&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  Search1
     |append[Search2]
     |stats values(B) as B values(C) as C values(D) as D by A
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Jun 2019 15:43:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches/m-p/435021#M124075</guid>
      <dc:creator>marco1987</dc:creator>
      <dc:date>2019-06-21T15:43:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches/m-p/435022#M124076</link>
      <description>&lt;P&gt;I've updated the answer to reflect your additional data.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2019 15:43:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches/m-p/435022#M124076</guid>
      <dc:creator>jnudell_2</dc:creator>
      <dc:date>2019-06-21T15:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches/m-p/435023#M124077</link>
      <description>&lt;P&gt;@jnudell_2 , thank you so much! It works after reverse this 2 searches.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2019 05:44:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches/m-p/435023#M124077</guid>
      <dc:creator>jerrytao</dc:creator>
      <dc:date>2019-06-24T05:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches/m-p/435024#M124078</link>
      <description>&lt;P&gt;Are you using the &lt;CODE&gt;join&lt;/CODE&gt; one or the other one?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2019 17:37:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches/m-p/435024#M124078</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-06-24T17:37:16Z</dc:date>
    </item>
  </channel>
</rss>

