<?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: Need Help With time conversion and adding Timezone in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/Need-Help-With-time-conversion-and-adding-Timezone/m-p/673673#M18298</link>
    <description>&lt;P&gt;I do not have access to update that. So I was trying to figure out how to do it with SPL&lt;/P&gt;</description>
    <pubDate>Tue, 09 Jan 2024 16:50:04 GMT</pubDate>
    <dc:creator>coldwolf7</dc:creator>
    <dc:date>2024-01-09T16:50:04Z</dc:date>
    <item>
      <title>Need Help With time conversion and adding Timezone</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Need-Help-With-time-conversion-and-adding-Timezone/m-p/673668#M18296</link>
      <description>&lt;P class="lia-align-left"&gt;Hello,&lt;/P&gt;&lt;P class="lia-align-left"&gt;I need some help. Manipulating time is something I have struggled with&amp;nbsp;&lt;/P&gt;&lt;P class="lia-align-left"&gt;Below is the code I have&amp;nbsp;&lt;/P&gt;&lt;P class="lia-align-left"&gt;&amp;nbsp;((index="desktop_os") (sourcetype="itsm_remedy")) earliest=-1d@d&lt;BR /&gt;| search ASSIGNED_GROUP IN ("Desktop_Support_1", "Remote_Support")&lt;BR /&gt;``` Convert REPORTED_DATE to epoch form ```&lt;BR /&gt;| eval REPORTED_DATE2=strptime(REPORTED_DATE, "%Y-%m-%d %H:%M:%S")&lt;BR /&gt;``` Keep events reported more than 12 hours ago so are due in &amp;lt; 12 hours ```&lt;BR /&gt;| where REPORTED_DATE2 &amp;lt;= relative_time(now(), "-12h")&lt;BR /&gt;| eval MTTRSET = round((now()-REPORTED_DATE2)/3600)&lt;BR /&gt;| dedup INCIDENT_NUMBER&lt;BR /&gt;| stats values(REPORTED_DATE) AS Reported, values(DESCRIPTION) AS Title, values(ASSIGNED_GROUP) AS Group, values(ASSIGNEE) AS Assignee, LAST(STATUS_TXT) as Status,values(MTTRSET) as MTTRHours, values(STATUS_REASON_TXT) as PendStatus by INCIDENT_NUMBER&lt;BR /&gt;| search Status IN ("ASSIGNED", "IN PROGRESS", "PENDING")&lt;BR /&gt;| sort Assignee&lt;BR /&gt;| table Assignee MTTRHours INCIDENT_NUMBER Reported Title Title Status PendStatus&amp;nbsp;&lt;/P&gt;&lt;P class="lia-align-left"&gt;this code runs and gives us the results we need, but the issue is that&amp;nbsp;REPORTED_DATE field is off by 5 hours due to time zone issue. that is a custom field from out ticketing system that is stuck on GMT and the output looks like&amp;nbsp;&lt;/P&gt;&lt;P class="lia-align-left"&gt;&lt;SPAN&gt;2024-01-08 09:22:49.0&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="lia-align-left"&gt;I need to get that field produce a correct timezone for EST. I am struggling with making it work.&lt;/P&gt;&lt;P class="lia-align-left"&gt;I looked at this thread but that is not working for us:&amp;nbsp;&lt;A href="https://community.splunk.com/t5/Getting-Data-In/How-to-convert-date-and-time-in-UTC-to-EST/m-p/204873" target="_blank" rel="noopener"&gt;Solved: How to convert date and time in UTC to EST? - Splunk Community&lt;/A&gt;&lt;/P&gt;&lt;P class="lia-align-left"&gt;Any help is appreciated.&lt;/P&gt;&lt;P class="lia-align-left"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-align-left"&gt;Thanks&lt;/P&gt;&lt;P class="lia-align-left"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 16:12:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Need-Help-With-time-conversion-and-adding-Timezone/m-p/673668#M18296</guid>
      <dc:creator>coldwolf7</dc:creator>
      <dc:date>2024-01-09T16:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help With time conversion and adding Timezone</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Need-Help-With-time-conversion-and-adding-Timezone/m-p/673672#M18297</link>
      <description>&lt;P&gt;Do you have the ability to modify the sourcetype for the ticketing system data?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can add a single config to the input / sourcetype:&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;# The following props.conf entry sets Eastern Time Zone if host matches nyc*.
