<?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: Splunk calculate sequential sum for every timestamp in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-calculate-sequential-sum-for-every-timestamp/m-p/465370#M191680</link>
    <description>&lt;P&gt;Have you tried the &lt;CODE&gt;streamstats&lt;/CODE&gt; command? This is a rolling computation, so you can sum that value for each row, and evaluate the total accuracy for each row (not just the 6th and 7th), and use that as the value for the dashboard over time. &lt;/P&gt;

&lt;P&gt;The docs can be found here: &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.2/SearchReference/Streamstats#Basic_examples"&gt;https://docs.splunk.com/Documentation/Splunk/7.3.2/SearchReference/Streamstats#Basic_examples&lt;/A&gt; but the syntax is quite similar to &lt;CODE&gt;eventstats&lt;/CODE&gt; (i.e. &lt;CODE&gt;| streamstats  sum(x)&lt;/CODE&gt;). There are some other cool optional arguments around when you want to stop rolling that sum, so you should definitely check out the docs.&lt;/P&gt;

&lt;P&gt;Also as a small syntax note: you could have done both of your &lt;CODE&gt;eventstats&lt;/CODE&gt; computations in one command call, similar to a stats (i.e.: &lt;CODE&gt;| eventstats sum(total_dates_correct) as TOTAL_CORRECT, sum(total_datetypes) as TOTAL&lt;/CODE&gt; will also work, because you aren't doing any additional split by clauses that might have different buckets between the two).&lt;/P&gt;

&lt;P&gt;Let me know if this helps/you have any other questions!&lt;/P&gt;</description>
    <pubDate>Wed, 23 Oct 2019 23:19:40 GMT</pubDate>
    <dc:creator>aberkow</dc:creator>
    <dc:date>2019-10-23T23:19:40Z</dc:date>
    <item>
      <title>Splunk calculate sequential sum for every timestamp</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-calculate-sequential-sum-for-every-timestamp/m-p/465369#M191679</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
I would like to create fields (or a field with multiple values) which represents the sum for each timestamp.&lt;/P&gt;

&lt;P&gt;For example, if I have data like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;10/23/19
10:37:01.000 AM 
urlupdateid=6, urlid=1, payer=Aetna, ReviewDate_datetype_correct=true, ReviewDate_date_correct=true, total_datetypes_correct=1, total_dates_correct=1, total_datetypes=1

10/17/19
3:18:48.000 PM  
urlupdateid=5, urlid=1, payer=Aetna, RetiredDate_datetype_correct=false, RetiredDate_date_correct=false, total_datetypes_correct=0, total_dates_correct=0, total_datetypes=1

10/17/19
3:18:48.000 PM  
urlupdateid=4, urlid=1, payer=Aetna, EffectiveDate_datetype_correct=true, EffectiveDate_date_correct=false, total_datetypes_correct=1, total_dates_correct=0, total_datetypes=1

10/17/19
3:18:48.000 PM  
urlupdateid=3, urlid=1, payer=Aetna, EffectiveDate_datetype_correct=false, EffectiveDate_date_correct=false, total_datetypes_correct=0, total_dates_correct=0, total_datetypes=1

10/17/19
3:18:48.000 PM  
urlupdateid=2, urlid=1, payer=Aetna, ReviewDate_datetype_correct=true, ReviewDate_date_correct=false, total_datetypes_correct=1, total_dates_correct=0, total_datetypes=1

10/17/19
3:18:48.000 PM  
urlupdateid=1, urlid=1, payer=Aetna, PublicationDate_datetype_correct=true, PublicationDate_date_correct=true, ReviewDate_datetype_correct=true, ReviewDate_date_correct=true, total_datetypes_correct=2, total_dates_correct=2, total_datetypes=2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The result would be two data points from sum(total_dates_correct) / sum(total_datetypes): &lt;BR /&gt;
one where TOTAL_ACCURACY = 2/6 (from all the events with the timestamp 10/17/19 3:18:48.000 PM) and one another where TOTAL_ACCURACY = 3/7 (from all events including both timestamp 10/17/19 3:18:48.000 PM and  10/23/19 10:37:01.000 AM)&lt;/P&gt;

&lt;P&gt;How would I do this? This query does not work because TOTAL_ACCURACY only reflects the accuracy up to the current timestamp: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventstats sum(total_dates_correct) as TOTAL_CORRECT | eventstats sum(total_datetypes) as TOTAL | eval TOTAL_ACCURACY = (TOTAL_CORRECT / TOTAL) * 100
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Ideally, I would like to create a dashboard that shows the accuracy over the time range that is changeable in the search.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:41:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-calculate-sequential-sum-for-every-timestamp/m-p/465369#M191679</guid>
      <dc:creator>ruhtraeel</dc:creator>
      <dc:date>2020-09-30T02:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk calculate sequential sum for every timestamp</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-calculate-sequential-sum-for-every-timestamp/m-p/465370#M191680</link>
      <description>&lt;P&gt;Have you tried the &lt;CODE&gt;streamstats&lt;/CODE&gt; command? This is a rolling computation, so you can sum that value for each row, and evaluate the total accuracy for each row (not just the 6th and 7th), and use that as the value for the dashboard over time. &lt;/P&gt;

&lt;P&gt;The docs can be found here: &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.2/SearchReference/Streamstats#Basic_examples"&gt;https://docs.splunk.com/Documentation/Splunk/7.3.2/SearchReference/Streamstats#Basic_examples&lt;/A&gt; but the syntax is quite similar to &lt;CODE&gt;eventstats&lt;/CODE&gt; (i.e. &lt;CODE&gt;| streamstats  sum(x)&lt;/CODE&gt;). There are some other cool optional arguments around when you want to stop rolling that sum, so you should definitely check out the docs.&lt;/P&gt;

&lt;P&gt;Also as a small syntax note: you could have done both of your &lt;CODE&gt;eventstats&lt;/CODE&gt; computations in one command call, similar to a stats (i.e.: &lt;CODE&gt;| eventstats sum(total_dates_correct) as TOTAL_CORRECT, sum(total_datetypes) as TOTAL&lt;/CODE&gt; will also work, because you aren't doing any additional split by clauses that might have different buckets between the two).&lt;/P&gt;

&lt;P&gt;Let me know if this helps/you have any other questions!&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2019 23:19:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-calculate-sequential-sum-for-every-timestamp/m-p/465370#M191680</guid>
      <dc:creator>aberkow</dc:creator>
      <dc:date>2019-10-23T23:19:40Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk calculate sequential sum for every timestamp</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-calculate-sequential-sum-for-every-timestamp/m-p/465371#M191681</link>
      <description>&lt;P&gt;The only problem with this is that it wouldn't take weighting into account. If I calculate the total accuracy for each row using streamstats and then average that out, I'd run into this problem:&lt;/P&gt;

&lt;P&gt;Event 1:&lt;BR /&gt;
Accuracy: 100%, total dates = 1, dates correct = 1&lt;/P&gt;

&lt;P&gt;Event 2:&lt;BR /&gt;
Accuracy: 0%, total dates = 10, dates correct = 0&lt;/P&gt;

&lt;P&gt;Accuracy: &lt;BR /&gt;
50% (even though it should be 1/11 = 9.1%) &lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2019 23:39:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-calculate-sequential-sum-for-every-timestamp/m-p/465371#M191681</guid>
      <dc:creator>ruhtraeel</dc:creator>
      <dc:date>2019-10-23T23:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk calculate sequential sum for every timestamp</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-calculate-sequential-sum-for-every-timestamp/m-p/465372#M191682</link>
      <description>&lt;P&gt;With &lt;CODE&gt;streamstats&lt;/CODE&gt;? It should weight, because the sum of total dates would be 11 and the sum of total dates correct would be 1. &lt;/P&gt;

&lt;P&gt;What I was thinking:&lt;BR /&gt;
&lt;CODE&gt;base search...&lt;BR /&gt;
| streamstats sum(total_dates_correct) as totalDatesCorrectRunning, sum(total_date_types) as totalDatesRunning&lt;BR /&gt;
| eval runningAverage=totalDatesCorrectRunning/totalDatesRunning&lt;/CODE&gt;&lt;BR /&gt;
This generates an average which should be correctly weighted by day, is this still not the case?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2019 00:12:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-calculate-sequential-sum-for-every-timestamp/m-p/465372#M191682</guid>
      <dc:creator>aberkow</dc:creator>
      <dc:date>2019-10-24T00:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk calculate sequential sum for every timestamp</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-calculate-sequential-sum-for-every-timestamp/m-p/465373#M191683</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| stats count
| eval raw="10/23/19 10:37:01.000 AM urlupdateid=6, urlid=1, payer=Aetna, ReviewDate_datetype_correct=true, ReviewDate_date_correct=true, total_datetypes_correct=1, total_dates_correct=1, total_datetypes=1
10/17/19 3:18:48.000 PM urlupdateid=5, urlid=1, payer=Aetna, RetiredDate_datetype_correct=false, RetiredDate_date_correct=false, total_datetypes_correct=0, total_dates_correct=0, total_datetypes=1
10/17/19 3:18:48.000 PM urlupdateid=4, urlid=1, payer=Aetna, EffectiveDate_datetype_correct=true, EffectiveDate_date_correct=false, total_datetypes_correct=1, total_dates_correct=0, total_datetypes=1
10/17/19 3:18:48.000 PM urlupdateid=3, urlid=1, payer=Aetna, EffectiveDate_datetype_correct=false, EffectiveDate_date_correct=false, total_datetypes_correct=0, total_dates_correct=0, total_datetypes=1
10/17/19 3:18:48.000 PM urlupdateid=2, urlid=1, payer=Aetna, ReviewDate_datetype_correct=true, ReviewDate_date_correct=false, total_datetypes_correct=1, total_dates_correct=0, total_datetypes=1
10/17/19 3:18:48.000 PM urlupdateid=1, urlid=1, payer=Aetna, PublicationDate_datetype_correct=true, PublicationDate_date_correct=true, ReviewDate_datetype_correct=true, ReviewDate_date_correct=true, total_datetypes_correct=2, total_dates_correct=2, total_datetypes=2"
| makemv delim="
" raw
| mvexpand raw
| rex field=raw "(?&amp;lt;time&amp;gt;^.+(AM|PM))"
| rex field=raw "total_dates_correct=(?&amp;lt;total_dates_correct&amp;gt;\d), total_datetypes=(?&amp;lt;total_datetypes&amp;gt;\d)"
| eval _time=strptime(time,"%m/%d/%y %H:%M:%S.%3Q")
| table _time total_dates_correct total_datetypes
`comment("this is sample data")`
| timechart span=1d sum(total_dates_correct) as TOTAL_CORRECT sum(total_datetypes) as TOTAL 
| eval TOTAL_ACCURACY = (TOTAL_CORRECT / TOTAL) * 100
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi, this is sample query.&lt;/P&gt;

&lt;P&gt;For example, search period is one month,&lt;BR /&gt;
If you change &lt;CODE&gt;span =&lt;/CODE&gt; to &lt;CODE&gt;2week&lt;/CODE&gt;, you will get the expected results.&lt;BR /&gt;
Wouldn't it be nice to make it a dashboard and give it as a token?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2019 13:03:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-calculate-sequential-sum-for-every-timestamp/m-p/465373#M191683</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-10-24T13:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk calculate sequential sum for every timestamp</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-calculate-sequential-sum-for-every-timestamp/m-p/465374#M191684</link>
      <description>&lt;P&gt;I think you're right; I tested out that query, and it seems to keep track of the running average correctly. I've encountered another problem; how would I plot this as a chart, with X being the time and Y being the runningAverage? I tried doing this: &lt;BR /&gt;
    | table _time runningAverage&lt;BR /&gt;
But this messes up the _time column, as this makes the earliest date (10/17/19 3:18:48.000 PM) have the latest running average (42%), and the most recent event have a running average of 100% (which is actually the running average after the first event)&lt;/P&gt;

&lt;P&gt;Ideally, there would be two points in the graph, one representing the final running average on 10/17/19&lt;BR /&gt;
 3:18:48.000&lt;/P&gt;

&lt;P&gt;and another point with the running average on &lt;BR /&gt;
10/23/19&lt;BR /&gt;
 10:37:01.000&lt;/P&gt;

&lt;P&gt;and another with the running average on  &lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2019 17:38:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-calculate-sequential-sum-for-every-timestamp/m-p/465374#M191684</guid>
      <dc:creator>ruhtraeel</dc:creator>
      <dc:date>2019-10-28T17:38:04Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk calculate sequential sum for every timestamp</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-calculate-sequential-sum-for-every-timestamp/m-p/465375#M191685</link>
      <description>&lt;P&gt;Can you add a &lt;CODE&gt;sort&lt;/CODE&gt; on the _time field before you run streamstats? This should persist through:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| sort _time asc&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The params you can play around with for sort are +/-, asc/desc, and the limit on how many fields to sort: &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/sort#Syntax"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/sort#Syntax&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2019 17:57:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-calculate-sequential-sum-for-every-timestamp/m-p/465375#M191685</guid>
      <dc:creator>aberkow</dc:creator>
      <dc:date>2019-10-28T17:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk calculate sequential sum for every timestamp</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-calculate-sequential-sum-for-every-timestamp/m-p/465376#M191686</link>
      <description>&lt;P&gt;Why did you abandon this Q&amp;amp;A without even commenting on the efficacy of the answers?&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/778366/find-interval-sums-of-a-field-and-display-it-in-a.html#answer-778911"&gt;https://answers.splunk.com/answers/778366/find-interval-sums-of-a-field-and-display-it-in-a.html#answer-778911&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 00:54:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-calculate-sequential-sum-for-every-timestamp/m-p/465376#M191686</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-10-29T00:54:20Z</dc:date>
    </item>
  </channel>
</rss>

