<?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 How to edit my search to graph a daily Weighted Average over time? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-graph-a-daily-Weighted-Average-over/m-p/169042#M48259</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm trying to graph a daily weighted average of priority over time. &lt;BR /&gt;
Data looks like: id=123,priority=80,time=50, user=guest.&lt;/P&gt;

&lt;P&gt;Current query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval time=time/3600 | eventstats sum(time) as sum_time by user | eval weighted=time*priority/sum_time | timechart span=1d sum(weighted) by user limit=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Issue: The sum_time field is totaling across all time instead of just the relevant day.&lt;/P&gt;

&lt;P&gt;There doesn't seem to be an "addWeightedAverage" command similar to the "addTotals" command.&lt;/P&gt;

&lt;P&gt;Is there a simple fix to this query I'm missing?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Tue, 23 Dec 2014 21:26:56 GMT</pubDate>
    <dc:creator>asherman</dc:creator>
    <dc:date>2014-12-23T21:26:56Z</dc:date>
    <item>
      <title>How to edit my search to graph a daily Weighted Average over time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-graph-a-daily-Weighted-Average-over/m-p/169042#M48259</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm trying to graph a daily weighted average of priority over time. &lt;BR /&gt;
Data looks like: id=123,priority=80,time=50, user=guest.&lt;/P&gt;

&lt;P&gt;Current query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval time=time/3600 | eventstats sum(time) as sum_time by user | eval weighted=time*priority/sum_time | timechart span=1d sum(weighted) by user limit=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Issue: The sum_time field is totaling across all time instead of just the relevant day.&lt;/P&gt;

&lt;P&gt;There doesn't seem to be an "addWeightedAverage" command similar to the "addTotals" command.&lt;/P&gt;

&lt;P&gt;Is there a simple fix to this query I'm missing?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 23 Dec 2014 21:26:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-graph-a-daily-Weighted-Average-over/m-p/169042#M48259</guid>
      <dc:creator>asherman</dc:creator>
      <dc:date>2014-12-23T21:26:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to graph a daily Weighted Average over time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-graph-a-daily-Weighted-Average-over/m-p/169043#M48260</link>
      <description>&lt;P&gt;I don't quite get what the desired result would look like. Do post a few sample events along with the result you're looking for, then we'll surely be able to help you come up with a search that automates this.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Dec 2014 22:23:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-graph-a-daily-Weighted-Average-over/m-p/169043#M48260</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-12-23T22:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to graph a daily Weighted Average over time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-graph-a-daily-Weighted-Average-over/m-p/169044#M48261</link>
      <description>&lt;P&gt;Sample data:&lt;BR /&gt;
Day 1&lt;BR /&gt;
id=1,time=1,priority=90,user=guest1&lt;BR /&gt;
id=2,time=11,priority=10,user=guest1&lt;BR /&gt;
id=3,time=4,priority=90,user=guest2&lt;BR /&gt;
Day 2&lt;BR /&gt;
id=4,time=1,priority=50,user=guest1&lt;BR /&gt;
id=5,time=1,priority=10,user=guest1&lt;BR /&gt;
id=6,time=99,priority=40,user=guest2&lt;BR /&gt;
id=7,time=1,priority=100,user=guest2&lt;BR /&gt;
Output:&lt;BR /&gt;
Day 1:&lt;BR /&gt;
guest 1 average weighted priority=16.67&lt;BR /&gt;
guest 2 average weighted priority=90&lt;BR /&gt;
Day 2:&lt;BR /&gt;
guest 1 average weighted priority=30&lt;BR /&gt;
guest 2 average weighted priority=40.6&lt;/P&gt;</description>
      <pubDate>Tue, 23 Dec 2014 22:42:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-graph-a-daily-Weighted-Average-over/m-p/169044#M48261</guid>
      <dc:creator>asherman</dc:creator>
      <dc:date>2014-12-23T22:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to graph a daily Weighted Average over time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-graph-a-daily-Weighted-Average-over/m-p/169045#M48262</link>
      <description>&lt;P&gt;Okay, now I understand the question. Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval tp = time * priority | bin span=1d _time | stats sum(time) as time sum(tp) as tp by _time user | eval weighted = tp / time | xyseries _time user weighted
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Depending on the behaviour you want for missing data points you may want to replace the &lt;CODE&gt;xyseries&lt;/CODE&gt; with &lt;CODE&gt;timechart span=1d sum(weighted) by user&lt;/CODE&gt; or with &lt;CODE&gt;timechart span=1d avg(weighted) by user&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Dec 2014 00:39:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-graph-a-daily-Weighted-Average-over/m-p/169045#M48262</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-12-24T00:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to graph a daily Weighted Average over time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-graph-a-daily-Weighted-Average-over/m-p/169046#M48263</link>
      <description>&lt;P&gt;Thanks a bunch! Although, I'm unclear how the result from the xyseries and the timechart/avg variant differ from each other - could you elaborate on that please? The only difference I see in the results is that timechart truncates without a limit=0 set.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Dec 2014 00:51:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-graph-a-daily-Weighted-Average-over/m-p/169046#M48263</guid>
      <dc:creator>asherman</dc:creator>
      <dc:date>2014-12-24T00:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to graph a daily Weighted Average over time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-graph-a-daily-Weighted-Average-over/m-p/169047#M48264</link>
      <description>&lt;P&gt;Say an entire day has no data. &lt;CODE&gt;xyseries&lt;/CODE&gt; will not see that day, while &lt;CODE&gt;timechart&lt;/CODE&gt; will insert a row for that day.&lt;/P&gt;

&lt;P&gt;Say a user has no data for a day. Depending on whether you want a zero or a null for that cell you'll want &lt;CODE&gt;avg()&lt;/CODE&gt; or &lt;CODE&gt;sum()&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Dec 2014 00:56:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-graph-a-daily-Weighted-Average-over/m-p/169047#M48264</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-12-24T00:56:03Z</dc:date>
    </item>
  </channel>
</rss>

