<?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: What is wrong with my tstats command? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/What-is-wrong-with-my-tstats-command/m-p/286498#M86760</link>
    <description>&lt;P&gt;By the way, if you are using Enterprise Security maybe there's a datamodel you can use to search for your data in a much faster way&lt;/P&gt;</description>
    <pubDate>Wed, 21 Dec 2016 16:55:50 GMT</pubDate>
    <dc:creator>javiergn</dc:creator>
    <dc:date>2016-12-21T16:55:50Z</dc:date>
    <item>
      <title>What is wrong with my tstats command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-wrong-with-my-tstats-command/m-p/286493#M86755</link>
      <description>&lt;P&gt;This search works fine but is slow:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=host1 sourcetype="WinEventLog:Security" EventCode=5156  | timechart span=1d count 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So i'm attempting to convert it to tstats to see if it'll give me a little performance boost, but I don't know the secrets to get tstats to run.  Here's what i've tried based off of Example 4 in the tstats search reference documentation (along with a multitude of other configurations):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats prestats=t count  FROM index=wineventsec_us WHERE host=host1 AND sourcetype="WinEventLog:Security" AND EventCode=5156 BY _time span=1d | timechart span=1d count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Every time i tried a different configuration of the tstats command it has returned 0 events.  Any thoughts would be appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2016 14:35:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-wrong-with-my-tstats-command/m-p/286493#M86755</guid>
      <dc:creator>wcooper003</dc:creator>
      <dc:date>2016-12-21T14:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: What is wrong with my tstats command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-wrong-with-my-tstats-command/m-p/286494#M86756</link>
      <description>&lt;P&gt;You can't filter by EventCode unless it is indexed.&lt;/P&gt;

&lt;P&gt;Try just:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | tstats prestats=t count  FROM index=wineventsec_us WHERE host=host1 AND sourcetype="WinEventLog:Security" BY _time span=1d | timechart span=1d count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And if that works without filtering by EventCode, then this is your issue.&lt;/P&gt;

&lt;P&gt;Alternatively you could try the first query but using Event Sampling. It won't be 100% accurate but at least it'll be much faster and give you a good idea. For instance, with a 1:10 sampling you could do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=host1 sourcetype="WinEventLog:Security" EventCode=5156  
| timechart span=1d count 
| eval count = 10 * count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;With a 1:100 you would multiply by 100 and so on.&lt;/P&gt;

&lt;P&gt;Hope that helps.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2016 14:50:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-wrong-with-my-tstats-command/m-p/286494#M86756</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-12-21T14:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: What is wrong with my tstats command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-wrong-with-my-tstats-command/m-p/286495#M86757</link>
      <description>&lt;P&gt;Thanks for the info.  I tried to take out EventCode, but that didn't help.  Even if I strip out the WHERE clause completely, it still doesn't run.  E.g.:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats prestats=t count  FROM index=wineventsec_us BY _time span=1d | timechart span=1d count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is definitely the correct index name, why is this returning 0 events?  I have tstats working for some data models, but can't figure out what's going on here.  &lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2016 16:41:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-wrong-with-my-tstats-command/m-p/286495#M86757</guid>
      <dc:creator>wcooper003</dc:creator>
      <dc:date>2016-12-21T16:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: What is wrong with my tstats command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-wrong-with-my-tstats-command/m-p/286496#M86758</link>
      <description>&lt;P&gt;I can get this query working if I move the 'index=' from the FROM statement to the WHERE statement:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats count where index=wineventsec_us sourcetype="WinEventLog:Security" by _time span=1d | timechart span=1d count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But it's as you say - EventCode doesn't work in the query.  &lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2016 16:52:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-wrong-with-my-tstats-command/m-p/286496#M86758</guid>
      <dc:creator>wcooper003</dc:creator>
      <dc:date>2016-12-21T16:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: What is wrong with my tstats command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-wrong-with-my-tstats-command/m-p/286497#M86759</link>
      <description>&lt;P&gt;Yeah didn't notice that. You can use FROM to select from a datamodel for instance, but for field = value you have to do it within the WHERE clause.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2016 16:55:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-wrong-with-my-tstats-command/m-p/286497#M86759</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-12-21T16:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: What is wrong with my tstats command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-wrong-with-my-tstats-command/m-p/286498#M86760</link>
      <description>&lt;P&gt;By the way, if you are using Enterprise Security maybe there's a datamodel you can use to search for your data in a much faster way&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2016 16:55:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-wrong-with-my-tstats-command/m-p/286498#M86760</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-12-21T16:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: What is wrong with my tstats command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-wrong-with-my-tstats-command/m-p/593160#M206455</link>
      <description>&lt;P&gt;Would you please explain what you mean by "&lt;SPAN&gt;You can't filter by EventCode unless it is indexed."&lt;/SPAN&gt; Our Windows event codes are whitelisted in inputs.conf with oswin listed as the index, and we have oswin configured in indexes.conf.&lt;/P&gt;&lt;P&gt;I can see results if I just run index=oswin EventCode=8001.&lt;/P&gt;&lt;P&gt;But it tells me I have 0 results if I run:&lt;/P&gt;&lt;P&gt;| tstats values(host) where index=oswin AND EventCode=8001.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 20:22:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-wrong-with-my-tstats-command/m-p/593160#M206455</guid>
      <dc:creator>mommyfixit</dc:creator>
      <dc:date>2022-04-08T20:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: What is wrong with my tstats command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-wrong-with-my-tstats-command/m-p/593165#M206459</link>
      <description>&lt;P&gt;There are two kinds of fields in splunk.&lt;/P&gt;&lt;P&gt;There are the "usual" fields which are extracted in search time which means that splunk extracts them from raw events on the fly as it's comparing the events to your given conditions (oversimplifying slightly the process). Since they are extracted during search time, you can modify the extraction definitions and get various fields from the same raw events, you can redefine the extractions and reapply the, to the same raw data and so on.&lt;/P&gt;&lt;P&gt;Then there is the second one - the indexed fields. Those fields are created only once during the initial ingestion of events. So once the event is indexed, all indexed fields possible for that event are created and written into separate files. The standard splunk's metadata fields - host, source and sourcetype are indexed fields.&lt;/P&gt;&lt;P&gt;Both types of fields have their pros and cons and you usually need a very good reason to create new indexed fields.&lt;/P&gt;&lt;P&gt;But coming back to the original issue - doing summary statistics using tstats is possible only over indexed fields since tstats doesn't touch raw events and only uses the summaries of indexed fields. It has no knowledge of search-time extracted fields. It's therefore much much faster but limited only to those indexed fields.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 21:20:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-wrong-with-my-tstats-command/m-p/593165#M206459</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-04-08T21:20:16Z</dc:date>
    </item>
  </channel>
</rss>

