<?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 in timechart, how do you display average by field, but also show a total average in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308489#M92529</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have events from various projects, and each event has an eventDuration field.&lt;BR /&gt;
I'm trying to visualize the followings in the same chart:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;the average duration of events for individual project by day&lt;/LI&gt;
&lt;/OL&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;... | timechart span=1d avg(eventDuration) by project&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;OL&gt;
&lt;LI&gt;the total average duration of events for all projects/events by day&lt;/LI&gt;
&lt;/OL&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;... | timechart span=1d avg(eventDuration) as TotalAverage&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;But I'm having hard time figuring out how to combine these,&lt;BR /&gt;
so I can have the TotalAverage column from #2 added as the last column to the timechart from #1.&lt;/P&gt;

&lt;P&gt;Maybe I'm missing something obvious, but I'm hoping someone can give me some pointers.&lt;BR /&gt;
Thank you!&lt;/P&gt;</description>
    <pubDate>Sat, 01 Apr 2017 02:25:49 GMT</pubDate>
    <dc:creator>pcheng</dc:creator>
    <dc:date>2017-04-01T02:25:49Z</dc:date>
    <item>
      <title>in timechart, how do you display average by field, but also show a total average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308489#M92529</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have events from various projects, and each event has an eventDuration field.&lt;BR /&gt;
I'm trying to visualize the followings in the same chart:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;the average duration of events for individual project by day&lt;/LI&gt;
&lt;/OL&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;... | timechart span=1d avg(eventDuration) by project&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;OL&gt;
&lt;LI&gt;the total average duration of events for all projects/events by day&lt;/LI&gt;
&lt;/OL&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;... | timechart span=1d avg(eventDuration) as TotalAverage&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;But I'm having hard time figuring out how to combine these,&lt;BR /&gt;
so I can have the TotalAverage column from #2 added as the last column to the timechart from #1.&lt;/P&gt;

&lt;P&gt;Maybe I'm missing something obvious, but I'm hoping someone can give me some pointers.&lt;BR /&gt;
Thank you!&lt;/P&gt;</description>
      <pubDate>Sat, 01 Apr 2017 02:25:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308489#M92529</guid>
      <dc:creator>pcheng</dc:creator>
      <dc:date>2017-04-01T02:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: in timechart, how do you display average by field, but also show a total average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308490#M92530</link>
      <description>&lt;P&gt;Try using appendcols:&lt;BR /&gt;
... | timechart span=1d avg(eventDuration) by project | appendcols [ search ... | timechart span=1d avg(eventDuration) as TotalAverage ]&lt;/P&gt;</description>
      <pubDate>Sat, 01 Apr 2017 13:30:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308490#M92530</guid>
      <dc:creator>Tom1187</dc:creator>
      <dc:date>2017-04-01T13:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: in timechart, how do you display average by field, but also show a total average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308491#M92531</link>
      <description>&lt;P&gt;Try the below code, hope it would work.&lt;/P&gt;

&lt;P&gt;..|stats avg(eventDuration) as TotalDuration |timechart TotalDuration over avg(eventDuration) by project&lt;/P&gt;</description>
      <pubDate>Sat, 01 Apr 2017 18:53:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308491#M92531</guid>
      <dc:creator>gouravdashtcs</dc:creator>
      <dc:date>2017-04-01T18:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: in timechart, how do you display average by field, but also show a total average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308492#M92532</link>
      <description>&lt;P&gt;This does work for sure (although new column is not necessary the last column), but I was really hoping not to do the whole search again, hitting the index twice while the search is exactly the same.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 17:56:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308492#M92532</guid>
      <dc:creator>pcheng</dc:creator>
      <dc:date>2017-04-03T17:56:25Z</dc:date>
    </item>
    <item>
      <title>Re: in timechart, how do you display average by field, but also show a total average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308493#M92533</link>
      <description>&lt;P&gt;can't seem to use TotalDuration directly in timechart&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;Error in 'timechart' command: The specifier 'TotalDuration' is invalid. It must be in form (). For example: max(size).&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;so I changed it to&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;| timechart avg(TotalDuration) over avg(eventDuration) by project&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;but then seems like over is not supported either&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;Error in 'timechart' command: The specifier 'over' is invalid. It must be in form (). For example: max(size).&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Mon, 03 Apr 2017 18:04:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308493#M92533</guid>
      <dc:creator>pcheng</dc:creator>
      <dc:date>2017-04-03T18:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: in timechart, how do you display average by field, but also show a total average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308494#M92534</link>
      <description>&lt;P&gt;When doing anything complicated, it's usually easier to use stats, set the name of the series, and then feed the results to &lt;CODE&gt;timechart&lt;/CODE&gt;.  I believe this gets you what you want.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(your search)
| bin _time span=1d
| stats avg(eventDuration) as avgDuration by project _time
| appendpipe [| eval project="Total"]
| timechart span=1d avg(avgDuration) as avgDuration by project
| table _time * Total
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or this, depending on which average you want...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(your search)
| bin _time span=1d
| eval sorttype=0
| appendpipe [| eval project="Total", sorttype=1]
| stats avg(eventDuration) as avgDuration by sorttype project _time
| timechart span=1d avg(avgDuration) as avgDuration by project
| table _time * Total
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;The first will get you the average of the project averages.  The second will get you the average of the individual events.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;Update - Per somesoni2's recommendation, added table command at end of each query to move the total column right.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 21:13:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308494#M92534</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-04-03T21:13:50Z</dc:date>
    </item>
    <item>
      <title>Re: in timechart, how do you display average by field, but also show a total average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308495#M92535</link>
      <description>&lt;P&gt;Give this a try &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search
