<?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: multiple joins and subsearch question in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/multiple-joins-and-subsearch-question/m-p/430160#M172495</link>
    <description>&lt;P&gt;Hi MuS,&lt;/P&gt;

&lt;P&gt;Thanks for the tip. I have seen that link about that subsearches and I actually referred to it before several times before=) But I am still somewhat stuck on how to convert my query using subsearch/join (which is actually useless now because I am hitting some splunk limit so I am not even getting full data for one day).&lt;/P&gt;

&lt;P&gt;Below is my query so far. I am able to see the 4 columns that I need from eh_event=SIP_RESPONSE and all the RTCP_MESSAGE columns (minus the ones I explicitly dropped). But my data is now just one row with multiple columns instead of being broken down into multiple rows. Do I need to do an mvexpand on each field? ProbIem is I have at least 40 columns from RTCP_MESSAGE alone. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ehop_voip sourcetype=VOIP (eh_event=RTCP_MESSAGE fractionLost&amp;gt;128 callId=*) OR (eh_event=SIP_RESPONSE method=BYE callId=*)
| eval {eh_event}-Time=strftime(_time, "%Y-%m-%d %H:%M:%S")
| foreach * [eval "{eh_event}_&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;"=&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;]
| rex field=senderAddr "xx\.(?&amp;lt;range&amp;gt;\d{1,3})\.\d{1,3}\.\d{1,3}" 
| eval isCC=if(cidrmatch("xx.xx.0.0/16" ,senderAddr),1,0)
| eval isCC2=if(cidrmatch("xx.xx.0.0/16" ,senderAddr),1,0)
| fields RTCP* isCC isCC2 SIP_RESPONSE-Time SIP_RESPONSE_clientAddr  SIP_RESPONSE_serverAddr SIP_RESPONSE_callId
| fields - RTCP_MESSAGE_date* RTCP_MESSAGE_clientName RTCP_MESSAGE_punct RTCP_MESSAGE_source* RTCP_MESSAGE_eh_* RTCP_MESSAGE_eventtype* RTCP_MESSAGE_unix* RTCP_MESSAGE_cName RTCP_MESSAGE_host RTCP_MESSAGE_index _raw _time RTCP_MESSAGE_splunk*
| stats values(*) as *
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I modified my "stats values(&lt;EM&gt;) as *" to "stats values(&lt;/EM&gt;) as * by RTCP_MESSAGE_callId SIP_RESPONSE_callId" but that didn't work. So I tried renaming both RTCP_MESSAGE_callId and SIP_RESPONSE_callId to just "callId" then do the "stats values(*) as * by callId" but I got nothing either.&lt;/P&gt;

&lt;P&gt;What am I doing wrong here? Please help! &lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 23:42:31 GMT</pubDate>
    <dc:creator>mmdacutanan</dc:creator>
    <dc:date>2020-09-29T23:42:31Z</dc:date>
    <item>
      <title>multiple joins and subsearch question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/multiple-joins-and-subsearch-question/m-p/430158#M172493</link>
      <description>&lt;P&gt;I have got 3 queries that I need to join together.&lt;/P&gt;

&lt;P&gt;First query has a subsearch. I used a subsearch because I need to find the records that has a fractionLost &amp;gt; 128 for  eh_event=RTCP_MESSAGE. From that subsearch I collected the callId. I then use the callId to display the SIP records with the same callId AND has a method of BYE. This query works but not the fastest. Don't know of any other way to do this other than a subsearch. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ehop sourcetype=VOIP eh_event=SIP_RESPONSE method=BYE callId=* [ search index=ehop sourcetype=VOIP eh_event=RTCP_MESSAGE fractionLost &amp;gt; 128
| eval {eh_event}-Time=strftime(_time, "%Y-%m-%d %H:%M:%S")
| rex field=senderAddr "xx\.(?&amp;lt;range&amp;gt;\d{1,3})\.\d{1,3}\.\d{1,3}"
| where range &amp;gt;=xx and range &amp;lt;=xxx
| table callId]
| eval SIPTime=strftime(_time, "%Y-%m-%d %H:%M:%S") 
| table SIPTime clientAddr serverAddr callId
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now the query above only gives me the columns for the main search; I want to join the columns of the subsearch as well. So I did a join which basically looks like the subsearch above but with all the columns. The query seems to work, albeit slow:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ehop sourcetype=VOIP eh_event=SIP_RESPONSE method=BYE callId=* latest=-3h@h [ search index=ehop sourcetype=VOIP eh_event=RTCP_MESSAGE fractionLost &amp;gt; 128
    | eval {eh_event}-Time=strftime(_time, "%Y-%m-%d %H:%M:%S")
    | rex field=senderAddr "xx\.(?&amp;lt;range&amp;gt;\d{1,3})\.\d{1,3}\.\d{1,3}"
    | where range &amp;gt;=xxx and range &amp;lt;=xxx
    | table callId]