[host::nyc*]
TZ = US/Eastern&lt;/LI-CODE&gt;
&lt;P&gt;Is your Splunk environment Splunk Cloud, or self-hosted?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If cloud, you should be able to go to "Settings"-&amp;gt;"Source Types", click on the specific sourcetype and add a key/value pair in the advanced section key="TZ", value ="US/Eastern"&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 09:07:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Need-Help-With-time-conversion-and-adding-Timezone/m-p/673672#M18297</guid>
      <dc:creator>sshelly_splunk</dc:creator>
      <dc:date>2024-01-10T09:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help With time conversion and adding Timezone</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Need-Help-With-time-conversion-and-adding-Timezone/m-p/673673#M18298</link>
      <description>&lt;P&gt;I do not have access to update that. So I was trying to figure out how to do it with SPL&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 16:50:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Need-Help-With-time-conversion-and-adding-Timezone/m-p/673673#M18298</guid>
      <dc:creator>coldwolf7</dc:creator>
      <dc:date>2024-01-09T16:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help With time conversion and adding Timezone</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Need-Help-With-time-conversion-and-adding-Timezone/m-p/673675#M18299</link>
      <description>&lt;P&gt;I would suggest pinging the Splunk admins, as the data is coming in with an issue, and will always be an issue until they modify the input or sourcetype.&lt;/P&gt;&lt;P&gt;You can add/remove whatever number of hours you need for a particular _time field, but if it gets corrected in the future, all of your searches will fail. As well, I'm not sure how things would behave if you were to drilldown from a dashboard into raw data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It really is a simple as adding that TZ key/value to the sourcetype. What that does is makes the display of the data with different timezones seamless to end users. For example, searching for the last 60 minutes data sets configured in GMT AND CST will correctly display to the end user if TZ is configured for the sourcetypes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 16:58:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Need-Help-With-time-conversion-and-adding-Timezone/m-p/673675#M18299</guid>
      <dc:creator>sshelly_splunk</dc:creator>
      <dc:date>2024-01-09T16:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help With time conversion and adding Timezone</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Need-Help-With-time-conversion-and-adding-Timezone/m-p/673681#M18301</link>
      <description>&lt;P&gt;First off, I would suggest doing what&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/165621"&gt;@sshelly_splunk&lt;/a&gt;&amp;nbsp;said if possible. If not possible then you can try this method with SPL.&lt;BR /&gt;&lt;BR /&gt;I see this question come over a lot and people usually respond with "its complicated", and it is.&lt;BR /&gt;With that said, I have been working on trying to standardize a solution by using macros and think I have a good first iteration worked out, but I'm sure still needs some more regression testing.&lt;BR /&gt;&lt;BR /&gt;Here is what results look like using your sample timestamp that is assumed to be GMT but because of the user running the query's timezone preference is set to something else the epoch conversion isn't working as expected.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_0-1704819247370.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28814iC8419CD876839109/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_0-1704819247370.png" alt="dtburrows3_0-1704819247370.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;You can see inputs of the first macro `convert_timestamp_to_epoch(3)` are&lt;BR /&gt;$timestamp_field$ ----&amp;gt; REPORTED_DATE&lt;BR /&gt;$timestamp_format$ ----&amp;gt;&amp;nbsp;%Y-%m-%d %H:%M:%S.%1N&lt;BR /&gt;$assumed_timezone$ ----&amp;gt; GMT&lt;BR /&gt;&amp;nbsp; &amp;nbsp; This first macro should convert a timestamp to a standardized epoch time by using either a timezone found in the timestamp itself or if no timezone is found in the timestamp to revert to using the 3rd argument of the "assumed_timezone". You have the ability to leave the 3rd argument blank as well and then the catchall timezone is the user's configured timezone preference.&lt;BR /&gt;&lt;BR /&gt;The second macro `convert_epoch_to_specific_timezone(3)` has the input args&lt;BR /&gt;$epoch$ ----&amp;gt; standardized_epoch (this is default fieldname of the output of the previous macro)&lt;BR /&gt;$timestamp_format$ ----&amp;gt;&amp;nbsp;%Y-%m-%d %H:%M:%S.%1N&lt;BR /&gt;$output_timezone$ ----&amp;gt; EST&lt;BR /&gt;&amp;nbsp; &amp;nbsp; This macro is taking in a epoch value and returns a human readable timestamp set to any timezone requested in the 3rd argument. (thats the idea at least)&lt;BR /&gt;&lt;BR /&gt;Using the 2 macros together should be able to convert any timestamp to another with a desired timezone association.&lt;BR /&gt;&lt;BR /&gt;If you are interested in the macros, shoot me a message and I can get them packaged up for you and share.&lt;BR /&gt;&lt;BR /&gt;In the mean time why dont you try appending "+0000" to your REPORTED_DATE and convert to epoch including the timezone specifier&lt;BR /&gt;Example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;    | eval
        REPORTED_DATE2=strptime('REPORTED_DATE'."+0000", "%Y-%m-%d %H:%M:%S.%1N%z")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 17:16:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Need-Help-With-time-conversion-and-adding-Timezone/m-p/673681#M18301</guid>
      <dc:creator>dtburrows3</dc:creator>
      <dc:date>2024-01-09T17:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help With time conversion and adding Timezone</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Need-Help-With-time-conversion-and-adding-Timezone/m-p/673793#M18313</link>
      <description>&lt;P&gt;&lt;SPAN&gt;In the mean time why don't you try appending "+0000" to your REPORTED_DATE and convert to epoch including the timezone specifier&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;This was&amp;nbsp; perfect and worked great.&lt;/P&gt;&lt;P&gt;I am very interested in macros I have never done them can you help me build the ones out you did&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;</description>
      <pubDate>Wed, 10 Jan 2024 14:51:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Need-Help-With-time-conversion-and-adding-Timezone/m-p/673793#M18313</guid>
      <dc:creator>coldwolf7</dc:creator>
      <dc:date>2024-01-10T14:51:05Z</dc:date>
    </item>
  </channel>
</rss>

