<?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: Comparing value of same fields derrived from Rex command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-value-of-same-fields-derived-from-rex-command/m-p/588125#M204819</link>
    <description>&lt;P&gt;The rex is not important - it's just extracting a field from your data.&lt;/P&gt;&lt;P&gt;I assumed when you posted "today" and "yesterday", you had some existing daily data.&lt;/P&gt;&lt;P&gt;So, this CSV - are you saying that the 'previous' event could be ANY time interval prior to the current?&lt;/P&gt;&lt;P&gt;Can you show an example of your data and any existing query. If you say it's a CSV - are you doing inputlookup to get the data in the first place?&lt;/P&gt;&lt;P&gt;Doing the calculation is easy with the streamstats example I gave - but what comes before is important as to whether it works for you.&lt;/P&gt;&lt;P&gt;Either delta or streamstats will be the solution, but I'd like to better understand what your output looks like, as the stats command you show would not result in the 'Counters:' example, so I'm not sure what will work for your data&lt;/P&gt;</description>
    <pubDate>Tue, 08 Mar 2022 22:23:54 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2022-03-08T22:23:54Z</dc:date>
    <item>
      <title>How to compare the value of same fields derived from rex command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-value-of-same-fields-derived-from-rex-command/m-p/588117#M204813</link>
      <description>&lt;P&gt;hi i am hoping for some help regarding this. basically i would like to compare (subtract current to previous) the value of REX command on the latest data versus previous events REX command data.&lt;/P&gt;
&lt;P&gt;today&lt;/P&gt;
&lt;P&gt;Counters:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Reset&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Uptime&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Lifetime&lt;BR /&gt;Messages Received 13,524,598&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 13,524,585&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 13,524,598&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Yesterday&lt;/P&gt;
&lt;P&gt;Counters:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Reset&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Uptime&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Lifetime&lt;BR /&gt;Messages Received 12,524,598&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 12,524,585&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 12,524,598&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;current filter&lt;/P&gt;
&lt;P&gt;| rex field="status detail" "(?&amp;lt;message_received_name&amp;gt;Messages Received)\\s*[0-9,]*\s*[0-9,]*\s*(?&amp;lt;message_received&amp;gt;[0-9,]*)"&lt;BR /&gt;| rex field="status detail" "(?&amp;lt;current_time_text&amp;gt;Status as of:)\s*(?&amp;lt;query_time&amp;gt;.*)GMT"&lt;BR /&gt;| stats latest(message_received_name) as Counter_Name latest(message_received) as Messages_Received latest(query_time) as Query_Time by Hostname&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;how can i use the same search on the previous event, so i can find the difference of "message_received"&lt;/P&gt;
&lt;P&gt;thanks,&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 21:46:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-value-of-same-fields-derived-from-rex-command/m-p/588117#M204813</guid>
      <dc:creator>thaghost99</dc:creator>
      <dc:date>2022-03-08T21:46:37Z</dc:date>
    </item>
    <item>
      <title>Comparing value of same fields derrived from Rex command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-value-of-same-fields-derived-from-rex-command/m-p/588120#M204816</link>
      <description>&lt;P&gt;If you are searching over the entire date range, than when you do your stats you can bin by _time and then calculate the difference using delta, streamstats or autoregress, e.g. this example generates numbers of 4 days and then calculates the deltas of those numbers.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=96
