<?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: Splunk query to join two searches in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-query-to-join-two-searches/m-p/525949#M148443</link>
    <description>&lt;P&gt;Would help to see like a single record Json of each source type;&amp;nbsp; This goes back to the one .conf talk; I have done this a lot us stats as stated.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Here is how I would go about it;&amp;nbsp; search verbose to try an get to a single record of source you are looking to join.&amp;nbsp; I am making some assumption based on your search as posted.&lt;BR /&gt;&lt;BR /&gt;Here is how i do this;&amp;nbsp; Iterative;&amp;nbsp; write it one line at a time;&amp;nbsp; Focus on getting a sample of 2 records to join;&amp;nbsp; (Hint don't use Join;&amp;nbsp; It was 2018 before I learned to do this; as I was stuck in SQL Mindset;&amp;nbsp; It took me a long time to deprogram myself from this bad habit)&lt;BR /&gt;&lt;BR /&gt;1.&amp;nbsp; Write a single search to show two records to join;&amp;nbsp;&lt;BR /&gt;I am assuming you are not masking your intended search and index, and NOT somefield 1 2 is common across both searches:&lt;BR /&gt;&lt;BR /&gt;2.&amp;nbsp; where (isnotnull)&amp;nbsp;&amp;nbsp; I have found just say Field=*&amp;nbsp;&amp;nbsp; (that removes any null records from the results.&amp;nbsp; Less results is more;&amp;nbsp; the more explicit to write the search better&amp;nbsp; (time, index, sourcetype, host, etc)&amp;nbsp; just don't wildcard a field=*&amp;lt;something&amp;gt; has to end with star for performance&amp;nbsp; field=&amp;lt;something&amp;gt;* or just field=* (not null)&lt;BR /&gt;&lt;BR /&gt;(index=xxxml ((source=module "matrix-v4" NOT host="xyz.dmz" "&amp;lt;nt3:overall-outcome&amp;gt;*&amp;lt;/nt3:overall-outcome&amp;gt;" AccuiteCode=* ) OR (source="/var/log/production.log" urlPath="/com/system*" "/org/system" accessCode=*)) NOT "somefield1" NOT "somefield2")&lt;BR /&gt;&lt;BR /&gt;3.&amp;nbsp; you then are defining a sourc1 / 2 variable unique to the source type:&amp;nbsp; (something like this would work)&lt;BR /&gt;&lt;BR /&gt;| eval sourceA=if(match(source,"module"), "MS", if(match(source,"/var/log/production.log"), "Prod", "Invalid"))&lt;BR /&gt;&lt;BR /&gt;4.&amp;nbsp; What fields do you need to pass through for calculation:&amp;nbsp; use stats&lt;BR /&gt;&lt;BR /&gt;I use the following all the time&amp;nbsp;&amp;nbsp; (vaules(field) as field,&amp;nbsp; earliest(field) as field, first(field) as field, latest(field) as field, last(field) as field.&lt;BR /&gt;&lt;BR /&gt;Also if you have the same field in different sourcetypes&amp;nbsp;&amp;nbsp; you can do stuff to match in a stats.&amp;nbsp; I do this one all the time;&amp;nbsp; stats count(eval(match(sourcetype, "abc"))) as count_abc, etc.&amp;nbsp; I think can&amp;nbsp;&amp;nbsp; stats (values(eval(match(sourcetype,"abc"))) as&lt;BR /&gt;&lt;BR /&gt;I am not sure what all fields you need to pass through I believe the nt3 only is in the first source:&lt;BR /&gt;&lt;BR /&gt;values is needed when only one of the two sources will have the data point&lt;BR /&gt;&lt;BR /&gt;| stats values(nt3:overall-outcome) as nt3:overall-outcome, valuest(Latency) as latency by date_mday,date_month,rIdentifier,accessCode&lt;BR /&gt;&lt;BR /&gt;5&amp;gt; add the response time&lt;BR /&gt;&lt;BR /&gt;| eval responsetime = Latency/1000&lt;BR /&gt;&lt;BR /&gt;6.&amp;nbsp;&amp;nbsp; final calculation&lt;BR /&gt;&lt;BR /&gt;| stats count(responsetime) as Requests avg(responsetime) perc50(responsetime) perc60(responsetime) perc70(responsetime) perc80(responsetime) perc90(responsetime) perc95(responsetime) perc99(responsetime) max(responsetime) by date_mday,date_month,rIdentifier,nt3:overall-outcome,accessCode&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;7:&amp;nbsp; put it all together.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Oct 2020 03:27:21 GMT</pubDate>
    <dc:creator>kennetkline</dc:creator>
    <dc:date>2020-10-22T03:27:21Z</dc:date>
    <item>
      <title>Splunk query to join two searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-query-to-join-two-searches/m-p/525290#M148217</link>
      <description>&lt;P&gt;Hi Splunkers,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a complex query to extract the IDs from first search and join it using that to the second search and then calculate the response times&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;index=xxxml source=module "matrix-v4" NOT host="xyz.dmz" NOT "somefield1" NOT "somefield2" "&amp;lt;nt3:overall-outcome&amp;gt;*&amp;lt;/nt3:overall-outcome&amp;gt;" |where isnotnull(AccuiteCode) |xmlkv | eval MSUserid=AccessCode | eval source1="MS" | join ip [search index=xxxml source="/var/log/production.log" urlPath="/com/system*" "/org/system" NOT "somefield1" NOT "somefield2" | where isnotnull(accessCode) | eval ProdUserID=accessCode| eval source2="Prod"] | where source1="MS" AND source2="Prod" | eval responsetime = Latency/1000 | stats count(responsetime) as Requests avg(responsetime) perc50(responsetime) perc60(responsetime) perc70(responsetime) perc80(responsetime) perc90(responsetime) perc95(responsetime) perc99(responsetime) max(responsetime) by date_mday,date_month,rIdentifier,nt3:overall-outcome,accessCode&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This query only returns the first matched content but we have thousands to rows for the first query. It somehow unable to join it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Kindly advise.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Amit&lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2020 06:13:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-query-to-join-two-searches/m-p/525290#M148217</guid>
      <dc:creator>asharmaeqfx</dc:creator>
      <dc:date>2020-10-19T06:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk query to join two searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-query-to-join-two-searches/m-p/525380#M148249</link>
      <description>&lt;P&gt;can you try using transforming command (like stats, timechart or chart) before performing join&amp;nbsp;&lt;/P&gt;&lt;P&gt;make sure you have "ip" field available in subsearch and try to remove duplicates. when join is used as subsearch&amp;nbsp; in SPL, it has 50000 limitation on results it can return . if you can take only distinct results this would improve search and give you expected results otherwise you will end up seeing partial results.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2020 14:22:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-query-to-join-two-searches/m-p/525380#M148249</guid>
      <dc:creator>thambisetty</dc:creator>
      <dc:date>2020-10-19T14:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk query to join two searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-query-to-join-two-searches/m-p/525941#M148438</link>
      <description>&lt;P&gt;Does not helps much. Can you suggest like how to perform join in normal scenario.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Oct 2020 00:39:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-query-to-join-two-searches/m-p/525941#M148438</guid>
      <dc:creator>asharmaeqfx</dc:creator>
      <dc:date>2020-10-22T00:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk query to join two searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-query-to-join-two-searches/m-p/525949#M148443</link>
      <description>&lt;P&gt;Would help to see like a single record Json of each source type;&amp;nbsp; This goes back to the one .conf talk; I have done this a lot us stats as stated.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Here is how I would go about it;&amp;nbsp; search verbose to try an get to a single record of source you are looking to join.&amp;nbsp; I am making some assumption based on your search as posted.&lt;BR /&gt;&lt;BR /&gt;Here is how i do this;&amp;nbsp; Iterative;&amp;nbsp; write it one line at a time;&amp;nbsp; Focus on getting a sample of 2 records to join;&amp;nbsp; (Hint don't use Join;&amp;nbsp; It was 2018 before I learned to do this; as I was stuck in SQL Mindset;&amp;nbsp; It took me a long time to deprogram myself from this bad habit)&lt;BR /&gt;&lt;BR /&gt;1.&amp;nbsp; Write a single search to show two records to join;&amp;nbsp;&lt;BR /&gt;I am assuming you are not masking your intended search and index, and NOT somefield 1 2 is common across both searches:&lt;BR /&gt;&lt;BR /&gt;2.&amp;nbsp; where (isnotnull)&amp;nbsp;&amp;nbsp; I have found just say Field=*&amp;nbsp;&amp;nbsp; (that removes any null records from the results.&amp;nbsp; Less results is more;&amp;nbsp; the more explicit to write the search better&amp;nbsp; (time, index, sourcetype, host, etc)&amp;nbsp; just don't wildcard a field=*&amp;lt;something&amp;gt; has to end with star for performance&amp;nbsp; field=&amp;lt;something&amp;gt;* or just field=* (not null)&lt;BR /&gt;&lt;BR /&gt;(index=xxxml ((source=module "matrix-v4" NOT host="xyz.dmz" "&amp;lt;nt3:overall-outcome&amp;gt;*&amp;lt;/nt3:overall-outcome&amp;gt;" AccuiteCode=* ) OR (source="/var/log/production.log" urlPath="/com/system*" "/org/system" accessCode=*)) NOT "somefield1" NOT "somefield2")&lt;BR /&gt;&lt;BR /&gt;3.&amp;nbsp; you then are defining a sourc1 / 2 variable unique to the source type:&amp;nbsp; (something like this would work)&lt;BR /&gt;&lt;BR /&gt;| eval sourceA=if(match(source,"module"), "MS", if(match(source,"/var/log/production.log"), "Prod", "Invalid"))&lt;BR /&gt;&lt;BR /&gt;4.&amp;nbsp; What fields do you need to pass through for calculation:&amp;nbsp; use stats&lt;BR /&gt;&lt;BR /&gt;I use the following all the time&amp;nbsp;&amp;nbsp; (vaules(field) as field,&amp;nbsp; earliest(field) as field, first(field) as field, latest(field) as field, last(field) as field.&lt;BR /&gt;&lt;BR /&gt;Also if you have the same field in different sourcetypes&amp;nbsp;&amp;nbsp; you can do stuff to match in a stats.&amp;nbsp; I do this one all the time;&amp;nbsp; stats count(eval(match(sourcetype, "abc"))) as count_abc, etc.&amp;nbsp; I think can&amp;nbsp;&amp;nbsp; stats (values(eval(match(sourcetype,"abc"))) as&lt;BR /&gt;&lt;BR /&gt;I am not sure what all fields you need to pass through I believe the nt3 only is in the first source:&lt;BR /&gt;&lt;BR /&gt;values is needed when only one of the two sources will have the data point&lt;BR /&gt;&lt;BR /&gt;| stats values(nt3:overall-outcome) as nt3:overall-outcome, valuest(Latency) as latency by date_mday,date_month,rIdentifier,accessCode&lt;BR /&gt;&lt;BR /&gt;5&amp;gt; add the response time&lt;BR /&gt;&lt;BR /&gt;| eval responsetime = Latency/1000&lt;BR /&gt;&lt;BR /&gt;6.&amp;nbsp;&amp;nbsp; final calculation&lt;BR /&gt;&lt;BR /&gt;| stats count(responsetime) as Requests avg(responsetime) perc50(responsetime) perc60(responsetime) perc70(responsetime) perc80(responsetime) perc90(responsetime) perc95(responsetime) perc99(responsetime) max(responsetime) by date_mday,date_month,rIdentifier,nt3:overall-outcome,accessCode&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;7:&amp;nbsp; put it all together.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Oct 2020 03:27:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-query-to-join-two-searches/m-p/525949#M148443</guid>
      <dc:creator>kennetkline</dc:creator>
      <dc:date>2020-10-22T03:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk query to join two searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-query-to-join-two-searches/m-p/526085#M148490</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;Take a look at this answer&amp;nbsp;&lt;A href="https://community.splunk.com/t5/Splunk-Search/How-to-compare-fields-over-multiple-sourcetypes-without-join/m-p/113477" target="_blank"&gt;https://community.splunk.com/t5/Splunk-Search/How-to-compare-fields-over-multiple-sourcetypes-without-join/m-p/113477&lt;/A&gt;&amp;nbsp;it provides examples how it can be done. Basically get a common field over all events and use stats to do the final calculations.&lt;/P&gt;&lt;P&gt;Hope this helps ...&lt;/P&gt;&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Thu, 22 Oct 2020 18:50:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-query-to-join-two-searches/m-p/526085#M148490</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2020-10-22T18:50:00Z</dc:date>
    </item>
  </channel>
</rss>

