<?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: Stats output into timechart in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187692#M54081</link>
    <description>&lt;P&gt;Also you may be interested in the &lt;CODE&gt;limit&lt;/CODE&gt; and &lt;CODE&gt;useother&lt;/CODE&gt; parameters on &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/timechart"&gt;timechart&lt;/A&gt;. 10,000 different series of data is a lot to display on a graph, so you wind up with the top 10 series by default,  and the other 9990 series are summed together in a field called "OTHER".&lt;/P&gt;

&lt;P&gt;Ultimately what is it that you want to show in your chart?&lt;/P&gt;</description>
    <pubDate>Tue, 28 Oct 2014 19:42:16 GMT</pubDate>
    <dc:creator>acharlieh</dc:creator>
    <dc:date>2014-10-28T19:42:16Z</dc:date>
    <item>
      <title>Stats output into timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187688#M54077</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I've seen similar posts but they do not answer this question. What I'm trying to do is take the Statistics number received from a stats command and chart it out with timechart.&lt;/P&gt;

&lt;P&gt;My search &lt;EM&gt;before&lt;/EM&gt; the timechart:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=network sourcetype=snort msg="Trojan*" | stats count first(_time) by host, src_ip, dest_ip, msg
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This returns 10,000 rows (statistics number) instead of 80,000 events. How do I use that data and chart the results over a timechart? There should be 10,000 total events on the timechart, not 80,000. I can't figure it out.&lt;/P&gt;

&lt;P&gt;In other words, the results (rows) of the stats command are in reality new events to me. I deduped 80,000 down to 10,000 and now I want to see one line on a timechart represent how many new "events" there are over time.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Oct 2014 18:58:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187688#M54077</guid>
      <dc:creator>thisissplunk</dc:creator>
      <dc:date>2014-10-28T18:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: Stats output into timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187689#M54078</link>
      <description>&lt;P&gt;You can't do multiple fields after a &lt;CODE&gt;by&lt;/CODE&gt; clause for a &lt;CODE&gt;timechart&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Also, your stats loses all time related values, so you can't &lt;CODE&gt;... | timechart&lt;/CODE&gt; since there is no longer time data.&lt;/P&gt;

&lt;P&gt;If you are looking to aggregate over a timeframe, say, per hour, then you could try something like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=network sourcetype=snort msg="Trojan*" | stats count by date_hour, host, src_ip, dest_ip, msg
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This gives you a chart with the hours along the bottom.&lt;/P&gt;

&lt;P&gt;If you need a true timechart effect, then try something more like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=network sourcetype=snort msg="Trojan*" | stats count by _time, host, src_ip, dest_ip, msg
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Your output will be different than when not counting by unique timestamp of the index event.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Oct 2014 19:09:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187689#M54078</guid>
      <dc:creator>jtrucks</dc:creator>
      <dc:date>2014-10-28T19:09:07Z</dc:date>
    </item>
    <item>
      <title>Re: Stats output into timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187690#M54079</link>
      <description>&lt;P&gt;It doesn't work. The problem seems to be that timechart cannot accept more than one value after the BY clause. This is what led me to crafting a stats statement first.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Oct 2014 19:32:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187690#M54079</guid>
      <dc:creator>thisissplunk</dc:creator>
      <dc:date>2014-10-28T19:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: Stats output into timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187691#M54080</link>
      <description>&lt;P&gt;Here's what you actually use:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=network sourcetype=snort msg="Trojan*" | eval combined = host."_".src_ip."_".dest_ip."_".msg | timechart count by combined
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That way you get your grouping by all four values and &lt;CODE&gt;timechart&lt;/CODE&gt; is happy.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Oct 2014 19:35:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187691#M54080</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-10-28T19:35:29Z</dc:date>
    </item>
    <item>
      <title>Re: Stats output into timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187692#M54081</link>
      <description>&lt;P&gt;Also you may be interested in the &lt;CODE&gt;limit&lt;/CODE&gt; and &lt;CODE&gt;useother&lt;/CODE&gt; parameters on &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/timechart"&gt;timechart&lt;/A&gt;. 10,000 different series of data is a lot to display on a graph, so you wind up with the top 10 series by default,  and the other 9990 series are summed together in a field called "OTHER".&lt;/P&gt;

