<?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: Add x hours to epoch time in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/Add-x-hours-to-epoch-time/m-p/476693#M1757</link>
    <description>&lt;PRE&gt;&lt;CODE&gt;TRANSFORMS-&amp;lt;class&amp;gt; = &amp;lt;transform_stanza_name&amp;gt;, &amp;lt;transform_stanza_name2&amp;gt;,...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;TRANSFORMS-myevals=myeval, myeval2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and The rest looks good, let's reboot and check new events. how?&lt;/P&gt;</description>
    <pubDate>Fri, 17 Apr 2020 11:47:58 GMT</pubDate>
    <dc:creator>to4kawa</dc:creator>
    <dc:date>2020-04-17T11:47:58Z</dc:date>
    <item>
      <title>Add x hours to epoch time</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Add-x-hours-to-epoch-time/m-p/476686#M1750</link>
      <description>&lt;P&gt;I have a log that contains multiple time fields&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;_time (ingest time)&lt;/LI&gt;
&lt;LI&gt;Processed time (processed_time)&lt;/LI&gt;
&lt;LI&gt;Actioned time (actioned_time)&lt;/LI&gt;
&lt;LI&gt;Result time (result_time)&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;_time or ingest time is configured in props to adjust the timezone (due to no offset in the original log) I need for my timezone so its working fine.  However the rest of the fields are just static fields.  I went through doing the following for processed time (an example time stamp is Apr 10 2020 05:45:52)&lt;/P&gt;