| eval SIPTime=strftime(_time, "%Y-%m-%d %H:%M:%S") 
| table SIPTime clientAddr serverAddr callId
| join type=left callId  [ search index=ehop sourcetype=VOIP eh_event=RTCP_MESSAGE fractionLost &amp;gt; 128 
    | eval {eh_event}-Time=strftime(_time, "%Y-%m-%d %H:%M:%S")
    | rex field=senderAddr "10\.(?&amp;lt;range&amp;gt;\d{1,3})\.\d{1,3}\.\d{1,3}"
    | where range &amp;gt;=xxx and range &amp;lt;=xxx
    | table *
    | fields - burstDensity burstDuration change_type clientName date* _raw host index punct source sourcetype splunk* eh_* time* tag* eventtype unix_* -callId]

   So now the query above gives me all the columns for both eh_event=SIP_REQUEST and eh_event=RTCP_MESSAGE. BUT I have one more requirement which is to join eh_event=RTP_Tick. Again, I can use the callId to join RTCP_Tick to the rest. This is where I run into issues. I can join RTP_Tick with RTCP_Message just fine (query below) by employing the main search with subsearch technique. 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;BUT how do i join the query below to the query above so that I displaying all SIP_REQUEST, RTP_Tick and RTCP_Message that has the same callId???&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ehop sourcetype=VOIP eh_event=RTP_Tick callId=* [ search index=ehop sourcetype=VOIP eh_event=RTCP_MESSAGE fractionLost &amp;gt; 128 callId=* 
| eval {eh_event}-Time=strftime(_time, "%Y-%m-%d %H:%M:%S")
| rex field=senderAddr "xx\.(?&amp;lt;range&amp;gt;\d{1,3})\.\d{1,3}\.\d{1,3}"
| where range &amp;gt;=xxx and range &amp;lt;=xxxx
| table callId]
| eval {eh_event}-Time=strftime(_time, "%Y-%m-%d %H:%M:%S")
| table *
| fields - clientName date* _raw host index punct source sourcetype splunk* eh_* time* tag* eventtype unix_* -callId _time version
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried to do a second join but that didn't work. I only get SIP_Request and RTP_Message events, nothing shows up for RTP_Tick. ANy suggestion on how I can optimize my queries, please let me know as well. I know that  join/append/subsearches should be last resort but I couldn't see any other way.&lt;/P&gt;

&lt;P&gt;PLease help and thanks in advance!!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:37:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/multiple-joins-and-subsearch-question/m-p/430158#M172493</guid>
      <dc:creator>mmdacutanan</dc:creator>
      <dc:date>2020-09-29T23:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: multiple joins and subsearch question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/multiple-joins-and-subsearch-question/m-p/430159#M172494</link>
      <description>&lt;P&gt;Hi mmdacutanan,&lt;/P&gt;

&lt;P&gt;My advice: forget &lt;CODE&gt;join&lt;/CODE&gt; for reasons!&lt;/P&gt;

