<?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: Parsing different time fields for transactions in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Parsing-different-time-fields-for-transactions/m-p/650587#M224922</link>
    <description>&lt;P&gt;Unfortunately, this didn't work for me. Still, no idea why those events are not found&lt;/P&gt;</description>
    <pubDate>Fri, 14 Jul 2023 15:43:52 GMT</pubDate>
    <dc:creator>heorhii12412</dc:creator>
    <dc:date>2023-07-14T15:43:52Z</dc:date>
    <item>
      <title>Parsing different time fields for transactions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Parsing-different-time-fields-for-transactions/m-p/649856#M224684</link>
      <description>&lt;P&gt;Hello everyone, I have a bit of a strange requirement, which includes close work with time values.&amp;nbsp;&lt;BR /&gt;I have Splunk events in the following format:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;   event_time: 2023-06-29T14:49:42.787Z
   shipment_status: delivered
   timestamp: 2023-06-29T14:49:51.069Z
   tracking_number:95AAEC4900000&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Where &lt;STRONG&gt;shipment_status&amp;nbsp;&lt;/STRONG&gt;can have different values, but I need only &lt;STRONG&gt;&lt;EM&gt;in_transit&lt;/EM&gt;&lt;/STRONG&gt; and &lt;STRONG&gt;&lt;EM&gt;delivered&lt;/EM&gt;&lt;/STRONG&gt;, also &lt;STRONG&gt;timestamp&amp;nbsp;&lt;/STRONG&gt;field is basically the same as the built-in&amp;nbsp;&lt;STRONG&gt;_time&amp;nbsp;&lt;/STRONG&gt;field.&lt;BR /&gt;&lt;BR /&gt;I need to group events based on &lt;STRONG&gt;tracking_number&lt;/STRONG&gt; field, and show the percentage of these pairs to the rest of the events, but do that in a way that &lt;STRONG&gt;&lt;EM&gt;in_transit&amp;nbsp;&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;events should have come after &lt;EM&gt;&lt;STRONG&gt;delivered&lt;/STRONG&gt;&lt;/EM&gt; events more than an hour after. The catch is - &lt;U&gt;we should consider the difference between &lt;STRONG&gt;&lt;EM&gt;_time/timestamp&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;field for&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;in_transit&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;event and&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;event_time &lt;/EM&gt;&lt;/STRONG&gt;field for &lt;STRONG&gt;&lt;EM&gt;delivered&lt;/EM&gt;&lt;/STRONG&gt; event&lt;/U&gt;.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;For example, my query:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;event_status="delivered" OR event_status="in_transit"
| transaction tracking_number startswith=event_status=delivered endswith=event_status=in_transit keepevicted=true
| where duration &amp;gt; 3600
| stats sum(eventcount) as eventcount by closed_txn
| eventstats sum(eventcount) as totalcount
| where closed_txn == 1``` remaining eventcount only includes complete transactions ```
| eval percentage = eventcount * 100 / totalcount&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;uses a &lt;STRONG&gt;duration&amp;nbsp;&lt;/STRONG&gt;field, which automatically uses &lt;STRONG&gt;_time&amp;nbsp;&lt;/STRONG&gt;field for both events, but I need to get the duration of &amp;lt;&lt;STRONG&gt;_time/timestamp&lt;/STRONG&gt;(second_event/in_transit)&amp;gt;&amp;nbsp; -&amp;nbsp; &amp;lt;&lt;STRONG&gt;event_time&lt;/STRONG&gt;(first_event/delivered)&amp;gt;&amp;nbsp;= 1h15m(for example), which is more than one hour, so this transaction should be included in the&amp;nbsp;&lt;STRONG&gt;eventcount&amp;nbsp;&lt;/STRONG&gt;calculation.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Basically, I need to change this &lt;STRONG&gt;| where duration &amp;gt; 3600&amp;nbsp;&lt;/STRONG&gt;condition in my query for a correct time calculation of both events in the transaction, fitting what I described earlier.&amp;nbsp;&lt;BR /&gt;I still have not found a way to compare fields for these separate events in the transaction, so could someone offer some help? I will be very grateful for any suggestions or solutions!&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 14:30:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Parsing-different-time-fields-for-transactions/m-p/649856#M224684</guid>
      <dc:creator>heorhii12412</dc:creator>
      <dc:date>2023-07-10T14:30:51Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing different time fields for transactions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Parsing-different-time-fields-for-transactions/m-p/649862#M224685</link>
      <description>&lt;P&gt;Consider altering the _time field of the "delivered" events so the &lt;FONT face="courier new,courier"&gt;transaction&lt;/FONT&gt; command uses the desired timestamps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;event_status="delivered" OR event_status="in_transit"