| streamstats c
| eval _time=now()-(c * 3600)
| fields - c
| eval Reset=random() % 1000000, Uptime=Reset, Lifetime=Reset
| bin _time span=1d
| stats sum(*) as * by _time
| delta Lifetime | delta Reset | delta Uptime&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;The same search, but replace the last line with&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| streamstats window=1 current=f values(*) as prev_*
| foreach prev_* [ eval Diff_&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;='&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;'-&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; ]&lt;/LI-CODE&gt;&lt;P&gt;shows how to do it with streamstats&lt;/P&gt;&lt;P&gt;Not sure how that fits into your dataset though, but hopefully the example helps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 21:53:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-value-of-same-fields-derived-from-rex-command/m-p/588120#M204816</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-03-08T21:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing value of same fields derrived from Rex command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-value-of-same-fields-derived-from-rex-command/m-p/588122#M204817</link>
      <description>&lt;P&gt;hi &lt;SPAN class=""&gt;@&lt;/SPAN&gt;bowesmana&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;thanks for the swift response, but i think i got a little more confused. hehe&lt;/P&gt;&lt;P&gt;i am trying to extract the value of "messages received" for "lifetime" using the REX command.&lt;/P&gt;&lt;P&gt;but i would like to compare this LIFETIME value from the previous event (lets assume last event is an hour ago), using the same REX command. i would then like to subtract the value of 'LIFETIME' on the current event and the Previous event.&lt;/P&gt;&lt;P&gt;this would be so much easier if i could make message receive, lifetime as its own field, but this is from a CSV file which is mix with a ton of other data on the same field.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Counters: Reset Uptime Lifetime&lt;BR /&gt;Messages Received 12,524,598 12,524,585 12,524,598&lt;/P&gt;&lt;P&gt;Counters: Reset Uptime Lifetime&lt;BR /&gt;Messages Received 13,524,598 13,524,585 13,524,598&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;so "Message Received" 13,524,598 - 12,524,598 = 1,000,000&lt;/P&gt;&lt;P&gt;so i want to get the 1 million as the final value of message received&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 22:05:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-value-of-same-fields-derived-from-rex-command/m-p/588122#M204817</guid>
      <dc:creator>thaghost99</dc:creator>
      <dc:date>2022-03-08T22:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing value of same fields derrived from Rex command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-value-of-same-fields-derived-from-rex-command/m-p/588125#M204819</link>
      <description>&lt;P&gt;The rex is not important - it's just extracting a field from your data.&lt;/P&gt;&lt;P&gt;I assumed when you posted "today" and "yesterday", you had some existing daily data.&lt;/P&gt;&lt;P&gt;So, this CSV - are you saying that the 'previous' event could be ANY time interval prior to the current?&lt;/P&gt;&lt;P&gt;Can you show an example of your data and any existing query. If you say it's a CSV - are you doing inputlookup to get the data in the first place?&lt;/P&gt;&lt;P&gt;Doing the calculation is easy with the streamstats example I gave - but what comes before is important as to whether it works for you.&lt;/P&gt;&lt;P&gt;Either delta or streamstats will be the solution, but I'd like to better understand what your output looks like, as the stats command you show would not result in the 'Counters:' example, so I'm not sure what will work for your data&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 22:23:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-value-of-same-fields-derived-from-rex-command/m-p/588125#M204819</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-03-08T22:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing value of same fields derrived from Rex command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-value-of-same-fields-derived-from-rex-command/m-p/588127#M204820</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;splunk is currently monitoring a directory and ingesting as data gets put in there. so at the moment its daily schedule, but we can trigger the same script anytime during the day which will put the new csv in the same directory.&lt;/P&gt;&lt;P&gt;my goal is to capture based on previous event from the current one. so the previous event can be the previous day, or if script is triggered manually, the event can be in the previous hour.&amp;nbsp; i just need to compare it with the previous event (dont matter how long it is assuming my time range would show at least 2 events).&lt;/P&gt;&lt;P&gt;data looks something like this.&lt;/P&gt;&lt;P&gt;currently this is what my output looks like. which basically just spits out the current number.&lt;/P&gt;&lt;P&gt;&amp;nbsp;i want to show the Delta&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="thaghost99_0-1646778951575.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/18379iE583D0D24D5C0626/image-size/medium?v=v2&amp;amp;px=400" role="button" title="thaghost99_0-1646778951575.png" alt="thaghost99_0-1646778951575.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 22:36:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-value-of-same-fields-derived-from-rex-command/m-p/588127#M204820</guid>
      <dc:creator>thaghost99</dc:creator>
      <dc:date>2022-03-08T22:36:43Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing value of same fields derrived from Rex command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-value-of-same-fields-derived-from-rex-command/m-p/588308#M204884</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;your rex_statements
| reverse
| streamstats window=1 current=f global=f values(message_received) as prev_message_received by Hostname
| stats latest(message_received_name) as Counter_Name latest(message_received) as Messages_Received latest(query_time) as Query_Time latest(prev_message_received) as prev_Messages_Received by Hostname
| eval diff=Messages_Received-prev_Messages_Received&lt;/LI-CODE&gt;&lt;P&gt;The reverse/streamstats will copy the previous&amp;nbsp;message_received into a new field in the current event called prev_message_received. Then the stats gets both&amp;nbsp;message_received and prev_message_received and finally the diff calculates the difference between the two.&lt;/P&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2022 21:59:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-value-of-same-fields-derived-from-rex-command/m-p/588308#M204884</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-03-09T21:59:14Z</dc:date>
    </item>
  </channel>
</rss>