| eval project=split(project."##TotalAverage","##")
| timechart span=1d avg(avgDuration) as avgDuration by project
| table _time * TotalAverage
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Apr 2017 21:26:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308495#M92535</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-04-03T21:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: in timechart, how do you display average by field, but also show a total average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308496#M92536</link>
      <description>&lt;P&gt;oh~~~ this is cool! Thank you!&lt;BR /&gt;
I see what you're doing here, and the sorting is really cool.&lt;/P&gt;

&lt;P&gt;However, I can't seem to pass the result of stats into timechart (when I do, it returns no result). I had to use eventstats instead, but that nullify the sorting. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;And for the eventstats, I actually have to also split by date for the average to calculate properly.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | bin time span=1d
 | eval sorttype=0
 | appendpipe [| eval project="Total", sorttype=1]
 | eventstats avg(eventDuration) as avgDuration by date sorttype project
 | timechart span=1d avg(avgDuration) by project
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Do you know how I might get stats working with timechart? I'd really prefer the "Total" to be the last column, without having to come up with weird names just to satisfy the automatic alphabetical sorting.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 21:46:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308496#M92536</guid>
      <dc:creator>pcheng</dc:creator>
      <dc:date>2017-04-03T21:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: in timechart, how do you display average by field, but also show a total average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308497#M92537</link>
      <description>&lt;P&gt;It worked fine with my test data.  &lt;/P&gt;

&lt;P&gt;Ah, sorry, looks like I updated the code after you pulled it.  &lt;/P&gt;

&lt;P&gt;_time needs an underscore.&lt;/P&gt;

&lt;P&gt;Use the current code and try again.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 21:53:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308497#M92537</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-04-03T21:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: in timechart, how do you display average by field, but also show a total average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308498#M92538</link>
      <description>&lt;P&gt;Interesting approach, and I'll bet it's marginally more efficient than using appendpipe to split the records.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 21:56:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308498#M92538</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-04-03T21:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: in timechart, how do you display average by field, but also show a total average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308499#M92539</link>
      <description>&lt;P&gt;If you want to avoid searching the results twice, you could just add up the values and manually calc the total average (and remove the fields you don't care about):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | timechart span=1d avg(eventDuration) sum(eventDuration) as s_ed count(eventDuration) as c_ed by project | addtotals fieldname=s_ed s_ed* | addtotals fieldname=c_ed c_ed* | eval total_avg=s_ed/c_ed | fields - s_ed* - c_ed*
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Apr 2017 21:59:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308499#M92539</guid>
      <dc:creator>briancronrath</dc:creator>
      <dc:date>2017-04-03T21:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: in timechart, how do you display average by field, but also show a total average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308500#M92540</link>
      <description>&lt;P&gt;oh i see. timechart was expecting the default _time field. Thanks that does make stats work with timechart.&lt;/P&gt;

&lt;P&gt;The column ordering issue still persists though. Because my project names could be after "T" for "Total".&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 22:01:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308500#M92540</guid>
      <dc:creator>pcheng</dc:creator>
      <dc:date>2017-04-03T22:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: in timechart, how do you display average by field, but also show a total average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308501#M92541</link>
      <description>&lt;P&gt;For sorting issues, just add this to the end of the search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| table _time * Total
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Apr 2017 22:04:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308501#M92541</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-04-03T22:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: in timechart, how do you display average by field, but also show a total average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308502#M92542</link>
      <description>&lt;P&gt;Woo~~ that's it!&lt;BR /&gt;
Thank you both so much!&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 22:10:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308502#M92542</guid>
      <dc:creator>pcheng</dc:creator>
      <dc:date>2017-04-03T22:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: in timechart, how do you display average by field, but also show a total average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308503#M92543</link>
      <description>&lt;P&gt;This is an interesting approach and seems to work too.&lt;/P&gt;

&lt;P&gt;In this case, I'll stick with the avg() function since there's a way to get that working. ^^^&lt;/P&gt;

&lt;P&gt;But thank you for sharing! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 22:13:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308503#M92543</guid>
      <dc:creator>pcheng</dc:creator>
      <dc:date>2017-04-03T22:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: in timechart, how do you display average by field, but also show a total average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308504#M92544</link>
      <description>&lt;P&gt;Interesting! Using split you only increased the amount of values in the project field, but not duplicating the amount of events. &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;So many ways of doing things. Thank you guys so much!&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 22:22:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/308504#M92544</guid>
      <dc:creator>pcheng</dc:creator>
      <dc:date>2017-04-03T22:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: in timechart, how do you display average by field, but also show a total average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/547337#M155192</link>
      <description>&lt;P&gt;This actually helped me with similar problem. Thank you, you are life savior. My previous solution was using appendcols to combine two timechart searches, this solution is much faster and actually finishes &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Apr 2021 10:27:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/in-timechart-how-do-you-display-average-by-field-but-also-show-a/m-p/547337#M155192</guid>
      <dc:creator>JakubJ</dc:creator>
      <dc:date>2021-04-09T10:27:51Z</dc:date>
    </item>
  </channel>
</rss>

