<?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: Alternative solution for join with bad performance in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Alternative-solution-for-join-with-bad-performance/m-p/483377#M135335</link>
    <description>&lt;PRE&gt;&lt;CODE&gt;(index=x 2202) OR (index=y 2203 client 77777) 
| spath "EventStreamData.requestContext.id" output=transaction_number 
| spath "EventStreamData.httpStatus" output=STATUS 
| spath "EventStreamData.response.transactionNumber" output=transaction_number 
| stats count AS "COUNT" by transaction_number STATUS
| eval STATUS_MESSAGE= case(like(STATUS,"2%"), "Success"
    ,like(STATUS,"5%") OR (STATUS==404), "Server Error",like(STATUS,"4%") ,"Client Error" ,true() ,"Other Error") 
| table STATUS_MESSAGE, STATUS, COUNT
| fields STATUS_MESSAGE, STATUS, COUNT
| addcoltotals COUNT
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is this OK?&lt;/P&gt;</description>
    <pubDate>Thu, 27 Feb 2020 11:32:47 GMT</pubDate>
    <dc:creator>to4kawa</dc:creator>
    <dc:date>2020-02-27T11:32:47Z</dc:date>
    <item>
      <title>Alternative solution for join with bad performance</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Alternative-solution-for-join-with-bad-performance/m-p/483375#M135333</link>
      <description>&lt;P&gt;I need to do a search on multiple indexes/events and need to do a join on different fields from both. Below query works but is really slow when there are large number of results. Looking for an alternative solution that can help improve the performance. Thanks!&lt;/P&gt;

&lt;P&gt;index=x  2202&lt;BR /&gt;
| spath "EventStreamData.requestContext.id" &lt;BR /&gt;
| spath "EventStreamData.httpStatus"&lt;BR /&gt;&lt;BR /&gt;
| rename EventStreamData.httpStatus as "STATUS"&lt;BR /&gt;
| rename EventStreamData.requestContext.id as "transaction_number"&lt;BR /&gt;
| fields transaction_number, STATUS&lt;BR /&gt;
|join transaction_number&lt;BR /&gt;
[|search index=y 2203&lt;BR /&gt;
| spath "EventStreamData.requestContext.allRequestHeaders.client{}" &lt;BR /&gt;
| search "EventStreamData.requestContext.allRequestHeaders.client{}"=77777&lt;BR /&gt;
| spath "EventStreamData.response.transactionNumber" &lt;BR /&gt;
| rename EventStreamData.response.transactionNumber as "transaction_number"&lt;BR /&gt;
| fields transaction_number]&lt;BR /&gt;
|  stats  count AS "COUNT" by STATUS         | eval  STATUS_MESSAGE= case(((STATUS==200) OR (STATUS==201)), "Success", ((STATUS==500) OR (STATUS==502) OR (STATUS==504) OR (STATUS==404)), "Server Error",((STATUS==400) OR (STATUS==401) OR (STATUS==403) OR (STATUS==409)), "Client Error")              | table STATUS_MESSAGE, STATUS, COUNT           | addcoltotals  COUNT&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:25:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Alternative-solution-for-join-with-bad-performance/m-p/483375#M135333</guid>
      <dc:creator>amdhindsa</dc:creator>
      <dc:date>2020-09-30T04:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative solution for join with bad performance</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Alternative-solution-for-join-with-bad-performance/m-p/483376#M135334</link>
      <description>&lt;P&gt;I think you'd want to do something like this instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=x 2202) OR (index=y 2203) 