&lt;P&gt;So I wrote the following SPL to convert the static field "processed_time" to epoch&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo
| eval epoch_time(strptime(processed_time, "%b %d %Y %H:%M:%S")
| eval processed_time_normalized=strftime(epoch_time, "%b-%d-%Y %H:%M:%S"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I would like to do is add time to this event.  So if I wanted to add 2, 4, 9 hours to this field how would I do that?&lt;/P&gt;

&lt;P&gt;I tried doing&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval processed_time_normalized=strftime(epoch_time, "%b-%d-%Y %H:%M:%S" %:::z +8)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval processed_time_normalized=strftime(epoch_time, "%b-%d-%Y %H:%M:%S" %Z)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but all this does is set the offset to +8 in this example or the timezone I am in with %Z.  I need this time (processed_time) as well as actioned_time and result_time to show me in this example, 8 hours later.  &lt;/P&gt;

&lt;P&gt;What I also want to know is how do I then put this into something like props or transforms so I don't have to do this via SPL?  &lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:01:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Add-x-hours-to-epoch-time/m-p/476686#M1750</guid>
      <dc:creator>willadams</dc:creator>
      <dc:date>2020-09-30T05:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: Add x hours to epoch time</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Add-x-hours-to-epoch-time/m-p/476687#M1751</link>
      <description>&lt;P&gt;hi @willadams &lt;/P&gt;

&lt;P&gt;add milliseconds to direct epoch&lt;/P&gt;

&lt;P&gt;1 day = 86400&lt;BR /&gt;
1 hour=3600&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval epoch_time=strptime(processed_time, "%b %d %Y %H:%M:%S")+3600
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Apr 2020 07:27:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Add-x-hours-to-epoch-time/m-p/476687#M1751</guid>
      <dc:creator>harishalipaka</dc:creator>
      <dc:date>2020-04-16T07:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: Add x hours to epoch time</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Add-x-hours-to-epoch-time/m-p/476688#M1752</link>
      <description>&lt;P&gt;Of course that makes perfect sense.  Its epoch which is seconds and I was viewing this as hours in my head.  Thanks.&lt;/P&gt;

&lt;P&gt;Regarding my second query I guess I will just add to props maybe transforms to do it for me..?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2020 07:38:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Add-x-hours-to-epoch-time/m-p/476688#M1752</guid>
      <dc:creator>willadams</dc:creator>
      <dc:date>2020-04-16T07:38:38Z</dc:date>
    </item>
    <item>
      <title>Re: Add x hours to epoch time</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Add-x-hours-to-epoch-time/m-p/476689#M1753</link>
      <description>&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;INGEST_EVAL = &amp;lt;comma-separated list of evaluator expressions&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;try &lt;CODE&gt;INGEST_EVAL&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;reference:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval accesstime="Apr 10 2020 05:45:52"
| eval access_epoch=round(strptime(accesstime." +0800","%b %d %Y %T %Z"))
| convert ctime(access_epoch) as check_access_epoch
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Apr 2020 08:19:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Add-x-hours-to-epoch-time/m-p/476689#M1753</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-16T08:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: Add x hours to epoch time</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Add-x-hours-to-epoch-time/m-p/476690#M1754</link>
      <description>&lt;P&gt;Still a bit lost here&lt;/P&gt;

&lt;P&gt;So would I do this in transforms / props for example&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;transforms&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[myeval]
ingest_eval = epoch_time(strptime(processed_time, "%b %d %Y %H:%M:%S")+3600, eval processed_time_normalized=strftime(epoch_time, "%b-%d-%Y %H:%M:%S")

ingest_eval2 = epoch_time2(strptime(actioned_time, "%b %d %Y %H:%M:%S")+3600, eval actioned_time_normalized=strftime(epoch_time2, "%b-%d-%Y %H:%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;props&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[mysourcetype]
TRANSFORMS=ingest_eval
TRANSFORMS=ingest_eval2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Apr 2020 05:12:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Add-x-hours-to-epoch-time/m-p/476690#M1754</guid>
      <dc:creator>willadams</dc:creator>
      <dc:date>2020-04-17T05:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: Add x hours to epoch time</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Add-x-hours-to-epoch-time/m-p/476691#M1755</link>
      <description>&lt;P&gt;check &lt;A href="https://docs.splunk.com/Documentation/Splunk/8.0.3/Data/IngestEval"&gt;https://docs.splunk.com/Documentation/Splunk/8.0.3/Data/IngestEval&lt;/A&gt;&lt;BR /&gt;
and correct the mistake&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 10:34:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Add-x-hours-to-epoch-time/m-p/476691#M1755</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-17T10:34:48Z</dc:date>
    </item>
    <item>
      <title>Re: Add x hours to epoch time</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Add-x-hours-to-epoch-time/m-p/476692#M1756</link>
      <description>&lt;P&gt;So&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;transforms&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[myeval]
ingest_eval = epoch_time=(strptime(processed_time, "%b %d %Y %H:%M:%S")+3600, processed_time_normalized=strftime(epoch_time, "%b-%d-%Y %H:%M:%S")

[myeval2]

ingest_eval = epoch_time2=(strptime(actioned_time, "%b %d %Y %H:%M:%S")+3600, actioned_time_normalized=strftime(epoch_time2, "%b-%d-%Y %H:%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;** props ** &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;TRANSFORMS=myeval
TRANSFORMS=myeval2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;** fields **&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[actioned_time_normalized]
INDEXED = True

[processed_time_normalized]
INDEXED = True
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Apr 2020 11:05:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Add-x-hours-to-epoch-time/m-p/476692#M1756</guid>
      <dc:creator>willadams</dc:creator>
      <dc:date>2020-04-17T11:05:10Z</dc:date>
    </item>
    <item>
      <title>Re: Add x hours to epoch time</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Add-x-hours-to-epoch-time/m-p/476693#M1757</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;TRANSFORMS-&amp;lt;class&amp;gt; = &amp;lt;transform_stanza_name&amp;gt;, &amp;lt;transform_stanza_name2&amp;gt;,...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;TRANSFORMS-myevals=myeval, myeval2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and The rest looks good, let's reboot and check new events. how?&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 11:47:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Add-x-hours-to-epoch-time/m-p/476693#M1757</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-17T11:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: Add x hours to epoch time</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Add-x-hours-to-epoch-time/m-p/476694#M1758</link>
      <description>&lt;P&gt;They should come up within the sourcetype as an indexed field.&lt;/P&gt;

&lt;P&gt;Thanks @to4kawa !!!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 12:06:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Add-x-hours-to-epoch-time/m-p/476694#M1758</guid>
      <dc:creator>willadams</dc:creator>
      <dc:date>2020-04-17T12:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: Add x hours to epoch time</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Add-x-hours-to-epoch-time/m-p/476695#M1759</link>
      <description>&lt;P&gt;good job! Happy Splunking!&lt;BR /&gt;
and thank you @willadams&lt;BR /&gt;
You are finding the answer yourself.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 12:14:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Add-x-hours-to-epoch-time/m-p/476695#M1759</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-17T12:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: Add x hours to epoch time</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Add-x-hours-to-epoch-time/m-p/476696#M1760</link>
      <description>&lt;P&gt;Thank you for the guidance @to4kawa &lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 13:01:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Add-x-hours-to-epoch-time/m-p/476696#M1760</guid>
      <dc:creator>willadams</dc:creator>
      <dc:date>2020-04-17T13:01:19Z</dc:date>
    </item>
  </channel>
</rss>

