<?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 do I join two searches with common field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468513#M131926</link>
    <description>&lt;P&gt;Looks like a parsing problem.  The &lt;CODE&gt;rex&lt;/CODE&gt; command that extracts the duration field is a little off.  Do you have an example event that sets duration to "protocol"?&lt;/P&gt;</description>
    <pubDate>Wed, 03 Jun 2020 17:09:25 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2020-06-03T17:09:25Z</dc:date>
    <item>
      <title>How do I join two searches with common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468502#M131915</link>
      <description>&lt;P&gt;I have one search that checks for entries with duration &amp;gt;= 50000 (responses for requests)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;source="abc.log" | regex "\"duration\" : ([5-9][0-9]{4}|[0-9]{6,})"
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The search returns results with JSON format:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;   ...
  "duration" : 60026,
  "correlationId" : "be225a47972b95f5",
   ... 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I want to show the connected request for that response in the same result set. So I would like to find results where the correlation id matches.&lt;/P&gt;
&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;(source="abc.log" | regex "\"duration\" : ([5-9][0-9]{4}|[0-9]{6,})" | eval correlationId)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;OR&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;(source="abc.log" | correlationId)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The second part of the "OR" statement would return the requests that ended up with 50s+ response time. &lt;BR /&gt;Could anyone help me with the syntax to achieve this?&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 17:51:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468502#M131915</guid>
      <dc:creator>ellstream44</dc:creator>
      <dc:date>2020-06-08T17:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I join two searches with common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468503#M131916</link>
      <description>&lt;P&gt;This may work for you.  It uses &lt;CODE&gt;rex&lt;/CODE&gt; to extract fields from the events rather &lt;CODE&gt;regex&lt;/CODE&gt;, which just filters events.  The &lt;CODE&gt;where&lt;/CODE&gt; command does the filtering.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="abc.log" 
| rex "\"duration\" : (?&amp;lt;duration&amp;gt;\d+)"
| rex "\"correlationId\" : \"(&amp;lt;correlationId&amp;gt;[^\"]+)"
| where duration &amp;gt; 50000
| table correlationId duration
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Jun 2020 16:54:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468503#M131916</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-06-02T16:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: How do I join two searches with common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468504#M131917</link>
      <description>&lt;P&gt;Thanks for the response!&lt;BR /&gt;
The rex for duration and where statement worked great, however for the correlationId part, i get error: &lt;/P&gt;