| spath "EventStreamData.requestContext.id" 
| spath "EventStreamData.httpStatus" 
| rename EventStreamData.httpStatus as "STATUS" 
| rename EventStreamData.requestContext.id as "transaction_number" 
| spath "EventStreamData.requestContext.allRequestHeaders.client{}" 
| search "EventStreamData.requestContext.allRequestHeaders.client{}"=77777 
| spath "EventStreamData.response.transactionNumber" 
| rename EventStreamData.response.transactionNumber as "transaction_number" 
| stats count AS "COUNT" values(STATUS) as STATUS by transaction_number 
| eval STATUS_MESSAGE= case(((STATUS==200) OR (STATUS==201)), "Success", ((STATUS==500) OR (STATUS==502) OR (STATUS==504) OR (STATUS==404)), "Server Error",((STATUS==400) OR (STATUS==401) OR (STATUS==403) OR (STATUS==409)), "Client Error") 
| table STATUS_MESSAGE, STATUS, COUNT 
| addcoltotals COUNT
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Kind of hard to tell without sample data from both indexes though.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2020 01:01:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Alternative-solution-for-join-with-bad-performance/m-p/483376#M135334</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2020-02-27T01:01:04Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative solution for join with bad performance</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Alternative-solution-for-join-with-bad-performance/m-p/483377#M135335</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;(index=x 2202) OR (index=y 2203 client 77777) 
| spath "EventStreamData.requestContext.id" output=transaction_number 
| spath "EventStreamData.httpStatus" output=STATUS 
| spath "EventStreamData.response.transactionNumber" output=transaction_number 
| stats count AS "COUNT" by transaction_number STATUS
| eval STATUS_MESSAGE= case(like(STATUS,"2%"), "Success"
    ,like(STATUS,"5%") OR (STATUS==404), "Server Error",like(STATUS,"4%") ,"Client Error" ,true() ,"Other Error") 
| table STATUS_MESSAGE, STATUS, COUNT
| fields STATUS_MESSAGE, STATUS, COUNT
| addcoltotals COUNT
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is this OK?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2020 11:32:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Alternative-solution-for-join-with-bad-performance/m-p/483377#M135335</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-02-27T11:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative solution for join with bad performance</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Alternative-solution-for-join-with-bad-performance/m-p/483378#M135336</link>
      <description>&lt;P&gt;Both of the above queries worked but it was giving response by transaction_number and not the total based on STATUS. &lt;BR /&gt;
Adding - stats count as "COUNT" by STATUS_MESSAGE, STATUS to both returns an expected response. &lt;/P&gt;

&lt;P&gt;Thanks &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/208401"&gt;@masonmorales&lt;/a&gt; and &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/184221"&gt;@to4kawa&lt;/a&gt;.&lt;/P&gt;

&lt;P&gt;Query-&lt;BR /&gt;
(index=x 2202) OR (index=y 2203 client 77777) &lt;BR /&gt;
 | spath "EventStreamData.requestContext.id" output=transaction_number &lt;BR /&gt;
 | spath "EventStreamData.httpStatus" output=STATUS &lt;BR /&gt;
 | spath "EventStreamData.response.transactionNumber" output=transaction_number &lt;BR /&gt;
 | stats count AS "COUNT_BY_TX" by transaction_number STATUS&lt;BR /&gt;
 | eval STATUS_MESSAGE= case(like(STATUS,"2%"), "Success"&lt;BR /&gt;
     ,like(STATUS,"5%") OR (STATUS==404), "Server Error",like(STATUS,"4%") ,"Client Error" ,true() ,"Other Error") &lt;BR /&gt;
 &lt;STRONG&gt;| stats count as "COUNT" by STATUS_MESSAGE, STATUS&lt;/STRONG&gt; &lt;BR /&gt;
 | table STATUS_MESSAGE, STATUS, COUNT&lt;BR /&gt;
 | fields STATUS_MESSAGE, STATUS, COUNT&lt;BR /&gt;
 | addcoltotals COUNT&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:25:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Alternative-solution-for-join-with-bad-performance/m-p/483378#M135336</guid>
      <dc:creator>amdhindsa</dc:creator>
      <dc:date>2020-09-30T04:25:33Z</dc:date>
    </item>
  </channel>
</rss>

