<?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 for mathematical difference in stats? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-Splunk-for-mathematical-difference-in-stats/m-p/583998#M203370</link>
    <description>&lt;LI-CODE lang="markup"&gt;| streamstats window=2 global=f range(lastOffset) as difference by clusterId topicName partition
| where timestamp="today_timeStamp"
| stats sum(difference) as events by clusterId topicName&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 07 Feb 2022 18:38:25 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2022-02-07T18:38:25Z</dc:date>
    <item>
      <title>How to use Splunk for mathematical difference in stats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-Splunk-for-mathematical-difference-in-stats/m-p/583988#M203366</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;I would like to try using Splunk to calculate the difference in numbers from one sample to the next. Here is some theoretical log entries.&lt;/P&gt;
&lt;P&gt;The data indexed will look like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;yesterday_timeStamp clusterId=abc, topicName=mytopic, partition=0, lastOffset=100
yesterday_timeStamp clusterId=abc, topicName=mytopic, partition=1, lastOffset=200
today_timeStamp clusterId=abc, topicName=mytopic, partition=0, lastOffset=355
today_timeStamp clusterId=abc, topicName=mytopic, partition=1, lastOffset=401&lt;/LI-CODE&gt;
&lt;P&gt;The number of events in the last 24 hours would be partition 0(355-200=155), partition 1(401-200=201) Sum of partitions for topic(mytopic) = 155+201=356&lt;BR /&gt;There will be many topicName(s) and possible different numbers of partition(s) per topicName.&lt;BR /&gt;Can I use splunk to calculate the numbers of events per partition and topic&amp;nbsp; since yesterday?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2022 18:50:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-Splunk-for-mathematical-difference-in-stats/m-p/583988#M203366</guid>
      <dc:creator>chengka</dc:creator>
      <dc:date>2022-02-24T18:50:16Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk for mathematical difference in stats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-Splunk-for-mathematical-difference-in-stats/m-p/583998#M203370</link>
      <description>&lt;LI-CODE lang="markup"&gt;| streamstats window=2 global=f range(lastOffset) as difference by clusterId topicName partition
| where timestamp="today_timeStamp"
| stats sum(difference) as events by clusterId topicName&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 07 Feb 2022 18:38:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-Splunk-for-mathematical-difference-in-stats/m-p/583998#M203370</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-02-07T18:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk for mathematical difference in stats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-Splunk-for-mathematical-difference-in-stats/m-p/586464#M204288</link>
      <description>&lt;P&gt;Thank you I appreciate the help.&amp;nbsp; I was too literal.&amp;nbsp; The timestamp will be a real date/time.&amp;nbsp; How do I structure this where clause to be the latest?(all events will present the same date/time for each "interval", as described that would be a day)&lt;/P&gt;&lt;P class="lia-align-left lia-indent-padding-left-30px"&gt;| where timestamp="today_timeStamp"&lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2022 18:00:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-Splunk-for-mathematical-difference-in-stats/m-p/586464#M204288</guid>
      <dc:creator>chengka</dc:creator>
      <dc:date>2022-02-24T18:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk for mathematical difference in stats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-Splunk-for-mathematical-difference-in-stats/m-p/586567#M204321</link>
      <description>&lt;P&gt;I still don't see why ITWhisperer's tstats formula should not work, but simple stats should also be able to do the job assuming the "since yesterday" piece is done with search time filter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats max(lastOffset) as maxOffset min(lastOffset) as minOffset by partition topicName clusterId
| eval numEvents=maxOffset - minOffset
| eventstats sum(numEvents) as totalEvents&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One thing I can't figure out is how to derive number of events in&amp;nbsp;&lt;SPAN&gt;partition 0 as 355-200=155; shouldn't it be 355-100=255? (Lines one and three.) &amp;nbsp;Is there a relation that I missed?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The above gives&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;patition&lt;/TD&gt;&lt;TD&gt;topicName&lt;/TD&gt;&lt;TD&gt;clusterId&lt;/TD&gt;&lt;TD&gt;maxOffset&lt;/TD&gt;&lt;TD&gt;minOffset&lt;/TD&gt;&lt;TD&gt;numEvents&lt;/TD&gt;&lt;TD&gt;totalEvents&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;mytopic&lt;/TD&gt;&lt;TD&gt;abc&lt;/TD&gt;&lt;TD&gt;355&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;TD&gt;255&lt;/TD&gt;&lt;TD&gt;456&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;mytopic&lt;/TD&gt;&lt;TD&gt;abc&lt;/TD&gt;&lt;TD&gt;401&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;201&lt;/TD&gt;&lt;TD&gt;456&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 25 Feb 2022 09:24:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-Splunk-for-mathematical-difference-in-stats/m-p/586567#M204321</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-02-25T09:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk for mathematical difference in stats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-Splunk-for-mathematical-difference-in-stats/m-p/586613#M204334</link>
      <description>&lt;P&gt;Thank you. You are correct,&amp;nbsp; 355-200 was a mistake.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 15:14:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-Splunk-for-mathematical-difference-in-stats/m-p/586613#M204334</guid>
      <dc:creator>chengka</dc:creator>
      <dc:date>2022-02-25T15:14:13Z</dc:date>
    </item>
  </channel>
</rss>