&lt;P&gt;Take all you searches and combine to one single base search like :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=ehop sourcetype=VOIP eh_event=RTP_Tick callId=* ( sourcetype=VOIP eh_event=RTCP_MESSAGE fractionLost &amp;gt; 128 callId=* ) ( eh_event=SIP_RESPONSE method=BYE callId=*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and do all needed &lt;CODE&gt;eval&lt;/CODE&gt; or other SPL processing after that. Finally use a &lt;CODE&gt;stats&lt;/CODE&gt; to get the correlation you need.&lt;/P&gt;

&lt;P&gt;See some examples to use &lt;CODE&gt;stats&lt;/CODE&gt; instead &lt;CODE&gt;join&lt;/CODE&gt; here &lt;A href="https://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-join-append-or-use-of-subsearches.html"&gt;https://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-join-append-or-use-of-subsearches.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2019 02:26:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/multiple-joins-and-subsearch-question/m-p/430159#M172494</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2019-03-13T02:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: multiple joins and subsearch question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/multiple-joins-and-subsearch-question/m-p/430160#M172495</link>
      <description>&lt;P&gt;Hi MuS,&lt;/P&gt;

&lt;P&gt;Thanks for the tip. I have seen that link about that subsearches and I actually referred to it before several times before=) But I am still somewhat stuck on how to convert my query using subsearch/join (which is actually useless now because I am hitting some splunk limit so I am not even getting full data for one day).&lt;/P&gt;

&lt;P&gt;Below is my query so far. I am able to see the 4 columns that I need from eh_event=SIP_RESPONSE and all the RTCP_MESSAGE columns (minus the ones I explicitly dropped). But my data is now just one row with multiple columns instead of being broken down into multiple rows. Do I need to do an mvexpand on each field? ProbIem is I have at least 40 columns from RTCP_MESSAGE alone. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ehop_voip sourcetype=VOIP (eh_event=RTCP_MESSAGE fractionLost&amp;gt;128 callId=*) OR (eh_event=SIP_RESPONSE method=BYE callId=*)
| eval {eh_event}-Time=strftime(_time, "%Y-%m-%d %H:%M:%S")
| foreach * [eval "{eh_event}_&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;"=&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;]
| rex field=senderAddr "xx\.(?&amp;lt;range&amp;gt;\d{1,3})\.\d{1,3}\.\d{1,3}" 
| eval isCC=if(cidrmatch("xx.xx.0.0/16" ,senderAddr),1,0)
| eval isCC2=if(cidrmatch("xx.xx.0.0/16" ,senderAddr),1,0)
| fields RTCP* isCC isCC2 SIP_RESPONSE-Time SIP_RESPONSE_clientAddr  SIP_RESPONSE_serverAddr SIP_RESPONSE_callId
| fields - RTCP_MESSAGE_date* RTCP_MESSAGE_clientName RTCP_MESSAGE_punct RTCP_MESSAGE_source* RTCP_MESSAGE_eh_* RTCP_MESSAGE_eventtype* RTCP_MESSAGE_unix* RTCP_MESSAGE_cName RTCP_MESSAGE_host RTCP_MESSAGE_index _raw _time RTCP_MESSAGE_splunk*
| stats values(*) as *
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I modified my "stats values(&lt;EM&gt;) as *" to "stats values(&lt;/EM&gt;) as * by RTCP_MESSAGE_callId SIP_RESPONSE_callId" but that didn't work. So I tried renaming both RTCP_MESSAGE_callId and SIP_RESPONSE_callId to just "callId" then do the "stats values(*) as * by callId" but I got nothing either.&lt;/P&gt;

&lt;P&gt;What am I doing wrong here? Please help! &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:42:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/multiple-joins-and-subsearch-question/m-p/430160#M172495</guid>
      <dc:creator>mmdacutanan</dc:creator>
      <dc:date>2020-09-29T23:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: multiple joins and subsearch question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/multiple-joins-and-subsearch-question/m-p/430161#M172496</link>
      <description>&lt;P&gt;Sounds like you are missing some unique identifier that is common to all events. If you don't have one you can create one like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval joiner=case(isnotnull(field1), field1, isnotnull(field2), field2, 1=1, "unknown")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;once you have done this you can use a final &lt;CODE&gt;stats values(*) AS * by joiner&lt;/CODE&gt; for example.&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2019 02:17:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/multiple-joins-and-subsearch-question/m-p/430161#M172496</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2019-03-15T02:17:26Z</dc:date>
    </item>
  </channel>
</rss>

