<?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 optimize search query with join in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-search-query-with-join/m-p/646759#M223859</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/244605"&gt;@Splunk4&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;as I said, to debug your search you can have two approach: starting by the beginning or by the end.&lt;/P&gt;&lt;P&gt;Starting from the end, you have to remove, one by one, a complete row understanding if there's some blocking command and/or analyzing if there are all the fields, e.g., in your case,&lt;/P&gt;&lt;P&gt;at first delete the last where command to see if it causes the null result,&lt;/P&gt;&lt;P&gt;then you have two following stats command, check if the key of the second is present on the first and what are the values.&lt;/P&gt;&lt;P&gt;Starting from the beginning run the main search (with both the indexes and see if you have all the fields to use in the following commands, especially the BY clauses in stats commands.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
    <pubDate>Tue, 13 Jun 2023 06:30:47 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2023-06-13T06:30:47Z</dc:date>
    <item>
      <title>How to optimize search query with join?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-search-query-with-join/m-p/646434#M223746</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;i am using below query to get the common results on the basis of correlation_id but it is very slow,I need to optimize it to get the proper results&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=kong_fincrimekyc_prod
|rename request.headers.x-int-clientapplication as "client" correlation-id as "correlation_id"
|table Error_Reason,correlation_id,client,upstream_uri|where isnotnull(client)
|join type=outer correlation_id [ search index=fincrimekyc_prod source="prod-ms-vix-adapter" sourcetype=kyc_app_logs "com.nab.ms.vix.adapter.exception.VixExceptionHandler" "ERROR" OR "Exception"
| rex "Caused by(?&amp;lt;Error_Reason&amp;gt;.*?)\\\n"
| rex "correlation_id=\\\"(?&amp;lt;correlation_id&amp;gt;.*?)\\\"\,"|table Error_Reason,correlation_id]
|stats values(Error_Reason) as "Error_Reason" values(client) values(correlation_id) by upstream_uri|where isnotnull(Error_Reason)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help on this&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2023 10:11:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-search-query-with-join/m-p/646434#M223746</guid>
      <dc:creator>Splunk4</dc:creator>
      <dc:date>2023-06-13T10:11:02Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk optimize search query with join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-search-query-with-join/m-p/646436#M223747</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/244605"&gt;@Splunk4&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Splunk isn't a database and al the people (me too in the beginning) that arrive from the traditional IT start using the join command:&lt;BR /&gt;join command must be used only if there isn't any other solution and with searches with few results for performces reasons and because there's the limit of 50,000 results.&lt;/P&gt;&lt;P&gt;Anyway, you could use the stats command to join the two searches using this approach:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=kong_fincrimekyc_prod) OR (index=fincrimekyc_prod source="prod-ms-vix-adapter" sourcetype=kyc_app_logs "com.nab.ms.vix.adapter.exception.VixExceptionHandler" "ERROR" OR "Exception")
| rename request.headers.x-int-clientapplication as "client" correlation-id as "correlation_id"
| rex "Caused by(?&amp;lt;Error_Reason&amp;gt;.*?)\\\n"
| rex "correlation_id=\\\"(?&amp;lt;correlation_id&amp;gt;.*?)\\\"\,"
| stats 
   values(Error_Reason) AS "Error_Reason" 
   values(client) AS client
   values(upstream_uri) AS upstream_uri
   BY correlation_id
| stats 
   values(Error_Reason) AS "Error_Reason" 
   values(client) AS client 
   values(correlation_id) AS correlation_id
   BY upstream_uri
| where isnotnull(Error_Reason)&lt;/LI-CODE&gt;&lt;P&gt;In few words you use the by clouse of stats command to correlate two searches in the main search.&lt;/P&gt;&lt;P&gt;Obviously, I cannot test this search, see my approach and adapt it to your case.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 09:40:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-search-query-with-join/m-p/646436#M223747</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-06-09T09:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk optimize search query with join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-search-query-with-join/m-p/646561#M223803</link>
      <description>&lt;P&gt;i tried the above query but it is not returning any results.Looks like it is not renaming and extracting the fields the fields due to which the last condition is matching for error reason null.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 04:29:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-search-query-with-join/m-p/646561#M223803</guid>
      <dc:creator>Splunk4</dc:creator>
      <dc:date>2023-06-12T04:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk optimize search query with join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-search-query-with-join/m-p/646563#M223805</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/244605"&gt;@Splunk4&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;as I said, this is am approach, you have to adapt this approach to your data, probably the problem is in the regex to extract correlation_id.&lt;/P&gt;&lt;P&gt;Anyway, debug this search deleting a row from the end to understand where is the issue.&lt;/P&gt;&lt;P&gt;Ciao&amp;nbsp;&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 05:45:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-search-query-with-join/m-p/646563#M223805</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-06-12T05:45:50Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk optimize search query with join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-search-query-with-join/m-p/646745#M223857</link>
      <description>&lt;P&gt;When i am running the search only with one index then the field is getting extracted but it is not getting extracted when running by including the both.Not sure what can be the reason&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2023 04:53:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-search-query-with-join/m-p/646745#M223857</guid>
      <dc:creator>Splunk4</dc:creator>
      <dc:date>2023-06-13T04:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk optimize search query with join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-search-query-with-join/m-p/646759#M223859</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/244605"&gt;@Splunk4&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;as I said, to debug your search you can have two approach: starting by the beginning or by the end.&lt;/P&gt;&lt;P&gt;Starting from the end, you have to remove, one by one, a complete row understanding if there's some blocking command and/or analyzing if there are all the fields, e.g., in your case,&lt;/P&gt;&lt;P&gt;at first delete the last where command to see if it causes the null result,&lt;/P&gt;&lt;P&gt;then you have two following stats command, check if the key of the second is present on the first and what are the values.&lt;/P&gt;&lt;P&gt;Starting from the beginning run the main search (with both the indexes and see if you have all the fields to use in the following commands, especially the BY clauses in stats commands.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2023 06:30:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-search-query-with-join/m-p/646759#M223859</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-06-13T06:30:47Z</dc:date>
    </item>
  </channel>
</rss>

