<?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: Using transaction to calculate duration after a dedup doesnt seem in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-when-using-transaction-to-calculate-duration-after-a-dedup/m-p/602996#M209863</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;your solution did the job&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Jun 2022 11:57:40 GMT</pubDate>
    <dc:creator>stuwoodward</dc:creator>
    <dc:date>2022-06-23T11:57:40Z</dc:date>
    <item>
      <title>Why when using transaction to calculate duration after a dedup doesnt return values wanted?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-when-using-transaction-to-calculate-duration-after-a-dedup/m-p/602610#M209755</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I am new to splunk and not a developer so first up apologies for any poor syntax or coding practices.&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;What am I trying to do?&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The information that i need to show when a batch starts and ends is in different formats in different logs&lt;/LI&gt;
&lt;LI&gt;I am trying to come up with a table that shows how long it takes to run each batch of transactions.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;What is in the logs?&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;There is a batch id in each of the logs but in a different format so i use regex to extract it. This is what I want to group on&lt;/LI&gt;
&lt;LI&gt;There is a unique string in 1 log per batch which contains "Found the last" which is my end time&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;For each transaction in the batch there is a log which contains ""After payload". If there are 100 entries in the batch there are 100 logs with this message. I want to use the first of these logs as my start time.
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;How am I trying to do it?&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;I am filtering out any unneccesary logs by only looking for logs that have the message that I want which works&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;source="batch-queue-receiver.log"
| rex field=_raw "[\? ]Batch\s?[iI][dD]\s?: (?&amp;lt;Batchid&amp;gt;.{7}+)"
| rex field=_raw "[\? ]MerchantId: (?&amp;lt;Merchantid&amp;gt;.{7}+)"
| rex field=_raw "[\? ]INFO a.c.s.b.q..+- (?&amp;lt;info&amp;gt;.{14}+)"
| where Batchid != ""
| where info = "Found the last" OR info = "After payload "&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;I then want to use transaction to group by batch. This works but because I have multiple entries per batch it takes the last entry not the first so my duration is much smaller than expected&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;source="batch-queue-receiver.log"
| rex field=_raw "[\? ]Batch\s?[iI][dD]\s?: (?&amp;lt;Batchid&amp;gt;.{7}+)"
| rex field=_raw "[\? ]MerchantId: (?&amp;lt;Merchantid&amp;gt;.{7}+)"
| rex field=_raw "[\? ]INFO a.c.s.b.q..+- (?&amp;lt;info&amp;gt;.{14}+)"
| where Batchid != ""
| where info = "Found the last" OR info = "After payload "
| transaction Batchid startswith="After payload conversion" endswith="Found the last message of the batch" mvlist=true| table Batchid duration&lt;/LI-CODE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="stuwoodward_2-1655815642079.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/20201i89164279469BDC91/image-size/medium?v=v2&amp;amp;px=400" role="button" title="stuwoodward_2-1655815642079.png" alt="stuwoodward_2-1655815642079.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I then try to dedup but get no values returned&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;source="batch-queue-receiver.log"
| rex field=_raw "[\? ]Batch\s?[iI][dD]\s?: (?&amp;lt;Batchid&amp;gt;.{7}+)"
| rex field=_raw "[\? ]MerchantId: (?&amp;lt;Merchantid&amp;gt;.{7}+)"
| rex field=_raw "[\? ]INFO a.c.s.b.q..+- (?&amp;lt;info&amp;gt;.{14}+)"
| where Batchid != ""
| where info = "Found the last" OR info = "After payload "
| dedup info Batchid sortby +_time
| table Merchantid Batchid _time info _raw
| transaction Batchid startswith="After payload conversion" endswith="Found the last message of the batch" mvlist=true| table Batchid duration&lt;/LI-CODE&gt;
&lt;P&gt;If I remove the transaction but keep the dedup I get only two messages per batchid (what I want) so I am not sure what is going wrong . It appears that I can't do a transaction after a dedup but it is probably something else I am not aware of. Any help would be appreciated.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;source="batch-queue-receiver.log"
| rex field=_raw "[\? ]Batch\s?[iI][dD]\s?: (?&amp;lt;Batchid&amp;gt;.{7}+)"
| rex field=_raw "[\? ]MerchantId: (?&amp;lt;Merchantid&amp;gt;.{7}+)"
| rex field=_raw "[\? ]INFO a.c.s.b.q..+- (?&amp;lt;info&amp;gt;.{14}+)"
| where Batchid != ""
| where info = "Found the last" OR info = "After payload "
| dedup info Batchid sortby +_time
| table Batchid _time info&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&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="stuwoodward_1-1655815486836.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/20200i898B28D13EB61DBC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="stuwoodward_1-1655815486836.png" alt="stuwoodward_1-1655815486836.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 15:24:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-when-using-transaction-to-calculate-duration-after-a-dedup/m-p/602610#M209755</guid>
      <dc:creator>stuwoodward</dc:creator>
      <dc:date>2022-06-22T15:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: Using transaction to calculate duration after a dedup doesnt seem</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-when-using-transaction-to-calculate-duration-after-a-dedup/m-p/602753#M209803</link>
      <description>&lt;P&gt;Rather than using transaction, you could use stats&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=_raw "[\? ]Batch\s?[iI][dD]\s?: (?&amp;lt;Batchid&amp;gt;.{7}+)"
| rex field=_raw "[\? ]MerchantId: (?&amp;lt;Merchantid&amp;gt;.{7}+)"
| rex field=_raw "[\? ]INFO a.c.s.b.q..+- (?&amp;lt;first&amp;gt;After payload )"
| rex field=_raw "[\? ]INFO a.c.s.b.q..+- (?&amp;lt;last&amp;gt;Found the last)"
| where isnotnull(first) OR isnotnull(last)
| eval firsttime=if(isnotnull(first),_time,null())
| eval lasttime=if(isnotnull(last),_time,null())
| stats earliest(firsttime) as firsttime latest(lasttime) as lasttime by Batchid
| eval duration = lasttime-firsttime&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 22 Jun 2022 09:00:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-when-using-transaction-to-calculate-duration-after-a-dedup/m-p/602753#M209803</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-06-22T09:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: Using transaction to calculate duration after a dedup doesnt seem</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-when-using-transaction-to-calculate-duration-after-a-dedup/m-p/602996#M209863</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;your solution did the job&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2022 11:57:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-when-using-transaction-to-calculate-duration-after-a-dedup/m-p/602996#M209863</guid>
      <dc:creator>stuwoodward</dc:creator>
      <dc:date>2022-06-23T11:57:40Z</dc:date>
    </item>
  </channel>
</rss>

