<?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: Need help with query performance improvement in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-query-performance-improvement/m-p/615950#M214036</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/238059"&gt;@username13&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;the transaction command is a very slow command.&lt;/P&gt;&lt;P&gt;if you couple "ThreadId" "host" is unique (if in other words startswith and endswith are additional and not relevant), you could put them in the stats command having a faster search&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=log sourcetype=servlog
| stats earliest(_time) as "first" latest(_time) as "last" count by ThreadId host Type CompleteDescription
| eventstats sum(count) as count_full by Type, CompleteDescription 
| eventstats sum(count_full) as total by Type
| eval percentage = round((count_full/total)*100,0)
| eval time_diff = round((last - first)/60, 0)
| eval CompleteDescription=upper(CompleteDescription) 
| search Type!=SSL (CompleteDescription = "MISSING RESPONSE" OR CompleteDescription = "TIMEOUT" OR CompleteDescription = "TECHNICAL ERROR" OR CompleteDescription = "INTERNAL SYSTEM ERROR" OR CompleteDescription = "NO REACHABILITY") total &amp;gt;= 10 percentage &amp;gt;= 50 time_diff &amp;gt;= 30
| convert ctime(first) ctime(last) 
| table Type, CompleteDescription, count_type, count, percentage 
| sort - percentage, total&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Oct 2022 10:35:54 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2022-10-05T10:35:54Z</dc:date>
    <item>
      <title>Need help with query performance improvement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-query-performance-improvement/m-p/615945#M214034</link>
      <description>&lt;P&gt;Hi guys,&lt;BR /&gt;&lt;BR /&gt;I need to evaluate a disruption.&amp;nbsp; It can last multiple hours, so I need to use data which is at least 4h old. This query needs to show all disruptions that are longer than 15 minutes with it's starting timestamp and it's last occurring timestamp. To group all logged events, I need a transaction which also contains the field CompleteDescription. If this field contains specific values which can be seen in the query, it is a disruption.&lt;BR /&gt;&lt;BR /&gt;The query I've build works so far but is to slow to collect data from multiple hours. Does anyone have an idea how to improve the query for more performance?&lt;BR /&gt;&lt;BR /&gt;Thank you!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;index=log sourcetype=servlog
| transaction ThreadId host maxspan=180s startswith=(LogMessage=start) endswith=(LogMessage=end) 
| stats earliest(_time) as "first", latest(_time) as "last", count by Type, CompleteDescription
| eventstats sum(count) as count_full by Type, CompleteDescription 
| eventstats sum(count_full) as total by Type
| eval percentage = round((count_full/total)*100,0)
| eval time_diff = round((last - first)/60, 0)
| eval CompleteDescription=upper(CompleteDescription) 
| search Type!=SSL (CompleteDescription = "MISSING RESPONSE" OR CompleteDescription = "TIMEOUT" OR CompleteDescription = "TECHNICAL ERROR" OR CompleteDescription = "INTERNAL SYSTEM ERROR" OR CompleteDescription = "NO REACHABILITY") total &amp;gt;= 10 percentage &amp;gt;= 50 time_diff &amp;gt;= 30
| convert ctime(first) ctime(last) 
| table Type, CompleteDescription, count_type, count, percentage 
| sort - percentage, total&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2022 09:35:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-query-performance-improvement/m-p/615945#M214034</guid>
      <dc:creator>username13</dc:creator>
      <dc:date>2022-10-05T09:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with query performance improvement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-query-performance-improvement/m-p/615950#M214036</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/238059"&gt;@username13&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;the transaction command is a very slow command.&lt;/P&gt;&lt;P&gt;if you couple "ThreadId" "host" is unique (if in other words startswith and endswith are additional and not relevant), you could put them in the stats command having a faster search&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=log sourcetype=servlog
| stats earliest(_time) as "first" latest(_time) as "last" count by ThreadId host Type CompleteDescription
| eventstats sum(count) as count_full by Type, CompleteDescription 
| eventstats sum(count_full) as total by Type
| eval percentage = round((count_full/total)*100,0)
| eval time_diff = round((last - first)/60, 0)
| eval CompleteDescription=upper(CompleteDescription) 
| search Type!=SSL (CompleteDescription = "MISSING RESPONSE" OR CompleteDescription = "TIMEOUT" OR CompleteDescription = "TECHNICAL ERROR" OR CompleteDescription = "INTERNAL SYSTEM ERROR" OR CompleteDescription = "NO REACHABILITY") total &amp;gt;= 10 percentage &amp;gt;= 50 time_diff &amp;gt;= 30
| convert ctime(first) ctime(last) 
| table Type, CompleteDescription, count_type, count, percentage 
| sort - percentage, total&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2022 10:35:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-query-performance-improvement/m-p/615950#M214036</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-10-05T10:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with query performance improvement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-query-performance-improvement/m-p/615972#M214049</link>
      <description>&lt;P&gt;Hi Giuseppe,&lt;BR /&gt;&lt;BR /&gt;thank you very much for your help. Unfortunately my data is incomplete without the transaction command. So I guess I still have to keep it. But I'll keep it in mind! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2022 12:12:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-query-performance-improvement/m-p/615972#M214049</guid>
      <dc:creator>username13</dc:creator>
      <dc:date>2022-10-05T12:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with query performance improvement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-query-performance-improvement/m-p/616047#M214082</link>
      <description>&lt;P&gt;Why did you specified maxspan=180s for the transaction if your goal is to look for events longer than 15 minutes?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;| transaction ThreadId host maxspan=180s startswith=(LogMessage=start) endswith=(LogMessage=end) &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;You dropped the field&amp;nbsp;ThreadId and Host from the subsequent grouping using stats. Was this intentional?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;| stats earliest(_time) as "first", latest(_time) as "last", count by Type, CompleteDescription&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expanding on the &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;'s solution, we can make a simple adjustment to give you a similar output as your original query.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats range(_time) AS duration_secs earliest(_time) as "first" latest(_time) as "last" count by values(CompleteDescription) AS CompleteDescription values(Type) AS Type BY ThreadId host&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;You can move one of your filter up to improve efficiency&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where duration_secs&amp;gt;=1800&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;index=log sourcetype=servlog
| stats range(_time) AS duration_secs earliest(_time) as "first" latest(_time) as "last" count by values(CompleteDescription) AS CompleteDescription values(Type) AS Type BY ThreadId host
| where duration_secs&amp;gt;=1800
| eventstats sum(count) as count_full by Type, CompleteDescription 
| eventstats sum(count_full) as total by Type
| eval percentage = round((count_full/total)*100,0)
| eval time_diff = round((last - first)/60, 0)
| eval CompleteDescription=upper(CompleteDescription) 
| search Type!=SSL (CompleteDescription = "MISSING RESPONSE" OR CompleteDescription = "TIMEOUT" OR CompleteDescription = "TECHNICAL ERROR" OR CompleteDescription = "INTERNAL SYSTEM ERROR" OR CompleteDescription = "NO REACHABILITY") total &amp;gt;= 10 percentage &amp;gt;= 50 time_diff &amp;gt;= 30
| convert ctime(first) ctime(last) 
| table Type, CompleteDescription, count_type, count, percentage 
| sort - percentage, total&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If you're still having issues, could you provide sample events?&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2022 18:10:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-query-performance-improvement/m-p/616047#M214082</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-10-05T18:10:52Z</dc:date>
    </item>
  </channel>
</rss>

