<?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 do you parse two string times and compare and get difference? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-parse-two-string-times-and-compare-and-get-difference/m-p/451137#M78232</link>
    <description>&lt;P&gt;Great! &lt;/P&gt;

&lt;P&gt;How does this look? You're correct. The sessionIDs would be the same!&lt;/P&gt;

&lt;P&gt;cf_app_name="my-app-services" "msg.platform"=iOS "msg.level"=INFO &lt;BR /&gt;
| rex field="msg.message" "\s+-\s+Time:\s+(?[^\"]+)" &lt;BR /&gt;
| eval Time = strptime(Time, "%H:%M:%S") &lt;BR /&gt;
| stats range(Time) AS duration list(*) AS * BY sessionID &lt;BR /&gt;
| where duration &amp;gt; 60&lt;/P&gt;

&lt;P&gt;Doesn't the rex field need to be "msg.message" according to my example above?&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 23:16:05 GMT</pubDate>
    <dc:creator>imservicesbg</dc:creator>
    <dc:date>2020-09-29T23:16:05Z</dc:date>
    <item>
      <title>How do you parse two string times and compare and get difference?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-parse-two-string-times-and-compare-and-get-difference/m-p/451134#M78229</link>
      <description>&lt;P&gt;Hello friends,&lt;/P&gt;

&lt;P&gt;Say I have two index events that return string messages such as:&lt;/P&gt;

&lt;P&gt;SCHEDULE - SUCCESS - Time: 05:12:02&lt;BR /&gt;
AUTH - SUCCESS - Time: 05:14:01&lt;/P&gt;

&lt;P&gt;Here are the example events:&lt;/P&gt;