&lt;P&gt;"Error in 'rex' command: The regex '"correlation" : "([^"]+)' does not extract anything. It should specify at least one named group. Format: (?...)."&lt;/P&gt;

&lt;P&gt;I thought maybe ? was missing, so I tried this:&lt;BR /&gt;
| rex "\"correlationId\" : \"(?[^\"]+)"&lt;/P&gt;

&lt;P&gt;And I got hit for both correlation and duration for example:&lt;BR /&gt;
correlation                 duration &lt;BR /&gt;
c046ed74a4fb38a1   360615&lt;BR /&gt;
b0689d6af87fb231   541538&lt;/P&gt;

&lt;P&gt;However, I would like to see all the entries with a certain correlationId, so I can find out which request resulted in a response with duration 50s+, so i removed the "table" part, and clicked "Event" &lt;/P&gt;

&lt;P&gt;So with this query:&lt;BR /&gt;
source="abc.log" &lt;BR /&gt;
 | rex "\"duration\" : (?\d+)"&lt;BR /&gt;
 | rex "\"correlationId\" : \"(?[^\"]+)"&lt;BR /&gt;
 | where duration &amp;gt; 50000&lt;/P&gt;

&lt;P&gt;I found entries, but only the "response" parts. When I added c046ed74a4fb38a1 to the query above, I found only one entry with that correlationId, but If i searched like this:&lt;/P&gt;

&lt;P&gt;85a54844766753b0&lt;BR /&gt;
source="abc.log"&lt;/P&gt;

&lt;P&gt;I found the two searches, both the request and the response.&lt;/P&gt;

&lt;P&gt;My goal is to have a search where I would have a list of entries, where each entry contains both the request AND the response for when the response was 50+seconds &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 02 Jun 2020 17:50:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468504#M131917</guid>
      <dc:creator>ellstream44</dc:creator>
      <dc:date>2020-06-02T17:50:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do I join two searches with common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468505#M131918</link>
      <description>&lt;P&gt;My apologies for the typo.  I'm glad you figured it out.&lt;/P&gt;

&lt;P&gt;I'm not following what you want to do.  What does "85a54844766753b0" stand for?  What is the difference between a request and a response?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jun 2020 17:58:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468505#M131918</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-06-02T17:58:02Z</dc:date>
    </item>
    <item>
      <title>Re: How do I join two searches with common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468506#M131919</link>
      <description>&lt;P&gt;Sorry for being unclear, an example request with response (entries which i can find with my searches):&lt;BR /&gt;
85a54844766753b0 is a correlationId &lt;/P&gt;

&lt;P&gt;Request entry:&lt;BR /&gt;
2020-06-02 19:06:27,463 INFO com.Logger      {&lt;BR /&gt;
  "origin" : "remote",&lt;BR /&gt;
  "type" : "request",&lt;BR /&gt;
  "correlationId" : "85a54844766753b0",&lt;BR /&gt;
  "protocol" : "HTTP/1.1",&lt;BR /&gt;
  "method" : "PUT",&lt;BR /&gt;
  "uri" : "&lt;A href="http://myuri.net:4949/orders/123456/status"&gt;http://myuri.net:4949/orders/123456/status&lt;/A&gt;",&lt;BR /&gt;
  "body" : {"status":"AUTO_CANCELED"}&lt;BR /&gt;
}&lt;/P&gt;

&lt;P&gt;Response entry:&lt;BR /&gt;
2020-06-02 19:15:28,808 INFO com.Logger {&lt;BR /&gt;
  "origin" : "local",&lt;BR /&gt;
  "type" : "response",&lt;BR /&gt;
  "correlationId" : "85a54844766753b0",&lt;BR /&gt;
  "duration" : 541344,&lt;BR /&gt;
  "protocol" : "HTTP/1.1",&lt;BR /&gt;
  "status" : 204&lt;BR /&gt;
}&lt;/P&gt;

&lt;P&gt;So this is an example where a request with body {"status":"AUTO_CANCELED"} resulted in a response with over 50s response time. This is the information I need to identify which requests are taking a long time to finish since I have some load issues&lt;/P&gt;

&lt;P&gt;So now with this query:&lt;BR /&gt;
source="abc.log" &lt;BR /&gt;
 | rex "\"duration\" : (?\d+)"&lt;BR /&gt;
 | rex "\"correlationId\" : \"(?[^\"]+)"&lt;BR /&gt;
 | where duration &amp;gt; 50000&lt;/P&gt;

&lt;P&gt;I can find entries in the event which have duration &amp;gt; 50000. For each entry in the event list, I would also like to see the connected request (not only response) so that I can figure out which request was sent in this case &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;

&lt;P&gt;What I currently do is that I have to copy the correlationId, make a new search for &lt;BR /&gt;
source="abc.log"&lt;BR /&gt;
\"correlationId\" : \"85a54844766753b0\"&lt;/P&gt;

&lt;P&gt;To be able to see the actual request that resulted in a high duration for the response &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 02 Jun 2020 18:12:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468506#M131919</guid>
      <dc:creator>ellstream44</dc:creator>
      <dc:date>2020-06-02T18:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: How do I join two searches with common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468507#M131920</link>
      <description>&lt;P&gt;I think I understand now.  We need to match up events by correlationId.  There are a few ways to do that, but the best is usually &lt;CODE&gt;stats&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="abc.log"
| rex "\"duration\" : (?\d+)"
| rex "\"correlationId\" : \"(?[^\"]+)"
| stats values(*) as * by correlationId
| where duration &amp;gt; 50000
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Jun 2020 00:15:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468507#M131920</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-06-03T00:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do I join two searches with common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468508#M131921</link>
      <description>&lt;P&gt;I tried:&lt;BR /&gt;
source="abc.log" &lt;BR /&gt;
 | rex "\"duration\" : (?\d+)"&lt;BR /&gt;
 | rex "\"correlationId\" : \"(?[^\"]+)"&lt;BR /&gt;
 | stats values(*) as * by correlationId&lt;BR /&gt;
 | where duration &amp;gt; 50000&lt;/P&gt;

&lt;P&gt;But then I got a hit on every single event&lt;BR /&gt;
It was basically the same search as searching for&lt;BR /&gt;
source="abc.log" &lt;/P&gt;

&lt;P&gt;So I tried to put the "where" statement before the "duration" statement, as such:&lt;BR /&gt;
source="abc.log" &lt;BR /&gt;
 | rex "\"duration\" : (?\d+)"&lt;BR /&gt;
 | rex "\"correlationId\" : \"(?[^\"]+)"&lt;BR /&gt;
 | where duration &amp;gt; 50000&lt;BR /&gt;
 | stats values(*) as * by correlationId&lt;/P&gt;

&lt;P&gt;Now the where statement for duration worked, however even I look at the event tab, I still only find matches for the "response" parts &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; So I do not find the "requests" parts unfortunately. Perhaps this is because the field duration does not exist in the request part?&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 06:09:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468508#M131921</guid>
      <dc:creator>ellstream44</dc:creator>
      <dc:date>2020-06-03T06:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: How do I join two searches with common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468509#M131922</link>
      <description>&lt;P&gt;I intentionally put &lt;CODE&gt;where&lt;/CODE&gt; after &lt;CODE&gt;stats&lt;/CODE&gt; because request events do not have a duration field.  The &lt;CODE&gt;stats&lt;/CODE&gt; command matches up request and response by correlation ID so each resulting event has a duration.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 12:40:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468509#M131922</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-06-03T12:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I join two searches with common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468510#M131923</link>
      <description>&lt;P&gt;Ok but with this:&lt;BR /&gt;
source="abc.log" &lt;BR /&gt;
 | rex "\"duration\" : (?\d+)"&lt;BR /&gt;
 | rex "\"correlationId\" : \"(?[^\"]+)"&lt;BR /&gt;
 | stats values(*) as * by correlationId&lt;BR /&gt;
 | where duration &amp;gt; 50000&lt;/P&gt;

&lt;P&gt;I got hit on every single "response" in the "abc.log"&lt;BR /&gt;
even where duration is 16 etc&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 14:04:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468510#M131923</guid>
      <dc:creator>ellstream44</dc:creator>
      <dc:date>2020-06-03T14:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do I join two searches with common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468511#M131924</link>
      <description>&lt;P&gt;Please use the code (101010) button to format your SPL.&lt;/P&gt;

&lt;P&gt;What do you get using this?  Does the duration field display properly?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="abc.log"
| rex "\"duration\" : (?\d+)"
| rex "\"correlationId\" : \"(?[^\"]+)"
| stats values() as by correlationId
| table correlationID duration
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Jun 2020 14:40:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468511#M131924</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-06-03T14:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I join two searches with common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468512#M131925</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;source="abc.log" 
 | rex "\"duration\" : (?&amp;lt;duration&amp;gt;\d+)"
 | rex "\"correlationId\" : \"(?&amp;lt;correlationId&amp;gt;[^\"]+)"
 | stats values(*) as * by correlationId
 | table correlationId duration
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This query found several hits in the Statistics view, many entries had 1 correlationId and 2 durations&lt;/P&gt;

&lt;P&gt;Example:&lt;/P&gt;

&lt;P&gt;correlationId:    80005e83861c03b7                    &lt;/P&gt;

&lt;P&gt;duration: both "105" and also "protocol"&lt;/P&gt;

&lt;P&gt;I do not know what the protocol part comes from&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 15:18:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468512#M131925</guid>
      <dc:creator>ellstream44</dc:creator>
      <dc:date>2020-06-03T15:18:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I join two searches with common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468513#M131926</link>
      <description>&lt;P&gt;Looks like a parsing problem.  The &lt;CODE&gt;rex&lt;/CODE&gt; command that extracts the duration field is a little off.  Do you have an example event that sets duration to "protocol"?&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 17:09:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468513#M131926</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-06-03T17:09:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do I join two searches with common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468514#M131927</link>
      <description>&lt;P&gt;Seems like it, I get hits for posts that is not containing "duration" at all&lt;/P&gt;

&lt;P&gt;Example:&lt;/P&gt;

&lt;P&gt;2020-06-04 08:41:53,995 INFO com.Logger {&lt;BR /&gt;
  "origin" : "remote",&lt;BR /&gt;
  "type" : "request",&lt;BR /&gt;
  "correlation" : "84e110da7e8b37e6",&lt;BR /&gt;
  "protocol" : "HTTP/1.1",&lt;BR /&gt;
  "method" : "GET",&lt;BR /&gt;
  "uri" : "&lt;A href="http://myuri/orders/30070834"&gt;http://myuri/orders/30070834&lt;/A&gt;",&lt;BR /&gt;
  "body" : ""&lt;BR /&gt;
}&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="/opt/apps/spring-boot/customer-order-data-bowmore-prod/log/communication.log" 
  | rex "\"duration\" : (?&amp;lt;duration&amp;gt;\d+)"
  | rex "\"correlation\" : \"(?&amp;lt;correlation&amp;gt;[^\"]+)"
  | search duration=protocol
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Jun 2020 06:47:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-join-two-searches-with-common-field/m-p/468514#M131927</guid>
      <dc:creator>ellstream44</dc:creator>
      <dc:date>2020-06-04T06:47:03Z</dc:date>
    </item>
  </channel>
</rss>