| eval _time=if(event_status="delivered", strptime(event_time, "%Y-%m-%dT%H:%M:%S.%3N%Z"), _time)
| sort - _time
| transaction tracking_number startswith=event_status=delivered endswith=event_status=in_transit keepevicted=true
| where duration &amp;gt; 3600
| stats sum(eventcount) as eventcount by closed_txn
| eventstats sum(eventcount) as totalcount
| where closed_txn == 1``` remaining eventcount only includes complete transactions ```
| eval percentage = eventcount * 100 / totalcount&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 16:58:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Parsing-different-time-fields-for-transactions/m-p/649862#M224685</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-07-10T16:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing different time fields for transactions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Parsing-different-time-fields-for-transactions/m-p/649868#M224686</link>
      <description>&lt;P&gt;Good solution! I didn't even know we could intervene in the fields to this extent. But this solution didn't work for me. Splunk gives&amp;nbsp;&lt;STRONG&gt;Error in 'transaction' command: This search requires events to be in descending time order, but the preceding search does not guarantee time-ordered events.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;I don't really understand the problem, if the conditions are not met, then why not ignore this transaction in the final calculation? Probably has something to do with transaction conditions &lt;STRONG&gt;startswith&lt;/STRONG&gt; and &lt;STRONG&gt;endswith&lt;/STRONG&gt;. But I'm not sure. Do you happen to know a solution?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 15:53:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Parsing-different-time-fields-for-transactions/m-p/649868#M224686</guid>
      <dc:creator>heorhii12412</dc:creator>
      <dc:date>2023-07-10T15:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing different time fields for transactions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Parsing-different-time-fields-for-transactions/m-p/649877#M224690</link>
      <description>&lt;P&gt;When &lt;FONT face="courier new,courier"&gt;transaction&lt;/FONT&gt; makes that complaint, throw in a &lt;FONT face="courier new,courier"&gt;sort&lt;/FONT&gt;.&amp;nbsp; See my updated answer.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2023 16:25:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Parsing-different-time-fields-for-transactions/m-p/649877#M224690</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-07-11T16:25:21Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing different time fields for transactions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Parsing-different-time-fields-for-transactions/m-p/649970#M224723</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;I have another query:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;event_status="delivered" OR event_status="in_transit"
| transaction tracking_number startswith=event_status=delivered endswith=event_status=in_transit keepevicted=true 
| where duration &amp;gt; 3600    
| search closed_txn=1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which returned 5 transactions fit for this condition for the last 2 weeks. Here's one of those(accidentally fits my final requirement):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{"timestamp":"2023-07-06T23:44:52.784Z","tracking_number":"C11900891311111","event_status":"delivered","event_time":"2023-07-06T23:44:38.722Z"}
{"timestamp":"2023-07-07T07:03:10.712Z","tracking_number":"C11900891311111","event_status":"in_transit","event_time":"2023-07-03T18:24:36.668Z"}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If we take a look at &lt;STRONG&gt;event_time&amp;nbsp;&lt;/STRONG&gt;field of the &lt;EM&gt;&lt;STRONG&gt;delivered&lt;/STRONG&gt;&lt;/EM&gt; event and assume that it will replace &lt;STRONG&gt;_time&lt;/STRONG&gt; field for it, then after comparison of two timestamps &lt;STRONG&gt;&lt;EM&gt;in_transit&lt;/EM&gt;&lt;/STRONG&gt; event clearly came 8 hours after the first one.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;For some reason, these 5 transactions are not included in the total calculations in the query that you helped me to compose:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;event_status="delivered" OR event_status="in_transit"
| eval _time=if(event_status="delivered", strptime(event_time, "%Y-%m-%dT%H:%M:%S.%3N%Z"), _time)
| sort - _time
| transaction tracking_number startswith=event_status=delivered endswith=event_status=in_transit keepevicted=true
| where duration &amp;gt; 3600
| stats sum(eventcount) as eventcount by closed_txn
| eventstats sum(eventcount) as totalcount
| where closed_txn == 1``` remaining eventcount only includes complete transactions ```
| eval percentage = eventcount * 100 / totalcount&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The strange thing is - I tried singling this transaction this way:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;event_status="delivered" OR event_status="in_transit" AND "C11900891311111"
| eval _time=if(event_status="delivered", strptime(event_time, "%Y-%m-%dT%H:%M:%S.%3N%Z"), _time)
| sort - _time
| transaction tracking_number startswith=event_status=delivered endswith=event_status=in_transit keepevicted=true
| where duration &amp;gt; 3600
| stats sum(eventcount) as eventcount by closed_txn&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And successfully found it!&lt;BR /&gt;But removing condition&lt;STRONG&gt; AND "C11900891311111"&amp;nbsp;&lt;/STRONG&gt;at the start of the query gives me 0 results. This is very strange, right?&lt;BR /&gt;&lt;BR /&gt;P.S. Sorry for my continuous inquiries, I just really want to get to the root of the problem. I will upvote your answers as well!&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2023 11:55:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Parsing-different-time-fields-for-transactions/m-p/649970#M224723</guid>
      <dc:creator>heorhii12412</dc:creator>
      <dc:date>2023-07-11T11:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing different time fields for transactions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Parsing-different-time-fields-for-transactions/m-p/650068#M224745</link>
      <description>&lt;P&gt;Try this more generic query.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(event_status="delivered" OR event_status="in_transit") AND tracking_number=*
| eval _time=if(event_status="delivered", strptime(event_time, "%Y-%m-%dT%H:%M:%S.%3N%Z"), _time)
| sort - _time
| transaction tracking_number startswith=event_status=delivered endswith=event_status=in_transit keepevicted=true
| where duration &amp;gt; 3600
| stats sum(eventcount) as eventcount by closed_txn&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 12 Jul 2023 00:33:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Parsing-different-time-fields-for-transactions/m-p/650068#M224745</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-07-12T00:33:50Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing different time fields for transactions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Parsing-different-time-fields-for-transactions/m-p/650587#M224922</link>
      <description>&lt;P&gt;Unfortunately, this didn't work for me. Still, no idea why those events are not found&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2023 15:43:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Parsing-different-time-fields-for-transactions/m-p/650587#M224922</guid>
      <dc:creator>heorhii12412</dc:creator>
      <dc:date>2023-07-14T15:43:52Z</dc:date>
    </item>
  </channel>
</rss>

