<?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: Timecharting the sum of a max value in a field. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145496#M40557</link>
    <description>&lt;P&gt;Take a look at the &lt;CODE&gt;per_minute()&lt;/CODE&gt; functions: &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0.3/SearchReference/CommonStatsFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/6.0.3/SearchReference/CommonStatsFunctions&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I'm not driving so keep 'em coming &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Apr 2014 16:43:51 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2014-04-29T16:43:51Z</dc:date>
    <item>
      <title>Timecharting the sum of a max value in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145481#M40542</link>
      <description>&lt;P&gt;I &lt;EM&gt;think&lt;/EM&gt; I have the hard part of this figured out but, I'm struggling with how to send it into time chart. Here's the search base:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main module=api extra.user_id=* extra.endpoint=set_playback_position NOT (extra.args.position="-1" OR extra.args.position="-3" OR extra.args.position="-2" OR Cohort=INT) |bucket _time span=1d |dedup extra.args.url extra.user_id date_mday|stats max(extra.args.position) by extra.args.url extra.user_id
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When I run that, I get a nice set of stats showing the max value for extra.args.position for extra.user_id and extra.args.url. And, if I tack on stats sum it nicely sums up the max values of extra.args.position. &lt;/P&gt;

&lt;P&gt;What I'm looking to do is put this on a column timechart where the height of the column is the sum of max extra.args.position. With each column showing a day or if I want to go further a week which I think I can control by using bucket and span. Bonus points for making each column a stacked column where the components of the stack are the sum of extra.args.position for a user_id. &lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2014 21:49:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145481#M40542</guid>
      <dc:creator>cvervais</dc:creator>
      <dc:date>2014-04-28T21:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: Timecharting the sum of a max value in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145482#M40543</link>
      <description>&lt;P&gt;I'm a bit confused by your use of &lt;CODE&gt;bucket&lt;/CODE&gt;, &lt;CODE&gt;dedup date_mday&lt;/CODE&gt;, and &lt;CODE&gt;stats&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;The bucket floors each &lt;CODE&gt;_time&lt;/CODE&gt; to the start of that day, why are you using &lt;CODE&gt;date_mday&lt;/CODE&gt; instead of this for &lt;CODE&gt;dedup&lt;/CODE&gt;?&lt;BR /&gt;
Why are you using &lt;CODE&gt;dedup&lt;/CODE&gt; at all, shouldn't the &lt;CODE&gt;max()&lt;/CODE&gt; make sure you're not getting duplicates in the end?&lt;BR /&gt;
Finally, your &lt;CODE&gt;stats&lt;/CODE&gt; is throwing out any &lt;CODE&gt;_time&lt;/CODE&gt; info, making a &lt;CODE&gt;timechart&lt;/CODE&gt; after that impossible.&lt;/P&gt;

&lt;P&gt;Say you have this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;timestamp   position
04-28 08:00       10
04-28 10:00       20
04-28 14:00       15
04-29 11:00        5
04-29 13:00       42
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What should the output be?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2014 22:19:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145482#M40543</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-04-28T22:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: Timecharting the sum of a max value in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145483#M40544</link>
      <description>&lt;P&gt;Hi Martin, I get the feeling I'm going to owe you another pint. I was using bucket just to see if I could graph with things bucketed into daily buckets, I forgot to modify the dedup after I did that. With my limited (so far) knowledge of splunk, I put the dedup in to make sure i was getting the max value for that user_id and url combination. We log the position every 10 seconds, if I don't dedup and include _time I'm only getting the max value of position for that time period rather than the max value for that user_id url combination.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:29:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145483#M40544</guid>
      <dc:creator>cvervais</dc:creator>
      <dc:date>2020-09-28T16:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: Timecharting the sum of a max value in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145484#M40545</link>
      <description>&lt;P&gt;Maybe the easiest way to explain what I'm trying to get to is for each user, the sum of the highest recorded extra.playback.position for each extra.args.url. Then I can stack that into a column for each day, week, month, etc.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2014 22:42:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145484#M40545</guid>
      <dc:creator>cvervais</dc:creator>
      <dc:date>2014-04-28T22:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: Timecharting the sum of a max value in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145485#M40546</link>
      <description>&lt;P&gt;Imagine the data I posted above were for user johndoe - what should the output be?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2014 22:56:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145485#M40546</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-04-28T22:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: Timecharting the sum of a max value in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145486#M40547</link>
      <description>&lt;P&gt;Something like this:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt; timestamp  extra.args.url max(extra.args.position)&lt;BR /&gt;
04-28   &lt;A href="http://some.video"&gt;http://some.video&lt;/A&gt;   60&lt;BR /&gt;
04-28   &lt;A href="http://some.other.video"&gt;http://some.other.video&lt;/A&gt;  34 &lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2014 22:59:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145486#M40547</guid>
      <dc:creator>cvervais</dc:creator>
      <dc:date>2014-04-28T22:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: Timecharting the sum of a max value in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145487#M40548</link>
      <description>&lt;P&gt;That doesn't appear to match the data I posted. On top of imagining it's just a single user johndoe, also imagine that data is for a single URL &lt;A href="http://example.com"&gt;http://example.com&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2014 23:02:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145487#M40548</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-04-28T23:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: Timecharting the sum of a max value in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145488#M40549</link>
      <description>&lt;P&gt;Sorry about that, I'm confused. Are you asking for the example you gave what I would expect the chart would look like?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2014 23:04:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145488#M40549</guid>
      <dc:creator>cvervais</dc:creator>
      <dc:date>2014-04-28T23:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: Timecharting the sum of a max value in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145489#M40550</link>
      <description>&lt;P&gt;Yes. I can't make out clear computational rules from your text, so an example might help.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2014 23:07:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145489#M40550</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-04-28T23:07:17Z</dc:date>
    </item>
    <item>
      <title>Re: Timecharting the sum of a max value in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145490#M40551</link>
      <description>&lt;P&gt;Ah, thank you, that helped. Based on your table in your reply, I'd expect a chart with the horizontal axis being time and the vertical axis showing the calculated sum. So, in the chart there'd be a column for 04-28 that rises up to the value of 45. There'd be another column for 04-28 rising up to 47. &lt;/P&gt;