&lt;P&gt;Ultimately what is it that you want to show in your chart?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Oct 2014 19:42:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187692#M54081</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2014-10-28T19:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: Stats output into timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187693#M54082</link>
      <description>&lt;P&gt;Oh yeah, 10000 serieseses isn't going to be fun. Alternative search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=network sourcetype=snort msg="Trojan*" | bucket _time | stats count by _time, host, src_ip, dest_ip, msg
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That'll create a huge bunch of rows rather than 10000 fields.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Oct 2014 19:44:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187693#M54082</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-10-28T19:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: Stats output into timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187694#M54083</link>
      <description>&lt;P&gt;I removed the original answer and replaced it.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Oct 2014 19:45:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187694#M54083</guid>
      <dc:creator>jtrucks</dc:creator>
      <dc:date>2014-10-28T19:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: Stats output into timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187695#M54084</link>
      <description>&lt;P&gt;What I'm trying to show is the amount of rows per hour or so. "100 rows hit at 1 pm, 93 hit at 2 pm" etc.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Oct 2014 19:47:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187695#M54084</guid>
      <dc:creator>thisissplunk</dc:creator>
      <dc:date>2014-10-28T19:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: Stats output into timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187696#M54085</link>
      <description>&lt;P&gt;Are you possibly looking for a &lt;CODE&gt;| timechart span=1h dc(combined) as "Number of rows hit"&lt;/CODE&gt;?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Oct 2014 19:48:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187696#M54085</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-10-28T19:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: Stats output into timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187697#M54086</link>
      <description>&lt;P&gt;So a different note here, ( &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2/Knowledge/Usedefaultfields" target="_blank"&gt;Reference&lt;/A&gt; ) &lt;CODE&gt;date_hour&lt;/CODE&gt; is only present if the timestamp exists and is extracted from the raw event itself. It's also in the timezone of the log and not the timezone of you the splunk user (_time is the UTC timestamp, and is by default displayed in your timezone)... which could be important if you are combining logs from different timezones or across days. You could also use &lt;CODE&gt;|eval _time=relative_time(_time,"@h")&lt;/CODE&gt;, or &lt;CODE&gt;|bin _time span=1h&lt;/CODE&gt; or &lt;CODE&gt;|eval hour=strftime(_time, "%H")&lt;/CODE&gt; for getting a field by hour based on the _time field.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:01:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187697#M54086</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2020-09-28T18:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: Stats output into timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187698#M54087</link>
      <description>&lt;P&gt;I'll try my best to explain, but maybe timechart is overkill. I want to simply chop up the RESULTS from the stats command by hour/day. I want to count how many unique rows I see in the stats output fall into each hour, by day. In other words, I want one line on the timechart to represent the AMOUNT of rows seen per hour/day of the STATS output (the rows). There should be a total of 10,000 events on the timechart, not 80,000, because 10,000 was returned by the stats command.&lt;/P&gt;

&lt;P&gt;Imagine a line in front of you. At any hour, it should tell you how many times there was a unique rows from the stat command in that time frame.&lt;/P&gt;

&lt;P&gt;The combined option you showed above is producing a line for each and every unique row form the stats command. This isn't what I want.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Oct 2014 19:58:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187698#M54087</guid>
      <dc:creator>thisissplunk</dc:creator>
      <dc:date>2014-10-28T19:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: Stats output into timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187699#M54088</link>
      <description>&lt;P&gt;That sounds a lot like the &lt;CODE&gt;| bucket _time | stats ... by _time ...&lt;/CODE&gt; approach.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Oct 2014 20:05:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187699#M54088</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-10-28T20:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: Stats output into timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187700#M54089</link>
      <description>&lt;P&gt;This is slightly off topic, but something that may find interesting is the sparkline: you can have a  would give you a mini graph on each event to show how that event trends over your search window.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=network sourcetype=snort msg="Trojan*" | stats count sparkline by host, src_ip, dest_ip, msg&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;But also did you try martin's suggestion of:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=network sourcetype=snort msg="Trojan*" | eval combined = host."_".src_ip."_".dest_ip."_".msg | timechart span=1h dc(combined) as "Number of rows hit"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;That should be a single line giving the number of distinct combinations per hour.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Oct 2014 20:11:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187700#M54089</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2014-10-28T20:11:58Z</dc:date>
    </item>
    <item>
      <title>Re: Stats output into timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187701#M54090</link>
      <description>&lt;P&gt;Thank you all for the pointers. After a short walk I realized that in essence, I was using the stats command to dedup the results. After this realization I exchanged stats with dedup and used that in timechart. This was successful.&lt;/P&gt;

&lt;P&gt;This is what I ended up using for reference:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=network sourcetype=snort name="Trojan*" | dedup host src_ip dest_ip msg | timechart span=1d count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This was a case of always using stats for multiple purposes which complicated the timechart. The "combined =" solution below was on par with what I was trying to do.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Oct 2014 20:34:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-output-into-timechart/m-p/187701#M54090</guid>
      <dc:creator>thisissplunk</dc:creator>
      <dc:date>2014-10-28T20:34:25Z</dc:date>
    </item>
  </channel>
</rss>

