<?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 join two searches on a common field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-two-searches-on-a-common-field/m-p/209391#M61214</link>
    <description>&lt;P&gt;Another alternative&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | table _raw | extract kvdelim=":" pairdelim=", " | stats values(doYouBowl) as doYouBowl by pin | where mvcount(doYouBowl)=2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 22 Sep 2016 17:29:40 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2016-09-22T17:29:40Z</dc:date>
    <item>
      <title>How can I join two searches on a common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-two-searches-on-a-common-field/m-p/209384#M61207</link>
      <description>&lt;P&gt;This is my sample logs in  &lt;STRONG&gt;[bowlers]&lt;/STRONG&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"doYouBowl":"YES", "pin":"123", "name":"Billy"
"doYouBowl":"NO", "pin":"456", "name":"Bob"
"doYouBowl":"NO", "pin":"123", "name":"Mike"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Expected results is that the "pin" number must match and the resulting join results will be:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"doYouBowl":"YES", "pin":"123", "name":"Billy"
"doYouBowl":"NO", "pin":"123", "name":"Mike"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is what I came up with by researching, but I get an error at 121-ish, where I try to join on pin and the second search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; sourcetype="bowlers" \"doYouBowl\":\"NO\" | rex field=_raw "\"(?&amp;lt;pin&amp;gt;\d+)\"" | join pin [\"doYouBowl\":\"YES\" | rex field=_raw "\"(?&amp;lt;pin&amp;gt;\d+)\""]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Looking at the answers here, got suggestions to use transactions or (translate?), but want to get this join to work first and foremost.&lt;BR /&gt;
Any assistance would be appreciated.&lt;/P&gt;

&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 03:54:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-two-searches-on-a-common-field/m-p/209384#M61207</guid>
      <dc:creator>AverageMale</dc:creator>
      <dc:date>2016-09-22T03:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: How can I join two searches on a common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-two-searches-on-a-common-field/m-p/209385#M61208</link>
      <description>&lt;P&gt;Try making "pin" the field on all of it at once.  No "join" is needed at that point, instead you can use a stats, transaction or other method to group them.  Which is best all depends on what you are trying to do.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; sourcetype="bowlers"  | rex field=_raw "\"pin\":\"(?&amp;lt;pin&amp;gt;\d+)\"" | stats count by pin
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You could transaction on pin, too, which would group the events a different way.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; sourcetype="bowlers"  | rex field=_raw "\"pin\":\"(?&amp;lt;pin&amp;gt;\d+)\"" | transaction maxspan=1d pin
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Adjust your maxspan to be "long enough" but no longer.&lt;/P&gt;

&lt;P&gt;You'll notice my rex "pins" the field so it'll look for the string "pin:" and the digits after that will be used as the field &lt;CODE&gt;pin&lt;/CODE&gt;. This should make it more reliable in case you get other digits somewhere.&lt;/P&gt;

&lt;P&gt;Ask if you need more, otherwise great question, thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 11:41:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-two-searches-on-a-common-field/m-p/209385#M61208</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2016-09-22T11:41:08Z</dc:date>
    </item>
    <item>
      <title>Re: How can I join two searches on a common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-two-searches-on-a-common-field/m-p/209386#M61209</link>
      <description>&lt;P&gt;Hi Rich7177,&lt;/P&gt;

&lt;P&gt;Sorry, I didn't emphasize on the major criteria that the query is to find all cases where records exists that have the same "pin" but different values for "doYouBowl"?  This is why I wanted to use the join operation.&lt;/P&gt;

&lt;P&gt;I tried your solutions the query just looked for where the row contained "pin" and reported stats on it regardless if  "doYouBowl" had same or different values.&lt;/P&gt;

&lt;P&gt;Any ideas?&lt;BR /&gt;
Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 16:02:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-two-searches-on-a-common-field/m-p/209386#M61209</guid>
      <dc:creator>AverageMale</dc:creator>
      <dc:date>2016-09-22T16:02:12Z</dc:date>
    </item>
    <item>
      <title>Re: How can I join two searches on a common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-two-searches-on-a-common-field/m-p/209387#M61210</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="bowlers"  | rex field=_raw "\"pin\":\"(?&amp;lt;pin&amp;gt;\d+)\"" | rex "(?&amp;lt;bowl&amp;gt;YES|NO)"  | rex field=_raw "\"name\":\"(?&amp;lt;name&amp;gt;\w+)\"" | stats values(bowl) as doYouBowl values(name) as bowlers by pin | where mvcount(doYouBowl )=2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;*&lt;STRONG&gt;&lt;EM&gt;UPDATED&lt;/EM&gt;&lt;/STRONG&gt;*&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; sourcetype="bowlers"  | rex field=_raw "\"pin\":\"(?&amp;lt;pin&amp;gt;\d+)\"" | rex "(?&amp;lt;bowl&amp;gt;YES|NO)"  | rex field=_raw "\"name\":\"(?&amp;lt;name&amp;gt;\w+)\"" | eventstats values(bowl) as doYouBowl by pin | where mvcount(doYouBowl)=2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Sep 2016 16:09:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-two-searches-on-a-common-field/m-p/209387#M61210</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-09-22T16:09:34Z</dc:date>
    </item>
    <item>
      <title>Re: How can I join two searches on a common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-two-searches-on-a-common-field/m-p/209388#M61211</link>
      <description>&lt;P&gt;This appears to find the occurrences I am looking for but I have to drill down against each pin to confirm as the returned results are noted as:&lt;/P&gt;

&lt;P&gt;1234567  NO/YES&lt;BR /&gt;
5445435  NO/YES&lt;BR /&gt;
...&lt;BR /&gt;
...&lt;/P&gt;

&lt;P&gt;Rather than the actual expected results noted in my original post:&lt;/P&gt;

&lt;P&gt;"doYouBowl":"YES", "pin":"1234567", "name":"Billy"&lt;BR /&gt;
 "doYouBowl":"NO", "pin":"1234567", "name":"Mike"&lt;/P&gt;

&lt;P&gt;Is there a way to get this results?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 16:52:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-two-searches-on-a-common-field/m-p/209388#M61211</guid>
      <dc:creator>AverageMale</dc:creator>
      <dc:date>2016-09-22T16:52:28Z</dc:date>
    </item>
    <item>
      <title>Re: How can I join two searches on a common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-two-searches-on-a-common-field/m-p/209389#M61212</link>
      <description>&lt;P&gt;See updated query&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 17:02:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-two-searches-on-a-common-field/m-p/209389#M61212</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-09-22T17:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: How can I join two searches on a common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-two-searches-on-a-common-field/m-p/209390#M61213</link>
      <description>&lt;P&gt;Your last update seems to have done the trick! Thank you so much!&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 17:26:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-two-searches-on-a-common-field/m-p/209390#M61213</guid>
      <dc:creator>AverageMale</dc:creator>
      <dc:date>2016-09-22T17:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: How can I join two searches on a common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-two-searches-on-a-common-field/m-p/209391#M61214</link>
      <description>&lt;P&gt;Another alternative&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | table _raw | extract kvdelim=":" pairdelim=", " | stats values(doYouBowl) as doYouBowl by pin | where mvcount(doYouBowl)=2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Sep 2016 17:29:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-two-searches-on-a-common-field/m-p/209391#M61214</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-09-22T17:29:40Z</dc:date>
    </item>
  </channel>
</rss>

