<?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 Issue with Time Conversion in JSON String in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Issue-with-Time-Conversion-in-JSON-String/m-p/575196#M200431</link>
    <description>&lt;P&gt;Hey &lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt;,&lt;/P&gt;&lt;P&gt;I'm trying to get the time difference between when an event was received and a string representation of the time in the event.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's an example of the event:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "action": "created",
    "alert": {
        "number": 818,
        "created_at": "2021-11-16T21:52:12Z",
        "url": "https://somewebsite.com"
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue is the conversion of the time in "alert.created_at" from string to epoch.&amp;nbsp; Once I'm able to get the epoch representation, calculating the difference from _time is easy.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm working off this eval statement, but cant get it to work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; | eval strtime=strptime(alert.created_at, "%Y-%m-%dT%H:%M:%SZ") | table strtime&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any thoughts?&amp;nbsp; Thanks!&lt;/P&gt;</description>
    <pubDate>Wed, 17 Nov 2021 04:35:04 GMT</pubDate>
    <dc:creator>leftrightleft</dc:creator>
    <dc:date>2021-11-17T04:35:04Z</dc:date>
    <item>
      <title>Issue with Time Conversion in JSON String</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Issue-with-Time-Conversion-in-JSON-String/m-p/575196#M200431</link>
      <description>&lt;P&gt;Hey &lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt;,&lt;/P&gt;&lt;P&gt;I'm trying to get the time difference between when an event was received and a string representation of the time in the event.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's an example of the event:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "action": "created",
    "alert": {
        "number": 818,
        "created_at": "2021-11-16T21:52:12Z",
        "url": "https://somewebsite.com"
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue is the conversion of the time in "alert.created_at" from string to epoch.&amp;nbsp; Once I'm able to get the epoch representation, calculating the difference from _time is easy.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm working off this eval statement, but cant get it to work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; | eval strtime=strptime(alert.created_at, "%Y-%m-%dT%H:%M:%SZ") | table strtime&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any thoughts?&amp;nbsp; Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 17 Nov 2021 04:35:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Issue-with-Time-Conversion-in-JSON-String/m-p/575196#M200431</guid>
      <dc:creator>leftrightleft</dc:creator>
      <dc:date>2021-11-17T04:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Time Conversion in JSON String</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Issue-with-Time-Conversion-in-JSON-String/m-p/575199#M200433</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/240779"&gt;@leftrightleft&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please try this?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval strtime=strptime('alert.created_at', "%Y-%m-%dT%H:%M:%SZ")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My Sample Search :&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="{\"action\": \"created\",\"alert\": {\"number\": 818,\"created_at\": \"2021-11-16T21:52:12Z\",\"url\": \"https://somewebsite.com\"}}" 
| spath 
| eval strtime=strptime('alert.created_at', "%Y-%m-%dT%H:%M:%SZ")&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;KV&lt;/P&gt;</description>
      <pubDate>Wed, 17 Nov 2021 05:30:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Issue-with-Time-Conversion-in-JSON-String/m-p/575199#M200433</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2021-11-17T05:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Time Conversion in JSON String</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Issue-with-Time-Conversion-in-JSON-String/m-p/575292#M200466</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/127939"&gt;@kamlesh_vaghela&lt;/a&gt;, I wish I could give you more than just a thumbs up.&amp;nbsp; At a minimum, you deserve a high five.&amp;nbsp; Honestly, I would probably even give you a hug if I could &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Seriously though, thanks a lot.&amp;nbsp; I really was struggling with this.&amp;nbsp; I didn't realize the single quotes were what was needed.&amp;nbsp; I actually tried double quotes around the field name at one point, but it interpreted it as literally "alert.created_at".&lt;/P&gt;</description>
      <pubDate>Wed, 17 Nov 2021 15:38:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Issue-with-Time-Conversion-in-JSON-String/m-p/575292#M200466</guid>
      <dc:creator>leftrightleft</dc:creator>
      <dc:date>2021-11-17T15:38:58Z</dc:date>
    </item>
  </channel>
</rss>

