<?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: Time stamp difference Help! in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Time-stamp-difference-Help/m-p/696885#M236822</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;A class="" href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957" target="_self"&gt;&lt;SPAN class=""&gt;richgalloway&lt;/SPAN&gt;&lt;/A&gt;&amp;nbsp;the below query gives me all the required&amp;nbsp; results when&amp;nbsp;OR "status" OR "Path" is added to the query.&amp;nbsp; &amp;nbsp;However, its taking the wrong time stamp. Its taking the difference between the first two events.&amp;nbsp; i need the duration of&amp;nbsp; "Successfully completed execution" - "Starting execution for request" time stamps.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"My Base query"&amp;nbsp; ("Starting execution for request" OR "Successfully completed execution" OR "status" OR "Path")&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| rex "status:\s+(?&amp;lt;Status&amp;gt;.*)\"}"
| rex field=_raw "\((?&amp;lt;Message_Id&amp;gt;[^\)]*)"
| rex "Path\:\s+(?&amp;lt;ResourcePath&amp;gt;.*)\"" | rex "timestamp\:\s+(?&amp;lt;timestamp&amp;gt;.*)\""
| stats min(timestamp) as startTime, max(timestamp) as endTime, values(*) as * by Message_Id | stats values(*) as * by Message_Id
| eval end_timestamp_s = endTime/1000, start_timestamp_s = startTime/1000 | eval duration = end_timestamp_s - start_timestamp_s
| eval human_readable_etime = strftime(end_timestamp_s, "%Y-%m-%d %H:%M:%S"), human_readable_stime = strftime(start_timestamp_s, "%Y-%m-%d %H:%M:%S"), duration = tostring(duration, "duration")
| table Message_Id human_readable_stime human_readable_etime duration Status ResourcePath&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 20 Aug 2024 18:59:07 GMT</pubDate>
    <dc:creator>kc_prane</dc:creator>
    <dc:date>2024-08-20T18:59:07Z</dc:date>
    <item>
      <title>Time stamp difference Help!</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-stamp-difference-Help/m-p/696744#M236796</link>
      <description>&lt;P&gt;Hi, how do i get the difference in the time stamp? . I want to know the difference between the starting timestamp and the completed time stamp&lt;/P&gt;&lt;PRE&gt;"My base query"  &lt;BR /&gt;| rex "status:\s+(?&amp;lt;Status&amp;gt;.*)\"}" &lt;BR /&gt;| rex field=_raw "\((?&amp;lt;Message_Id&amp;gt;[^\)]*)" &lt;BR /&gt;| rex "Path\:\s+(?&amp;lt;ResourcePath&amp;gt;.*)\"" &lt;BR /&gt;| eval timestamp_s = timestamp/1000 &lt;BR /&gt;| eval human_readable_time = strftime(timestamp_s, "%Y-%m-%d %H:%M:%S") &lt;BR /&gt;| transaction Message_Id startswith="Starting execution for request" endswith="Successfully completed execution"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RAW_LOG&lt;/P&gt;&lt;DIV&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;8/19/24&lt;/P&gt;&lt;P&gt;9:56:05.113 AM&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;{"id":"38448254623555555", "timestamp":1724079365113, "message":"(fghhhhhh-244933333-456789-rrrrrrrrrr) Startingexecutionforrequest:f34444-22222-44444-999999-0888888"}&lt;/P&gt;&lt;P&gt;{"id":"38448254444444444", "timestamp":1724079365126, "message":"(fghhhhhh-244933333-456789-rrrrrrrrrr) Methodcompletedwithstatus:200"}&lt;/P&gt;&lt;P&gt;{"id":"38448222222222222", "timestamp":1724079365126, "message":"(fghhhhhh-244933333-456789-rrrrrrrrrr) Successfullycompletedexecution"}&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;{"&lt;/SPAN&gt;&lt;SPAN&gt;id&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;38417111111111111&lt;/SPAN&gt;&lt;SPAN&gt;", "&lt;/SPAN&gt;&lt;SPAN&gt;timestamp&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;:1724079365126&lt;/SPAN&gt;&lt;SPAN&gt;, "&lt;/SPAN&gt;&lt;SPAN&gt;message&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;SPAN&gt;"(&lt;/SPAN&gt;&lt;SPAN&gt;fghhhhhh-244933333-456789-rrrrrrrrrr&lt;/SPAN&gt;&lt;SPAN&gt;)&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;AWS Integration Endpoint RequestId :f32222-22222-44444-999999-0888888&lt;/SPAN&gt;&lt;SPAN&gt;"}&lt;/SPAN&gt;&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;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kc_prane_0-1724083710019.png" style="width: 662px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/32296iFDA1CEBB5F11377D/image-dimensions/662x60?v=v2" width="662" height="60" role="button" title="kc_prane_0-1724083710019.png" alt="kc_prane_0-1724083710019.png" /&gt;&lt;/span&gt;&lt;P&gt; &lt;/P&gt;&lt;BR /&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 19 Aug 2024 17:59:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-stamp-difference-Help/m-p/696744#M236796</guid>
      <dc:creator>kc_prane</dc:creator>
      <dc:date>2024-08-19T17:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: Time stamp difference Help!</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-stamp-difference-Help/m-p/696767#M236800</link>
      <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;transaction&lt;/FONT&gt; command creates a field called "duration" that is the difference in the _time values from the first and last events of the transaction.&amp;nbsp; That should fill this need, assuming _time is set by properly extracting the "timestamp" value at index time.&lt;/P&gt;&lt;P&gt;The transaction command is not very performant, however.&amp;nbsp; A more efficient way to do it uses &lt;FONT face="courier new,courier"&gt;stats&lt;/FONT&gt;.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"My base query"  ("Starting execution for request" OR "Successfully completed execution")