&lt;P&gt;I think that's what you're asking.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2014 23:12:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145490#M40551</guid>
      <dc:creator>cvervais</dc:creator>
      <dc:date>2014-04-28T23:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: Timecharting the sum of a max value in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145491#M40552</link>
      <description>&lt;P&gt;I don't see any evidence of max'ing in that example results, so that'd be this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search | timechart span=1d sum(position)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That's easily extensible to this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search | timechart span=1d sum(position) by URL
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;URLs will each get their own colour - it'll get messy if you want to split by user as well.&lt;BR /&gt;
That can be done of course:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search | eval user_url = user." - ".URL | timechart span=1d sum(position) by user_url
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That'll give you a huge number of colours, and probably won't be usable.&lt;/P&gt;

&lt;P&gt;I've changed your field names due to laziness &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Edit: This appears to be closest to the truth:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search | eval day = relative_time(_time, "@d") | stats latest(_time) as _time max(position) as position by user url day | timechart span=1d avg(position) by url
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Apr 2014 23:19:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145491#M40552</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-04-28T23:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: Timecharting the sum of a max value in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145492#M40553</link>
      <description>&lt;P&gt;I'm a fan of lazy myself &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
Yup, those examples I can get. The reason I'm not looking to sum the position is because the position represents how many seconds into the video playback the current position is. Since we log that every 10 seconds, if I sum it I'll have a result that is longer than the video it's self. &lt;/P&gt;

&lt;P&gt;That's why I was going with max. The maximum value of the position for that video will represent the duration watched. &lt;/P&gt;

&lt;P&gt;Since what I'm trying to get at and show is how much video the users are watching on a user basis and not necessarily the videos themselves.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2014 23:23:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145492#M40553</guid>
      <dc:creator>cvervais</dc:creator>
      <dc:date>2014-04-28T23:23:49Z</dc:date>
    </item>
    <item>
      <title>Re: Timecharting the sum of a max value in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145493#M40554</link>
      <description>&lt;P&gt;Ah. Something like this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search | eval day = relative_time(_time, "@d") | stats latest(_time) as _time max(position) as position by user url day | timechart span=1d avg(position) by url
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm counting each user once per day per url, getting their maximum position for that. Then I'm calculating the average of those maximums for each url per day. Compared to the length of a video it should show how far into the video users watch.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2014 23:28:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145493#M40554</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-04-28T23:28:23Z</dc:date>
    </item>
    <item>
      <title>Re: Timecharting the sum of a max value in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145494#M40555</link>
      <description>&lt;P&gt;That gave me enough to go on and got me this:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=main module=api hostname=&lt;EM&gt;PROD extra.user_id=&lt;/EM&gt; extra.endpoint=set_playback_position NOT (extra.args.position="-1" OR extra.args.position="-3" OR extra.args.position="-2" OR extra.args.position=0 OR Cohort=INT OR Cohort=PB*) |eval day = relative_time(_time, "@d") | stats latest(_time) as _time max(extra.args.position) as position by extra.user_id extra.args.url day | timechart span=1d sum(position)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;If I did it right, rather than take the average of the maximums, I'm adding them together to get the total amount of video watched.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:29:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145494#M40555</guid>
      <dc:creator>cvervais</dc:creator>
      <dc:date>2020-09-28T16:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: Timecharting the sum of a max value in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145495#M40556</link>
      <description>&lt;P&gt;If I want I can break it down by user_id in the time chart which is nice. Dumb question though, is there a way on the time chart to convert the vertical axis to minutes by dividing the result by 60? &lt;/P&gt;

&lt;P&gt;I'm going to go googling to try and find out too. I'm also going to see if anyone I know at Splunk is going to Hamburg and sending them with some euros to buy you a couple of pints.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Apr 2014 15:59:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145495#M40556</guid>
      <dc:creator>cvervais</dc:creator>
      <dc:date>2014-04-29T15:59:42Z</dc:date>
    </item>
    <item>
      <title>Re: Timecharting the sum of a max value in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145496#M40557</link>
      <description>&lt;P&gt;Take a look at the &lt;CODE&gt;per_minute()&lt;/CODE&gt; functions: &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0.3/SearchReference/CommonStatsFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/6.0.3/SearchReference/CommonStatsFunctions&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I'm not driving so keep 'em coming &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Apr 2014 16:43:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145496#M40557</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-04-29T16:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: Timecharting the sum of a max value in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145497#M40558</link>
      <description>&lt;P&gt;Not sure per_minute() is what I'm after. per_minute() seems to be more about how many events per minute. What I'm interested in is taking the value of position and dividing it by 60. &lt;/P&gt;

&lt;P&gt;Also, can you edit your answer to put the winning search in it so I can up vote it and mark it answered?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:29:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145497#M40558</guid>
      <dc:creator>cvervais</dc:creator>
      <dc:date>2020-09-28T16:29:42Z</dc:date>
    </item>
    <item>
      <title>Re: Timecharting the sum of a max value in a field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145498#M40559</link>
      <description>&lt;P&gt;Divide it by 60 then.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval field = field / 60
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Apr 2014 17:32:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timecharting-the-sum-of-a-max-value-in-a-field/m-p/145498#M40559</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-04-29T17:32:11Z</dc:date>
    </item>
  </channel>
</rss>

