<?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: How to subtract two fields? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125977#M34085</link>
    <description>&lt;P&gt;From the docs:&lt;/P&gt;

&lt;P&gt;startswith = A search or eval filtering expression which, if satisfied by an event, marks the beginning of a new transaction. &lt;BR /&gt;
endswith = A search or eval filtering expression which, if satisfied by an event, marks the end of a transaction. &lt;/P&gt;

&lt;P&gt;So startswith should be a string or &lt;CODE&gt;eval&lt;/CODE&gt; expression that identifies an event as the start of a transaction, and endswith should be a string or &lt;CODE&gt;eval&lt;/CODE&gt; expression that identifies an event as the end of a transaction.  See the docs on &lt;CODE&gt;transaction&lt;/CODE&gt; &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Transaction"&gt;here&lt;/A&gt;.&lt;/P&gt;

&lt;P&gt;Your new &lt;CODE&gt;Difference&lt;/CODE&gt; field will be over in the left side of the screen with the rest of the fields.&lt;/P&gt;</description>
    <pubDate>Tue, 03 Feb 2015 21:33:31 GMT</pubDate>
    <dc:creator>wpreston</dc:creator>
    <dc:date>2015-02-03T21:33:31Z</dc:date>
    <item>
      <title>How to subtract two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125965#M34073</link>
      <description>&lt;P&gt;I extracted 2 fields called 'Request' and 'Response'...Both these fields are integers. &lt;/P&gt;

&lt;P&gt;How do I display the difference between the Response field and request field?&lt;/P&gt;</description>
      <pubDate>Tue, 03 Feb 2015 20:00:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125965#M34073</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2015-02-03T20:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125966#M34074</link>
      <description>&lt;P&gt;index=test | eval new_field = field1 - field2&lt;/P&gt;</description>
      <pubDate>Tue, 03 Feb 2015 20:07:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125966#M34074</guid>
      <dc:creator>aakwah</dc:creator>
      <dc:date>2015-02-03T20:07:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125967#M34075</link>
      <description>&lt;P&gt;Where would the output (the difference) be located? It's running the search and showing results but I do not see the new field 'Difference' anywhere in my search &lt;/P&gt;

&lt;P&gt;I have: &lt;BR /&gt;
index=test | eval Difference=Response-Request &lt;/P&gt;</description>
      <pubDate>Tue, 03 Feb 2015 20:12:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125967#M34075</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2015-02-03T20:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125968#M34076</link>
      <description>&lt;P&gt;Are &lt;CODE&gt;Response&lt;/CODE&gt; and &lt;CODE&gt;Request&lt;/CODE&gt; in the same event or are they in separate events?&lt;/P&gt;</description>
      <pubDate>Tue, 03 Feb 2015 20:15:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125968#M34076</guid>
      <dc:creator>wpreston</dc:creator>
      <dc:date>2015-02-03T20:15:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125969#M34077</link>
      <description>&lt;P&gt;you should find a new field added to interesting fields on the left hand side called Difference &lt;/P&gt;</description>
      <pubDate>Tue, 03 Feb 2015 20:17:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125969#M34077</guid>
      <dc:creator>aakwah</dc:creator>
      <dc:date>2015-02-03T20:17:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125970#M34078</link>
      <description>&lt;P&gt;Separate events.. I have a web service call which has a request/response pair. So I extracted the time from the request field then I did a search for the response field and extracted the time from the response. So now I want to have a new field which holds the difference from the response and request &lt;/P&gt;</description>
      <pubDate>Tue, 03 Feb 2015 20:20:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125970#M34078</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2015-02-03T20:20:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125971#M34079</link>
      <description>&lt;P&gt;Ok if they are in separate events you will first need to link them together using either &lt;CODE&gt;stats&lt;/CODE&gt; or &lt;CODE&gt;transaction&lt;/CODE&gt;.  If you post some sample events we can help with correlating them if you need it.  After you've linked/correlated the events you can use &lt;CODE&gt;eval&lt;/CODE&gt; to get the difference in &lt;CODE&gt;Response&lt;/CODE&gt; and &lt;CODE&gt;Request&lt;/CODE&gt;.  As a generic example, something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... search terms here ... | transaction startswith="Request" endswith="Response" maxevents=2 | eval Difference=Response-Request
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Feb 2015 20:30:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125971#M34079</guid>
      <dc:creator>wpreston</dc:creator>
      <dc:date>2015-02-03T20:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125972#M34080</link>
      <description>&lt;P&gt;Yeah I see the 'Difference' field under Interesting fields but nothing is showing up when I click on it. Any suggestions? &lt;/P&gt;</description>
      <pubDate>Tue, 03 Feb 2015 20:34:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125972#M34080</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2015-02-03T20:34:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125973#M34081</link>
      <description>&lt;P&gt;I think @wpreston answer above is suitable as the events are separate &lt;/P&gt;</description>
      <pubDate>Tue, 03 Feb 2015 20:38:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125973#M34081</guid>
      <dc:creator>aakwah</dc:creator>
      <dc:date>2015-02-03T20:38:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125974#M34082</link>
      <description>&lt;P&gt;Yeah each request/response pair has a unique identifier.. So if I have the request and I want to find the response I can input that identifier (called a GUID) into the search and I can see both the request and response. So would my search look something like this?&lt;/P&gt;&lt;P&gt;...| transaction GUID="FF79-I348-3847" startswith="Request" endswith="Response" maxevents=2 | eval Difference=Response-Request&lt;/P&gt;</description>
      <pubDate>Tue, 03 Feb 2015 20:41:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125974#M34082</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2015-02-03T20:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125975#M34083</link>
      <description>&lt;P&gt;Very close!  You don't have to put a specific GUID into the transaction statement, you just have to tell &lt;CODE&gt;transaction&lt;/CODE&gt; which field to use to correlate the events.  It would be this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| transaction GUID startswith="Request" endswith="Response" maxevents=2 | eval Difference=Response-Request
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Feb 2015 21:09:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125975#M34083</guid>
      <dc:creator>wpreston</dc:creator>
      <dc:date>2015-02-03T21:09:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125976#M34084</link>
      <description>&lt;P&gt;It's still not working, it's returning "results not found". I'm thinking it may be something to do with the startswith and endswith. The startswith should have the first word of the event and the endswith should have the last word of the event right? Where would I see the 'Difference' (output)? Would it be where the other fields are? &lt;/P&gt;</description>
      <pubDate>Tue, 03 Feb 2015 21:23:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125976#M34084</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2015-02-03T21:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125977#M34085</link>
      <description>&lt;P&gt;From the docs:&lt;/P&gt;

