<?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 Subsearch in tstats causing issues in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-in-tstats-causing-issues/m-p/578038#M201449</link>
    <description>&lt;P&gt;Hi. I'm not sure why you try to use that syntax. The subsearch is executed before the outer search, and adds up to the execution. In term of performance, this is not nice.&lt;/P&gt;&lt;P&gt;But let's say you have your reasons ...:&lt;/P&gt;&lt;P&gt;It seems to me there is no space here: &lt;STRONG&gt;fields -_time&amp;nbsp;&lt;/STRONG&gt;while it should be:&amp;nbsp;&lt;STRONG&gt;fields - _time&amp;nbsp;&lt;/STRONG&gt;but you don't even need to get rid of that field.&lt;/P&gt;&lt;P&gt;If you want to return only 1 value, you can use &lt;STRONG&gt;[ | makeresults | eval Audit.action="add"&amp;nbsp;| return Audit.action]&amp;nbsp;&lt;/STRONG&gt;though I'm still unsure of what you try to achieve.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Dec 2021 15:58:21 GMT</pubDate>
    <dc:creator>ldongradi_SPL</dc:creator>
    <dc:date>2021-12-10T15:58:21Z</dc:date>
    <item>
      <title>Subsearch in tstats causing issues</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-in-tstats-causing-issues/m-p/577959#M201394</link>
      <description>&lt;P&gt;I am encountering an issue when using a subsearch in a tstats query. Specifically, I am seeing the count of events increase as well as taking much longer to run than a query without the subsearch (1.5s vs 85s). Note that in my case the subsearch is only returning one result, so I wouldn't expect such a pronounced performance impact.&lt;/P&gt;&lt;P&gt;The examples below use Splunk's own data model that searches over the _audit index, so the performance issue is not as apparent since there is not as many events as in my use-case.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| tstats count FROM  datamodel=internal_audit_logs WHERE Audit.action="add"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Returns a count of 33.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| tstats count FROM  datamodel=internal_audit_logs WHERE [ | makeresults annotate=f | fields -_time | eval Audit.action="add" ]&lt;/LI-CODE&gt;&lt;P&gt;Returns a count of 46.&lt;BR /&gt;&lt;BR /&gt;This issue is not reproducible with index queries.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Dec 2021 23:10:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-in-tstats-causing-issues/m-p/577959#M201394</guid>
      <dc:creator>GindiKhangura</dc:creator>
      <dc:date>2021-12-09T23:10:54Z</dc:date>
    </item>
    <item>
      <title>Subsearch in tstats causing issues</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-in-tstats-causing-issues/m-p/578038#M201449</link>
      <description>&lt;P&gt;Hi. I'm not sure why you try to use that syntax. The subsearch is executed before the outer search, and adds up to the execution. In term of performance, this is not nice.&lt;/P&gt;&lt;P&gt;But let's say you have your reasons ...:&lt;/P&gt;&lt;P&gt;It seems to me there is no space here: &lt;STRONG&gt;fields -_time&amp;nbsp;&lt;/STRONG&gt;while it should be:&amp;nbsp;&lt;STRONG&gt;fields - _time&amp;nbsp;&lt;/STRONG&gt;but you don't even need to get rid of that field.&lt;/P&gt;&lt;P&gt;If you want to return only 1 value, you can use &lt;STRONG&gt;[ | makeresults | eval Audit.action="add"&amp;nbsp;| return Audit.action]&amp;nbsp;&lt;/STRONG&gt;though I'm still unsure of what you try to achieve.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 15:58:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-in-tstats-causing-issues/m-p/578038#M201449</guid>
      <dc:creator>ldongradi_SPL</dc:creator>
      <dc:date>2021-12-10T15:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch in tstats causing issues</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-in-tstats-causing-issues/m-p/578053#M201457</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213640"&gt;@ldongradi_SPL&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to modify the tstats query with a dynamic value without having to rely on SimpleXML, tokens, or JS (should strictly be done via search).&lt;/P&gt;&lt;P&gt;Regardless which method I use, the issue still exists where the count is incorrect.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| tstats count FROM  datamodel=internal_audit_logs WHERE Audit.action=[ | makeresults annotate=f | eval Audit.action="\"add\"" | return $Audit.action ]&lt;/LI-CODE&gt;&lt;P&gt;creates a reportSearch of&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| tstats  count FROM  datamodel=internal_audit_logs WHERE Audit.action= "add"                                 &lt;/LI-CODE&gt;&lt;P&gt;If I run the reportSearch manually in the search app, it runs fine and returns a count of 393 results. Running the query with the subsearch returns an incorrect count of 657.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To answer your question why I am using a subsearch this way: in my case, the subsearch is a fast search that returns just one value based on some criteria, so I wouldn't expect a performance impact. Correct me if I'm wrong, but the subsearch only runs once. It allows me to create a search that dynamically adapts based on some criteria.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 18:50:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-in-tstats-causing-issues/m-p/578053#M201457</guid>
      <dc:creator>GindiKhangura</dc:creator>
      <dc:date>2021-12-10T18:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch in tstats causing issues</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-in-tstats-causing-issues/m-p/578094#M201476</link>
      <description>&lt;P&gt;I can't say why I understand the difference in count between your 2 searches.&lt;/P&gt;&lt;P&gt;But trying a similar syntax as yours in my test environment gives me an execution time of 0.37s with the subsearch vs 0.075s without it, while I don't have any discrepancy in the results.&lt;/P&gt;&lt;P&gt;Based on these performance, I would probably not investigate that syntax any further if it leads to an execution time 5 times worse.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Dec 2021 00:35:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-in-tstats-causing-issues/m-p/578094#M201476</guid>
      <dc:creator>ldongradi_SPL</dc:creator>
      <dc:date>2021-12-11T00:35:28Z</dc:date>
    </item>
  </channel>
</rss>

