<?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 to optimize this timechart query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-this-timechart-query/m-p/540685#M152983</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/49493"&gt;@tscroggins&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I attempted using the tstats command you mentioned. Does it matter where acct_id field is located in the event or does it have to be the first field after the time like in your example?&lt;/P&gt;&lt;P&gt;This is what my event currently looks like:&lt;/P&gt;&lt;P&gt;&lt;SPAN class="t"&gt;20210221&lt;/SPAN&gt; &lt;SPAN class="t"&gt;01:19:04.554&lt;/SPAN&gt; &lt;SPAN class="t"&gt;UTC&lt;/SPAN&gt; &lt;SPAN class="t"&gt;INFO&lt;/SPAN&gt; &lt;SPAN class="t"&gt;core&lt;/SPAN&gt;&amp;nbsp;field&lt;SPAN class="t"&gt;=some_value&lt;/SPAN&gt;&amp;nbsp;field1&lt;SPAN class="t"&gt;=some_value1&lt;/SPAN&gt;&amp;nbsp;field2&lt;SPAN class="t"&gt;=some_value2&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN class="t"&gt;acct_id="123-123-123&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 21 Feb 2021 01:23:09 GMT</pubDate>
    <dc:creator>klim</dc:creator>
    <dc:date>2021-02-21T01:23:09Z</dc:date>
    <item>
      <title>How to optimize this timechart query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-this-timechart-query/m-p/540591#M152943</link>
      <description>&lt;P&gt;I have this query index=some_index | timechart&amp;nbsp;limit=15 useOther=false count by acct_id and it needs to run up to a time period of one month. The current time it takes to run is very long and the amount of events it looks at is around 70 million a day. I could accelerate the report but even then it takes awhile to complete the chart even when it says it's scanned 100% of the time period.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2021 22:52:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-this-timechart-query/m-p/540591#M152943</guid>
      <dc:creator>klim</dc:creator>
      <dc:date>2021-02-19T22:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to optimize this timechart query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-this-timechart-query/m-p/540599#M152947</link>
      <description>&lt;P&gt;Have you considered creating a summary index based on the counts for each day, then make your query a sum of the daily counts over the month?&lt;/P&gt;</description>
      <pubDate>Sat, 20 Feb 2021 00:04:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-this-timechart-query/m-p/540599#M152947</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-02-20T00:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to optimize this timechart query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-this-timechart-query/m-p/540600#M152948</link>
      <description>&lt;P&gt;I've considered that but the time range that could be selected could be the last 15 minutes or 15 minute range on a certain date.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Feb 2021 00:13:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-this-timechart-query/m-p/540600#M152948</guid>
      <dc:creator>klim</dc:creator>
      <dc:date>2021-02-20T00:13:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to optimize this timechart query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-this-timechart-query/m-p/540658#M152960</link>
      <description>&lt;P&gt;It's still an excellent suggestion, but you can summarize over smaller time ranges. If your summary populating search runs every ~15 minutes, you're counting by acct_id over ~730,000 events. When a user needs to aggregate over larger time ranges, they can search the summary index. The available precision will just be limited to your aggregation window.&lt;/P&gt;&lt;P&gt;If you're running Splunk 8+ and your raw events contain acct_id=x, you can also take advantage of PREFIX in tstats:&lt;/P&gt;&lt;P&gt;| tstats count where index=some_index TERM(acct_id=*) by PREFIX(acct_id=) _time span=1d&lt;/P&gt;&lt;P&gt;Check out Richard Morgan's excellent "TSTATS and PREFIX" presentation from .conf20 at&amp;nbsp;&lt;A href="https://conf.splunk.com/files/2020/slides/PLA1089C.pdf" target="_blank" rel="noopener"&gt;https://conf.splunk.com/files/2020/slides/PLA1089C.pdf&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Feb 2021 18:52:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-this-timechart-query/m-p/540658#M152960</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2021-02-20T18:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to optimize this timechart query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-this-timechart-query/m-p/540683#M152981</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/49493"&gt;@tscroggins&lt;/a&gt;&amp;nbsp;thanks for the reply. I'm pretty sure I'm using splunk 8 right now but the tstats command you provided returns three columns acct_id, _time, and count. acct_id is empty though so maybe the PREFIX(acct_id) isn't working correctly. The acct_id contains only dashes so it is a minor breaker.&lt;/P&gt;</description>
      <pubDate>Sun, 21 Feb 2021 00:58:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-this-timechart-query/m-p/540683#M152981</guid>
      <dc:creator>klim</dc:creator>
      <dc:date>2021-02-21T00:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to optimize this timechart query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-this-timechart-query/m-p/540684#M152982</link>
      <description>&lt;P&gt;If the events look something like this:&lt;/P&gt;&lt;P&gt;Sat Feb 20 20:13:00 EST 2021 acct_id=123&lt;/P&gt;&lt;P&gt;your tstats search could look like this:&lt;/P&gt;&lt;P&gt;| tstats count where index=foo TERM(acct_id=*) by PREFIX(acct_id=)&lt;/P&gt;&lt;P&gt;The PREFIX() function must contain the entire string prefix, including the "=" character.&lt;/P&gt;&lt;P&gt;If the events look something like this, and you're using search time field exaction:&lt;/P&gt;&lt;P&gt;Sat Feb 20 20:13:00 EST 2021 123&lt;/P&gt;&lt;P&gt;then you need to fall back to search time aggregations. If you plan to summarize data, compare the "cost" of summarizing with the cost of simply indexing the acct_id field in the primary index.&lt;/P&gt;</description>
      <pubDate>Sun, 21 Feb 2021 01:16:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-this-timechart-query/m-p/540684#M152982</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2021-02-21T01:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to optimize this timechart query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-this-timechart-query/m-p/540685#M152983</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/49493"&gt;@tscroggins&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I attempted using the tstats command you mentioned. Does it matter where acct_id field is located in the event or does it have to be the first field after the time like in your example?&lt;/P&gt;&lt;P&gt;This is what my event currently looks like:&lt;/P&gt;&lt;P&gt;&lt;SPAN class="t"&gt;20210221&lt;/SPAN&gt; &lt;SPAN class="t"&gt;01:19:04.554&lt;/SPAN&gt; &lt;SPAN class="t"&gt;UTC&lt;/SPAN&gt; &lt;SPAN class="t"&gt;INFO&lt;/SPAN&gt; &lt;SPAN class="t"&gt;core&lt;/SPAN&gt;&amp;nbsp;field&lt;SPAN class="t"&gt;=some_value&lt;/SPAN&gt;&amp;nbsp;field1&lt;SPAN class="t"&gt;=some_value1&lt;/SPAN&gt;&amp;nbsp;field2&lt;SPAN class="t"&gt;=some_value2&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN class="t"&gt;acct_id="123-123-123&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Feb 2021 01:23:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-this-timechart-query/m-p/540685#M152983</guid>
      <dc:creator>klim</dc:creator>
      <dc:date>2021-02-21T01:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to optimize this timechart query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-this-timechart-query/m-p/540687#M152985</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/228254"&gt;@klim&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The double quote is a major breaker, so PREFIX won't work.&lt;/P&gt;&lt;P&gt;You might consider extracting and indexing the acct_id field, but it won't help with already indexed events.&lt;/P&gt;</description>
      <pubDate>Sun, 21 Feb 2021 01:30:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-optimize-this-timechart-query/m-p/540687#M152985</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2021-02-21T01:30:16Z</dc:date>
    </item>
  </channel>
</rss>

