<?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 Can't get timechart average to work in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513278#M143997</link>
    <description>&lt;P&gt;I'm trying to get the average time that a case is open in a system.&lt;/P&gt;&lt;P&gt;To get the latest event per case that's closed and calculate&amp;nbsp;the time between open and close,&amp;nbsp;I use the following search (I'll refer to this as "&amp;lt;base command&amp;gt;") which works:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="&amp;lt;client&amp;gt;" case_id | dedup 1 case_id sortby -_time | search (status!=new AND status!=under_investigation) | convert mktime(_time) as modification_time_epoch | eval creation_time_epoch = strptime(creation_time, "%Y/%m/%d %H:%M:%S") | eval timedifference_seconds = modification_time_epoch - creation_time_epoch | eval timedifference_minutes = timedifference_seconds / 60 | eval timedifference_hours = timedifference_minutes / 60&lt;/LI-CODE&gt;&lt;P&gt;Appending ' | timechart avg(timedifference_hours)' doesn't work as expected because it simply uses the last value instead of the average across all of the values.&lt;/P&gt;&lt;P&gt;Appending ' |&amp;nbsp;stats avg(timedifference_hours)' does correctly calculate the average but I can't get that output to be accepted by timechart.&lt;/P&gt;&lt;P&gt;I've tried every solution that I can find online but none of them have worked, hence this post.&lt;/P&gt;</description>
    <pubDate>Mon, 10 Aug 2020 12:00:10 GMT</pubDate>
    <dc:creator>benhooper</dc:creator>
    <dc:date>2020-08-10T12:00:10Z</dc:date>
    <item>
      <title>Can't get timechart average to work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513278#M143997</link>
      <description>&lt;P&gt;I'm trying to get the average time that a case is open in a system.&lt;/P&gt;&lt;P&gt;To get the latest event per case that's closed and calculate&amp;nbsp;the time between open and close,&amp;nbsp;I use the following search (I'll refer to this as "&amp;lt;base command&amp;gt;") which works:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="&amp;lt;client&amp;gt;" case_id | dedup 1 case_id sortby -_time | search (status!=new AND status!=under_investigation) | convert mktime(_time) as modification_time_epoch | eval creation_time_epoch = strptime(creation_time, "%Y/%m/%d %H:%M:%S") | eval timedifference_seconds = modification_time_epoch - creation_time_epoch | eval timedifference_minutes = timedifference_seconds / 60 | eval timedifference_hours = timedifference_minutes / 60&lt;/LI-CODE&gt;&lt;P&gt;Appending ' | timechart avg(timedifference_hours)' doesn't work as expected because it simply uses the last value instead of the average across all of the values.&lt;/P&gt;&lt;P&gt;Appending ' |&amp;nbsp;stats avg(timedifference_hours)' does correctly calculate the average but I can't get that output to be accepted by timechart.&lt;/P&gt;&lt;P&gt;I've tried every solution that I can find online but none of them have worked, hence this post.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 12:00:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513278#M143997</guid>
      <dc:creator>benhooper</dc:creator>
      <dc:date>2020-08-10T12:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get timechart average to work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513287#M143998</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="&amp;lt;client&amp;gt;" case_id (status!=new AND status!=under_investigation) 
| eval creation_time_epoch = strptime(creation_time, "%Y/%m/%d %H:%M:%S") 
| eval timedifference = _time - creation_time_epoch
| timechart span=1h avg(timedifference) by case_id&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 09:31:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513287#M143998</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-08-10T09:31:46Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get timechart average to work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513290#M143999</link>
      <description>&lt;P&gt;Thanks for that but it seems to not work:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;All sorts of unexpected columns are returned ("1156", "1157", "1232", etc - times?).&lt;/LI&gt;&lt;LI&gt;A span of 1 hour returns "0 → 0".&lt;/LI&gt;&lt;LI&gt;A span of 7 days returns "0&amp;nbsp;⇲ -199,122", etc.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Also, it may have been unclear in the original post but I'd like an all-time average, if possible. So far, I've just been using the time-picker to do so but I'm unsure how the timechart span plays into that.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 09:40:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513290#M143999</guid>
      <dc:creator>benhooper</dc:creator>
      <dc:date>2020-08-10T09:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get timechart average to work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513294#M144002</link>
      <description>&lt;P&gt;&amp;gt;&lt;SPAN&gt;unexpected columns are returned&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;you wanted&lt;STRONG&gt;&amp;nbsp;| timechart avg(timedifference_hours),&lt;/STRONG&gt; so I make the query &lt;STRONG&gt;timechart span=1h avg&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&amp;gt;all time average&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;try&lt;STRONG&gt; | eventstats avg()&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 09:50:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513294#M144002</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-08-10T09:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get timechart average to work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513303#M144006</link>
      <description>&lt;P&gt;Sorry,&amp;nbsp;I mostly use timecharts in the single value visualisation (including in this case) so I forgot that the timechart span is the unit on the x axis and not the search timeframe.&lt;/P&gt;&lt;P&gt;I tried "&amp;nbsp;| eventstats avg()" and " | eventstats avg(timedifference_hours)" but both return "&lt;SPAN&gt;Your search isn't generating any statistic or visualization results".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 10:54:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513303#M144006</guid>
      <dc:creator>benhooper</dc:creator>
      <dc:date>2020-08-10T10:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get timechart average to work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513313#M144009</link>
      <description>&lt;P&gt;&amp;gt;&lt;SPAN&gt;|&amp;nbsp;stats avg(timedifference_hours) is works&lt;BR /&gt;&lt;BR /&gt;you don't create table, so&amp;nbsp;&lt;EM&gt;Your search isn't generating any statistic or visualization results&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 11:39:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513313#M144009</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-08-10T11:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get timechart average to work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513320#M144015</link>
      <description>&lt;P&gt;I've just tried the following searches but both still return "No results found":&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;"&amp;lt;base command&amp;gt;&amp;nbsp;| eventstats avg(timedifference_hours) as timedifference_hours_average | table timedifference_hours_average | timechart span=1d avg(timedifference_hours_average)"&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;"&amp;lt;base command&amp;gt;&amp;nbsp;| stats avg(timedifference_hours) as timedifference_hours_average | table timedifference_hours_average | timechart span=1d avg(timedifference_hours_average)"&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;They work fine without " | timechart", though.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 11:57:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513320#M144015</guid>
      <dc:creator>benhooper</dc:creator>
      <dc:date>2020-08-10T11:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get timechart average to work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513321#M144016</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&amp;lt;base command&amp;gt;&amp;nbsp;| eventstats avg(timedifference_hours) as timedifference_hours_average&lt;BR /&gt;&lt;BR /&gt;Have you tried the query line by line?&lt;BR /&gt;&lt;STRONG&gt;eventstats avg()&lt;/STRONG&gt; makes whole average. why do you do&amp;nbsp;&lt;STRONG&gt;| timechart span=1d?&lt;BR /&gt;&lt;/STRONG&gt;Nothing changes per day.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;"&amp;lt;base command&amp;gt;&amp;nbsp;| stats avg( ...&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;timechart&amp;nbsp;&lt;/STRONG&gt;needs _time field. your query remove _time by &lt;STRONG&gt;stats&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 12:03:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513321#M144016</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-08-10T12:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get timechart average to work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513325#M144018</link>
      <description>&lt;P&gt;Okay, I've managed to generate a timechart which does seem to be correct (tested by exporting and calculating average in Excel) using the following search:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;base command&amp;gt; | eventstats avg(timedifference_hours) as timedifference_hours_average | table _time, timedifference_hours_average | timechart avg(timedifference_hours_average)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;However, there seems to be no real trend / history to it. For example:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;All-time: "31 ↗ 31"&lt;/LI&gt;&lt;LI&gt;Month to date: "10&amp;nbsp;↗ 10"&lt;/LI&gt;&lt;LI&gt;Last 7 days: "6&amp;nbsp;↗ 6"&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Using a custom trend comparison and a different time range doesn't make a difference because, for some reason, the timeline values are either 0 or the highest number.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 12:28:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513325#M144018</guid>
      <dc:creator>benhooper</dc:creator>
      <dc:date>2020-08-10T12:28:33Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get timechart average to work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513331#M144020</link>
      <description>&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.0.4/SearchReference/Timechart" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.0.4/SearchReference/Timechart&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I have no idea why you are using &lt;STRONG&gt;timechart&lt;/STRONG&gt;, but since you are using &lt;STRONG&gt;eventstats&lt;/STRONG&gt;, of course it won't change.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 12:46:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513331#M144020</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-08-10T12:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get timechart average to work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513334#M144021</link>
      <description>&lt;P&gt;Because I'd like to see whether the average time to close a case is improving or worsening but, since I'm new to all of this, I'll take suggestions for better ways to do so.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 13:04:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513334#M144021</guid>
      <dc:creator>benhooper</dc:creator>
      <dc:date>2020-08-10T13:04:11Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get timechart average to work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513336#M144022</link>
      <description>&lt;LI-CODE lang="markup"&gt;index="&amp;lt;client&amp;gt;" case_id (status!=new AND status!=under_investigation) 
| eval creation_time_epoch = strptime(creation_time, "%Y/%m/%d %H:%M:%S") 
| eval timedifference = _time - creation_time_epoch
| eval time=_time
| bin span=1d _time
| eventstats avg(timedifference) as day_avg by _time case_id
| bin span=1w _time
| eventstats avg(timedifference) as week_avg by _time case_id
| bin span=1month _time
| eventstats avg(timedifference) as month_avg by _time case_id
| eval _time=time
| table _time case_id day_avg week_avg month_avg
| sort _time
| xyseries _time case_id day_avg week_avg month_avg&lt;/LI-CODE&gt;&lt;P&gt;Visualization &amp;gt;&amp;gt; line chart&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;but I don't see the logs , it can't work, I guess.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 13:13:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513336#M144022</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-08-10T13:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get timechart average to work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513351#M144030</link>
      <description>&lt;P&gt;That does work and I've created it as a separate panel because it may be useful in the future but it's too complicated for what we want for now which is why we're trying to use the Single Value visualisation.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 14:02:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513351#M144030</guid>
      <dc:creator>benhooper</dc:creator>
      <dc:date>2020-08-10T14:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get timechart average to work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513378#M144033</link>
      <description>&lt;P&gt;It seems that using streamstats in place of eventstats has achieved what I want as the average updates with each event.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 15:01:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-get-timechart-average-to-work/m-p/513378#M144033</guid>
      <dc:creator>benhooper</dc:creator>
      <dc:date>2020-08-10T15:01:10Z</dc:date>
    </item>
  </channel>
</rss>

