<?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 I get Splunk's timezone settings via Python? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/how-do-I-get-Splunk-s-timezone-settings-via-Python/m-p/122831#M1799</link>
    <description>&lt;P&gt;If you have done the right thing and configured a &lt;CODE&gt;TZ=&lt;/CODE&gt; value in your &lt;CODE&gt;props.conf&lt;/CODE&gt; for every source (except for some scripted inputs from TA apps), then you can check the &lt;CODE&gt;date_zone&lt;/CODE&gt; field to see what Splunk thinks is the TZ for each event.  If you see &lt;CODE&gt;local&lt;/CODE&gt; then this means that the TZ of the indexer (or heavy forwarder) was used (which is usually bad/wrong).  You are mistaken to think that Splunk "has a TZ" because it doesn't; all Splunk times are stored in GMT-based epoch (TZ=0) so you should never need to do any TZ manipulation if you are dealing with the &lt;CODE&gt;_time&lt;/CODE&gt; field.&lt;/P&gt;</description>
    <pubDate>Wed, 15 Jul 2015 03:15:51 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2015-07-15T03:15:51Z</dc:date>
    <item>
      <title>how do I get Splunk's timezone settings via Python?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/how-do-I-get-Splunk-s-timezone-settings-via-Python/m-p/122830#M1798</link>
      <description>&lt;P&gt;i want to log activity of what a script is doing into an index.&lt;/P&gt;

&lt;P&gt;i'm creating current time with a &lt;CODE&gt;datetime&lt;/CODE&gt; object in python:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;now = datetime.datetime.now()
now.strftime("%Y-%m-%d %H:%M:%S %Z")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;now i do know strftime has limited support for timezones... but without a timezone the log message might not get parsed correctly AFAIK, and is probably not a Good Thing to leave it off.&lt;/P&gt;

&lt;P&gt;how can i access what Splunk thinks the host server's timezone is (independent of individual user settings, etc)?  whether it's REST endpoint in Splunk, an SDK variable / function, or some native Python function doesn't matter to me.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2015 23:44:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/how-do-I-get-Splunk-s-timezone-settings-via-Python/m-p/122830#M1798</guid>
      <dc:creator>awurster</dc:creator>
      <dc:date>2015-07-14T23:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: how do I get Splunk's timezone settings via Python?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/how-do-I-get-Splunk-s-timezone-settings-via-Python/m-p/122831#M1799</link>
      <description>&lt;P&gt;If you have done the right thing and configured a &lt;CODE&gt;TZ=&lt;/CODE&gt; value in your &lt;CODE&gt;props.conf&lt;/CODE&gt; for every source (except for some scripted inputs from TA apps), then you can check the &lt;CODE&gt;date_zone&lt;/CODE&gt; field to see what Splunk thinks is the TZ for each event.  If you see &lt;CODE&gt;local&lt;/CODE&gt; then this means that the TZ of the indexer (or heavy forwarder) was used (which is usually bad/wrong).  You are mistaken to think that Splunk "has a TZ" because it doesn't; all Splunk times are stored in GMT-based epoch (TZ=0) so you should never need to do any TZ manipulation if you are dealing with the &lt;CODE&gt;_time&lt;/CODE&gt; field.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2015 03:15:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/how-do-I-get-Splunk-s-timezone-settings-via-Python/m-p/122831#M1799</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-07-15T03:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: how do I get Splunk's timezone settings via Python?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/how-do-I-get-Splunk-s-timezone-settings-via-Python/m-p/122832#M1800</link>
      <description>&lt;P&gt;thanks but i'm mostly just looking for a pythonic way to access the local system's timezone.&lt;/P&gt;

&lt;P&gt;i'm writing logs to &lt;CODE&gt;~/var/log/splunk/foo.log&lt;/CODE&gt; which lands in the server's &lt;CODE&gt;_internal&lt;/CODE&gt; index.  it might be redundant to log a TZ, but i still am curious what the answer is.&lt;/P&gt;

&lt;P&gt;i should also clarify that i'd like to do it natively as much as possible, without requiring a 3rd party lib like &lt;CODE&gt;pytz&lt;/CODE&gt; to be bundled with my add-on.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2015 03:47:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/how-do-I-get-Splunk-s-timezone-settings-via-Python/m-p/122832#M1800</guid>
      <dc:creator>awurster</dc:creator>
      <dc:date>2015-07-15T03:47:24Z</dc:date>
    </item>
  </channel>
</rss>