| rex "status:\s+(?&amp;lt;Status&amp;gt;.*)\"}" 
| rex field=_raw "\((?&amp;lt;Message_Id&amp;gt;[^\)]*)" 
| rex "Path\:\s+(?&amp;lt;ResourcePath&amp;gt;.*)\"" 
| rex "timestamp\\\":(\d+)" 
| stats min(timestamp) as startTime, max(timestamp) as endTime by Message_Id
| eval duration = endTime - startTime
| eval end_timestamp_s = endTime/1000, start_timestamp_s = startTime/1000
| eval human_readable_etime = strftime(end_timestamp_s, "%Y-%m-%d %H:%M:%S"), human_readable_stime = strftime(start_timestamp_s, "%Y-%m-%d %H:%M:%S"), duration = tostring(duration, "duration")
| table Message_Id human_readable_stime human_readable_etime duration&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2024 18:18:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-stamp-difference-Help/m-p/696767#M236800</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2024-08-19T18:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: Time stamp difference Help!</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-stamp-difference-Help/m-p/696789#M236804</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@&amp;nbsp;&lt;SPAN&gt;richgalloway&amp;nbsp; Thanks for the reply,The query looks good but I am missing&amp;nbsp; the below two fields&amp;nbsp; in the results. Can help in getting them populated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1)&amp;nbsp;| rex "status:\s+(?&amp;lt;Status&amp;gt;.*)\"}"&amp;nbsp;&lt;BR /&gt;2)&amp;nbsp;| rex "Path\:\s+(?&amp;lt;ResourcePath&amp;gt;.*)\""&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2024 02:45:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-stamp-difference-Help/m-p/696789#M236804</guid>
      <dc:creator>kc_prane</dc:creator>
      <dc:date>2024-08-20T02:45:36Z</dc:date>
    </item>
    <item>
      <title>Re: Time stamp difference Help!</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-stamp-difference-Help/m-p/696840#M236815</link>
      <description>&lt;P&gt;Try this query&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"My base query"  ("Starting execution for request" OR "Successfully completed execution")
