<?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 can we limit the tstats record? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-we-limit-the-tstats-record/m-p/627692#M218100</link>
    <description>&lt;P&gt;Maybe it is correct from theoretical side, but it was checked in a practical way:&lt;/P&gt;&lt;P&gt;In comparison query with prestats for the same data and time frame takes&amp;nbsp;&lt;SPAN class=""&gt;0.874&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;seconds&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;| tstats prestats=t count(your field) where index=index by field&lt;/P&gt;&lt;P&gt;| head 50&lt;/P&gt;&lt;P&gt;| stats&amp;nbsp;count(your field) by field&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This search has completed and has returned&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;5&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;results by scanning&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;6,460&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;events in&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;0.874&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;seconds&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While without prestats - &amp;gt;&amp;nbsp;&lt;SPAN class=""&gt;6.305&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;seconds&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;| tstats count(your field) where index=index by field&lt;/P&gt;&lt;P&gt;| head 50&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This search has completed and has returned&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;5&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;results by scanning&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;76,972&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;events in&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;6.305&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;seconds&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 20 Jan 2023 08:21:08 GMT</pubDate>
    <dc:creator>LIS</dc:creator>
    <dc:date>2023-01-20T08:21:08Z</dc:date>
    <item>
      <title>How can we limit the tstats record?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-we-limit-the-tstats-record/m-p/506599#M141730</link>
      <description>&lt;P&gt;I am using tstats command from a while, right now we want to make tstats command to limit record as we are using in kubernetes and there are way too many events. I have looked around and don't see limit option. though as a work around I use `| head 100` to limit but that won't stop processing the main search query.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 23:19:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-we-limit-the-tstats-record/m-p/506599#M141730</guid>
      <dc:creator>sumitnagal</dc:creator>
      <dc:date>2023-01-19T23:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: how can we limit the tstats record</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-we-limit-the-tstats-record/m-p/506601#M141732</link>
      <description>The short answer is you can't.&lt;BR /&gt;You can limit the tstats results with the where clause, but there's no way to stop it after a certain number of results, just like with the implicit search command in non-tstats queries.</description>
      <pubDate>Mon, 29 Jun 2020 21:53:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-we-limit-the-tstats-record/m-p/506601#M141732</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-06-29T21:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: how can we limit the tstats record</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-we-limit-the-tstats-record/m-p/627659#M218091</link>
      <description>&lt;P&gt;This is possible with argument prestats=t and then for example command stats:&lt;/P&gt;&lt;P&gt;| tstats prestats=t count(your field) where index=index by field&lt;/P&gt;&lt;P&gt;| head 50&lt;/P&gt;&lt;P&gt;| stats&amp;nbsp;count(your field) by field&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 22:58:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-we-limit-the-tstats-record/m-p/627659#M218091</guid>
      <dc:creator>LIS</dc:creator>
      <dc:date>2023-01-19T22:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: how can we limit the tstats record</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-we-limit-the-tstats-record/m-p/627664#M218094</link>
      <description>&lt;P&gt;That will limit the number of results, but as the OP says, it has no effect on the number of events read from disk.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2023 01:01:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-we-limit-the-tstats-record/m-p/627664#M218094</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-01-20T01:01:43Z</dc:date>
    </item>
    <item>
      <title>Re: How can we limit the tstats record?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-we-limit-the-tstats-record/m-p/627692#M218100</link>
      <description>&lt;P&gt;Maybe it is correct from theoretical side, but it was checked in a practical way:&lt;/P&gt;&lt;P&gt;In comparison query with prestats for the same data and time frame takes&amp;nbsp;&lt;SPAN class=""&gt;0.874&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;seconds&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;| tstats prestats=t count(your field) where index=index by field&lt;/P&gt;&lt;P&gt;| head 50&lt;/P&gt;&lt;P&gt;| stats&amp;nbsp;count(your field) by field&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This search has completed and has returned&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;5&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;results by scanning&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;6,460&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;events in&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;0.874&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;seconds&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While without prestats - &amp;gt;&amp;nbsp;&lt;SPAN class=""&gt;6.305&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;seconds&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;| tstats count(your field) where index=index by field&lt;/P&gt;&lt;P&gt;| head 50&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This search has completed and has returned&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;5&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;results by scanning&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;76,972&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;events in&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;6.305&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;seconds&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2023 08:21:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-we-limit-the-tstats-record/m-p/627692#M218100</guid>
      <dc:creator>LIS</dc:creator>
      <dc:date>2023-01-20T08:21:08Z</dc:date>
    </item>
    <item>
      <title>Re: How can we limit the tstats record?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-we-limit-the-tstats-record/m-p/627718#M218107</link>
      <description>&lt;P&gt;If you want to filter by column try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| tstats allow_old_summaries=t summariesonly=t 
count min(_time) as first_time max(_time) as last_time 
from datamodel=Network_Traffic 
where All_Traffic.action="allowed"
by All_Traffic.dvc All_Traffic.rule All_Traffic.src_ip All_Traffic.dest All_Traffic.dest_port All_Traffic.action All_Traffic.transport
| rename All_Traffic.* as * 
| sort 0 - last_time
| convert ctime(first_time) ctime(last_time)
| fields dvc rule src_ip dest dest_port transport count first_time last_time action&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 20 Jan 2023 10:28:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-we-limit-the-tstats-record/m-p/627718#M218107</guid>
      <dc:creator>jonaclough</dc:creator>
      <dc:date>2023-01-20T10:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: How can we limit the tstats record?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-we-limit-the-tstats-record/m-p/627758#M218116</link>
      <description>&lt;P&gt;Interesting!&amp;nbsp; Thanks for sharing!&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2023 13:43:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-we-limit-the-tstats-record/m-p/627758#M218116</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-01-20T13:43:59Z</dc:date>
    </item>
  </channel>
</rss>