&lt;P&gt;EVENT 1 - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{  
   "cf_app_id":"345345345345",
   "cf_app_name":"my-app-services",
   "job_index":"b4853c36-6ecd-4902-9eb6xxxxxxxxx",
   "message_type":"OUT",
   "msg":{  
      "component":"MyApp",
      "device":"iPhone",
      "deviceID":"3534534534534",
      "level":"INFO",
      "levelindicator":"✏️",
      "message":"SCHEDULE - SUCCESS - Time: 05:12:02",
      "osversion":"12.0.1",
      "platform":"iOS",
      "reference":"Logger.swift|info|31",
      "sessionID":"234234234234",
      "username":"N/A",
      "version":"5.1.0"
   },
   "origin":"rep",
   "source_instance":"0",
   "source_type":"APP/PROC/WEB",
   "timestamp":1549302723595711849
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;EVENT 2 - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{  
   "cf_app_id":"34534534532",
   "cf_app_name":"my-app-services",
   "job_index":"b4853c36-6ecd-4902-9eb6zzzzzzz",
   "message_type":"OUT",
   "msg":{  
      "component":"MyApp",
      "device":"iPhone",
      "deviceID":"345435345345",
      "level":"INFO",
      "levelindicator":"✏️",
      "message":"AUTH - SUCCESS - Time: 05:14:01",
      "osversion":"12.0.1",
      "platform":"iOS",
      "reference":"Logger.swift|info|31",
      "sessionID":"6456464564",
      "username":"N/A",
      "version":"5.1.0"
   },
   "origin":"rep",
   "source_instance":"0",
   "source_type":"APP/PROC/WEB",
   "timestamp":567567567567
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The logic here is, Splunk is reporting a successful SCHEDULE service call and adding a JS timestamp from Date() to "msg.message". Then comes an AUTHORIZATION success call a couple minutes later and does the same thing with a Date() timestamp to "msg.message".  &lt;/P&gt;

&lt;P&gt;What I want to do:&lt;/P&gt;

&lt;P&gt;I want to take the timestamps out of each like so:&lt;/P&gt;

&lt;P&gt;05:14:01 and 05:12:02 and then subtract those to find the difference of 2:01. Then create a panel that shows all comparisons like that which are over 1 minute in duration. &lt;/P&gt;

&lt;P&gt;Is this even possible? What kind of search param would I use to find the substring with Splunk and find the time difference which creates my panel? I hope this is clear in what I am trying to do. Should I use compare?&lt;/P&gt;

&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 19:43:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-parse-two-string-times-and-compare-and-get-difference/m-p/451134#M78229</guid>
      <dc:creator>imservicesbg</dc:creator>
      <dc:date>2019-02-11T19:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do you parse two string times and compare and get difference?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-parse-two-string-times-and-compare-and-get-difference/m-p/451135#M78230</link>
      <description>&lt;P&gt;If you refer to &lt;A href="https://answers.splunk.com/answers/613695/converting-hmmss-into-hour-minutes-and-seconds.html"&gt;https://answers.splunk.com/answers/613695/converting-hmmss-into-hour-minutes-and-seconds.html&lt;/A&gt; the dur2sec might be an option here...however that might fail when your close to midnight in which case strptime might work.&lt;/P&gt;

&lt;P&gt;strptime to convert to epoch, minus the two epoch values, then convert back into a duration with an:&lt;BR /&gt;
    | eval duration=tostring(differencevalue,"duration")&lt;/P&gt;

&lt;P&gt;Sorry don't have time to write a full answer this morning...&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 21:56:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-parse-two-string-times-and-compare-and-get-difference/m-p/451135#M78230</guid>
      <dc:creator>gjanders</dc:creator>
      <dc:date>2019-02-11T21:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do you parse two string times and compare and get difference?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-parse-two-string-times-and-compare-and-get-difference/m-p/451136#M78231</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=YouShouldAlwaysSpecifyAnIndex AND sourcetype=AndSourcetypeToo
| rex field=msg.message "\s+-\s+Time:\s+(?&amp;lt;Time&amp;gt;[^\"]+)"
| eval Time = strptime(Time, "%H:%M:%S")
| stats range(Time) AS duration list(*) AS * BY sessionID
| where duration &amp;gt; 60
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is assuming that the events share a common &lt;CODE&gt;sessoinID&lt;/CODE&gt; value (which your events, as shown, do not).  If this is a mistake, switch that out for the field that does correlate the 2 events.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 02:03:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-parse-two-string-times-and-compare-and-get-difference/m-p/451136#M78231</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-02-12T02:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: How do you parse two string times and compare and get difference?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-parse-two-string-times-and-compare-and-get-difference/m-p/451137#M78232</link>
      <description>&lt;P&gt;Great! &lt;/P&gt;

&lt;P&gt;How does this look? You're correct. The sessionIDs would be the same!&lt;/P&gt;

&lt;P&gt;cf_app_name="my-app-services" "msg.platform"=iOS "msg.level"=INFO &lt;BR /&gt;
| rex field="msg.message" "\s+-\s+Time:\s+(?[^\"]+)" &lt;BR /&gt;
| eval Time = strptime(Time, "%H:%M:%S") &lt;BR /&gt;
| stats range(Time) AS duration list(*) AS * BY sessionID &lt;BR /&gt;
| where duration &amp;gt; 60&lt;/P&gt;

&lt;P&gt;Doesn't the rex field need to be "msg.message" according to my example above?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:16:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-parse-two-string-times-and-compare-and-get-difference/m-p/451137#M78232</guid>
      <dc:creator>imservicesbg</dc:creator>
      <dc:date>2020-09-29T23:16:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do you parse two string times and compare and get difference?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-parse-two-string-times-and-compare-and-get-difference/m-p/451138#M78233</link>
      <description>&lt;P&gt;I updated &lt;CODE&gt;msg.messsage&lt;/CODE&gt;.  Does it actually work for you?  If so, click &lt;CODE&gt;Accept&lt;/CODE&gt; to close the question.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 00:29:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-parse-two-string-times-and-compare-and-get-difference/m-p/451138#M78233</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-02-13T00:29:13Z</dc:date>
    </item>
  </channel>
</rss>