| rex "status:\s+(?&amp;lt;Status&amp;gt;.*)\"}" 
| rex field=_raw "\((?&amp;lt;Message_Id&amp;gt;[^\)]*)" 
| rex "Path\:\s+(?&amp;lt;ResourcePath&amp;gt;.*)\"" 
| rex "timestamp\\\":(\d+)" 
| stats min(timestamp) as startTime, max(timestamp) as endTime, values(*) as * by Message_Id
| eval duration = endTime - startTime
| eval end_timestamp_s = endTime/1000, start_timestamp_s = startTime/1000
| eval human_readable_etime = strftime(end_timestamp_s, "%Y-%m-%d %H:%M:%S"), human_readable_stime = strftime(start_timestamp_s, "%Y-%m-%d %H:%M:%S"), duration = tostring(duration, "duration")
| table Message_Id human_readable_stime human_readable_etime duration Status Path&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 20 Aug 2024 12:48:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-stamp-difference-Help/m-p/696840#M236815</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2024-08-20T12:48:29Z</dc:date>
    </item>
    <item>
      <title>Re: Time stamp difference Help!</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-stamp-difference-Help/m-p/696885#M236822</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;A class="" href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957" target="_self"&gt;&lt;SPAN class=""&gt;richgalloway&lt;/SPAN&gt;&lt;/A&gt;&amp;nbsp;the below query gives me all the required&amp;nbsp; results when&amp;nbsp;OR "status" OR "Path" is added to the query.&amp;nbsp; &amp;nbsp;However, its taking the wrong time stamp. Its taking the difference between the first two events.&amp;nbsp; i need the duration of&amp;nbsp; "Successfully completed execution" - "Starting execution for request" time stamps.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"My Base query"&amp;nbsp; ("Starting execution for request" OR "Successfully completed execution" OR "status" OR "Path")&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| rex "status:\s+(?&amp;lt;Status&amp;gt;.*)\"}"
| rex field=_raw "\((?&amp;lt;Message_Id&amp;gt;[^\)]*)"
| rex "Path\:\s+(?&amp;lt;ResourcePath&amp;gt;.*)\"" | rex "timestamp\:\s+(?&amp;lt;timestamp&amp;gt;.*)\""
| stats min(timestamp) as startTime, max(timestamp) as endTime, values(*) as * by Message_Id | stats values(*) as * by Message_Id
| eval end_timestamp_s = endTime/1000, start_timestamp_s = startTime/1000 | eval duration = end_timestamp_s - start_timestamp_s
| eval human_readable_etime = strftime(end_timestamp_s, "%Y-%m-%d %H:%M:%S"), human_readable_stime = strftime(start_timestamp_s, "%Y-%m-%d %H:%M:%S"), duration = tostring(duration, "duration")
| table Message_Id human_readable_stime human_readable_etime duration Status ResourcePath&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 20 Aug 2024 18:59:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-stamp-difference-Help/m-p/696885#M236822</guid>
      <dc:creator>kc_prane</dc:creator>
      <dc:date>2024-08-20T18:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: Time stamp difference Help!</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-stamp-difference-Help/m-p/696890#M236824</link>
      <description>&lt;P&gt;My original query only returned start and end events so the duration calculation worked.&amp;nbsp; With the change to the base query, we'll have to change how we extract times.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"My Base query"  ("Starting execution for request" OR "Successfully completed execution" OR "status" OR "Path")
| rex "status:\s+(?&amp;lt;Status&amp;gt;.*)\"}"
| rex field=_raw "\((?&amp;lt;Message_Id&amp;gt;[^\)]*)"
| rex "Path\:\s+(?&amp;lt;ResourcePath&amp;gt;.*)\"" 
| rex "timestamp\:\s+(?&amp;lt;timestamp&amp;gt;.*)\""
| eval startTime = if(searchmatch("Starting execution for request"), timestamp, startTime),
       endTime = if(searchmatch("Successfully completed execution"), timestamp, endTime)
| stats max(startTime) as startTime, max(endTime) as endTime, values(*) as * by Message_Id | stats values(*) as * by Message_Id
| eval end_timestamp_s = endTime/1000, start_timestamp_s = startTime/1000 | eval duration = end_timestamp_s - start_timestamp_s
| eval human_readable_etime = strftime(end_timestamp_s, "%Y-%m-%d %H:%M:%S"), human_readable_stime = strftime(start_timestamp_s, "%Y-%m-%d %H:%M:%S"), duration = tostring(duration, "duration")
| table Message_Id human_readable_stime human_readable_etime duration Status ResourcePath&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 20 Aug 2024 19:27:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-stamp-difference-Help/m-p/696890#M236824</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2024-08-20T19:27:16Z</dc:date>
    </item>
  </channel>
</rss>