&lt;P&gt;startswith = A search or eval filtering expression which, if satisfied by an event, marks the beginning of a new transaction. &lt;BR /&gt;
endswith = A search or eval filtering expression which, if satisfied by an event, marks the end of a transaction. &lt;/P&gt;

&lt;P&gt;So startswith should be a string or &lt;CODE&gt;eval&lt;/CODE&gt; expression that identifies an event as the start of a transaction, and endswith should be a string or &lt;CODE&gt;eval&lt;/CODE&gt; expression that identifies an event as the end of a transaction.  See the docs on &lt;CODE&gt;transaction&lt;/CODE&gt; &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Transaction"&gt;here&lt;/A&gt;.&lt;/P&gt;

&lt;P&gt;Your new &lt;CODE&gt;Difference&lt;/CODE&gt; field will be over in the left side of the screen with the rest of the fields.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Feb 2015 21:33:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125977#M34085</guid>
      <dc:creator>wpreston</dc:creator>
      <dc:date>2015-02-03T21:33:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125978#M34086</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;It's still not working, it's returning&lt;BR /&gt;
"results not found". &lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Is GUID an extracted field?&lt;/P&gt;</description>
      <pubDate>Tue, 03 Feb 2015 21:38:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125978#M34086</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2015-02-03T21:38:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125979#M34087</link>
      <description>&lt;P&gt;Yes I extracted the unique identifier (FF79-I348-3847) and named it GUID &lt;/P&gt;</description>
      <pubDate>Tue, 03 Feb 2015 21:40:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125979#M34087</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2015-02-03T21:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125980#M34088</link>
      <description>&lt;P&gt;I finally figured it out! The transaction command automatically took the difference but I just had to use 'duration'.. Below is my query for others who may need help &lt;/P&gt;

&lt;P&gt;... | transaction GUID startswith="CalculateTaxRequest" endswith="CalculateTaxResponse" | top GUID  by duration&lt;/P&gt;</description>
      <pubDate>Thu, 05 Feb 2015 14:18:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/125980#M34088</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2015-02-05T14:18:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/694282#M236157</link>
      <description>&lt;P&gt;hey a little years late but I'm just wondering if you changed the timestamp into epoch time before using the transaction command&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 11:08:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/694282#M236157</guid>
      <dc:creator>sintjm</dc:creator>
      <dc:date>2024-07-25T11:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/694283#M236158</link>
      <description>&lt;P&gt;hey a little years late but I'm just wondering if you changed the timestamp into epoch time before using the transaction command?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 11:29:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/694283#M236158</guid>
      <dc:creator>sintjm</dc:creator>
      <dc:date>2024-07-25T11:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/694288#M236160</link>
      <description>&lt;P&gt;Hi &lt;A href="https://community.splunk.com/t5/user/viewprofilepage/user-id/177720" target="_blank"&gt;&lt;SPAN style="color:var(--ck-color-mention-text);"&gt;&lt;U&gt;&lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;@sintjm&lt;/SPAN&gt; &lt;/U&gt;&lt;/SPAN&gt;&lt;/A&gt;,&lt;/P&gt;
&lt;P&gt;I’m a Community Moderator in the Splunk Community.&lt;/P&gt;
&lt;P&gt;This question was posted 8 years ago, so it might not get the attention you need for your question to be answered. We recommend that you post a new question so that your issue can get the &amp;nbsp;visibility it deserves. To increase your chances of getting help from the community, follow &lt;A href="http://docs.splunk.com/Documentation/Splunkbase/splunkbase/Answers/Questions" target="_blank"&gt;&lt;U&gt;these guidelines&lt;/U&gt;&lt;/A&gt; in the Splunk Answers User Manual when creating your post.&lt;/P&gt;
&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 12:07:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-fields/m-p/694288#M236160</guid>
      <dc:creator>DanielPi</dc:creator>
      <dc:date>2024-07-25T12:07:14Z</dc:date>
    </item>
  </channel>
</rss>

