<?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: Calculate same event in two different times in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Calculate-same-event-in-two-different-times/m-p/107467#M183384</link>
    <description>&lt;P&gt;For some reasons, I could not get the right result using your query.&lt;/P&gt;</description>
    <pubDate>Wed, 09 Nov 2011 21:30:18 GMT</pubDate>
    <dc:creator>tdnguyen1</dc:creator>
    <dc:date>2011-11-09T21:30:18Z</dc:date>
    <item>
      <title>Calculate same event in two different times</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-same-event-in-two-different-times/m-p/107463#M183380</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am new two splunk. I am wondering is there a way to calculate the delta of RXdropped from 5 minutes apart.&lt;/P&gt;

&lt;P&gt;10:50:00 RXdropped&lt;BR /&gt;
         123&lt;/P&gt;

&lt;P&gt;10:55:00 RXdropped&lt;BR /&gt;
         456&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2011 18:02:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-same-event-in-two-different-times/m-p/107463#M183380</guid>
      <dc:creator>tdnguyen1</dc:creator>
      <dc:date>2011-11-09T18:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate same event in two different times</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-same-event-in-two-different-times/m-p/107464#M183381</link>
      <description>&lt;P&gt;Hello!  Welcome to Splunk!&lt;/P&gt;

&lt;P&gt;If you download the *NIX App, you'll find there is a dashboard for network traffic.&lt;BR /&gt;
Here's the link: &lt;A href="http://splunk-base.splunk.com/apps/22314/splunk-for-unix-and-linux"&gt;http://splunk-base.splunk.com/apps/22314/splunk-for-unix-and-linux&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;This is the search that the *nix app uses:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="os" sourcetype="interfaces" host=*  | multikv fields name, inetAddr, RXbytes, TXbytes  | streamstats current=f last(TXbytes) as lastTX, last(RXbytes) as lastRX by Name   | eval time=_time  | strcat Name "-" inetAddr "@" host Interface_Host  | eval RX_Thruput = lastRX-RXbytes  | eval TX_Thruput = lastTX-TXbytes  | timechart eval(sum(TX_Thruput)/dc(time)) by Interface_Host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In the "streamstats" function, it's creating two new fields: last(Txbytes) as lastTX, and last(Rxbytes) as lastRX. Later it subtracts the last value from the current value with: &lt;BR /&gt;
Eval RX_Thruput=lastRX-Rxbytes &lt;/P&gt;

&lt;P&gt;The last() function gets the most recent value of a field and adds it to the current event.  Remember that the default order of events in Splunk is reverse chronological order, so when an event gets the "last" value of a field it's getting it from a later time, so subtracting the "current" value from the "last" value give us the difference, which is the throughput for the period. &lt;/P&gt;

&lt;P&gt;Best regards,&lt;BR /&gt;
Jon&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2011 18:27:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-same-event-in-two-different-times/m-p/107464#M183381</guid>
      <dc:creator>Jon_Webster</dc:creator>
      <dc:date>2011-11-09T18:27:39Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate same event in two different times</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-same-event-in-two-different-times/m-p/107465#M183382</link>
      <description>&lt;P&gt;Hi Jon,&lt;/P&gt;

&lt;P&gt;Thanks for your fast response. I really appreciated that. The result is not what I expected. I am looking for the delta. Something like this.&lt;/P&gt;

&lt;P&gt;456 - 123 = 333&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2011 19:23:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-same-event-in-two-different-times/m-p/107465#M183382</guid>
      <dc:creator>tdnguyen1</dc:creator>
      <dc:date>2011-11-09T19:23:32Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate same event in two different times</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-same-event-in-two-different-times/m-p/107466#M183383</link>
      <description>&lt;P&gt;I did this it seems to work for now.&lt;/P&gt;

&lt;P&gt;index=os sourcetype="interfaces" host="prdcg4mdbl03.oss.prd" | multikv | eval PercError_PacketLoss=round(((Error * 100)/(RXbytes+TXbytes)),1) | eval StatusError = if(PercError_PacketLoss &amp;gt;= 1.0, "WARNING", "OK") | eval PercRX_PacketLoss=round(((RXdropped * 100)/RXbytes),1) | eval PercTX_PacketLoss=round(((TXdropped * 100)/TXbytes),1) | eval StatusRX = if(PercRX_PacketLoss &amp;gt;= 1.0, "WARNING", "OK") | eval StatusTX = if(PercTX_PacketLoss &amp;gt;= 1.0, "WARNING", "OK") | table time Name StatusError PercError_PacketLoss StatusRX PercRX_PacketLoss StatusTX  PercTX_PacketLoss&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 10:04:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-same-event-in-two-different-times/m-p/107466#M183383</guid>
      <dc:creator>tdnguyen1</dc:creator>
      <dc:date>2020-09-28T10:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate same event in two different times</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-same-event-in-two-different-times/m-p/107467#M183384</link>
      <description>&lt;P&gt;For some reasons, I could not get the right result using your query.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2011 21:30:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-same-event-in-two-different-times/m-p/107467#M183384</guid>
      <dc:creator>tdnguyen1</dc:creator>
      <dc:date>2011-11-09T21:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate same event in two different times</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-same-event-in-two-different-times/m-p/107468#M183385</link>
      <description>&lt;P&gt;It is calculating the delta.&lt;BR /&gt;
This eval statement subtracts Rxbytes from lastRX and assigns the result to RX_Thruput. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval RX_Thruput=lastRX-Rxbytes 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In other words:  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;lastRX (456) - Rxbytes (123) = RX_Thruput (333)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It's not using RXdropped, but if you use RXdropped you'll get the results you want.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2011 23:25:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-same-event-in-two-different-times/m-p/107468#M183385</guid>
      <dc:creator>Jon_Webster</dc:creator>
      <dc:date>2011-11-09T23:25:55Z</dc:date>
    </item>
  </channel>
</rss>

