<?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 to subtract 15 hours from my event timestamp in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-15-hours-from-my-event-timestamp/m-p/347660#M63827</link>
    <description>&lt;P&gt;hey, did you try it out?&lt;/P&gt;</description>
    <pubDate>Tue, 26 Sep 2017 18:25:33 GMT</pubDate>
    <dc:creator>Sukisen1981</dc:creator>
    <dc:date>2017-09-26T18:25:33Z</dc:date>
    <item>
      <title>How to subtract 15 hours from my event timestamp</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-15-hours-from-my-event-timestamp/m-p/347654#M63821</link>
      <description>&lt;P&gt;Hi, i'm making a batch job status panel for websphere team . i need to show those jobs as pending state who are running since 15 hours till now . so what my purpose is that whatever time itr is now , it will subtract 15 hours from now and the time the job was last updated and then it will update the job status as pending . can anyone please help .&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2017 09:23:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-15-hours-from-my-event-timestamp/m-p/347654#M63821</guid>
      <dc:creator>Mohsin123</dc:creator>
      <dc:date>2017-09-25T09:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract 15 hours from my event timestamp</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-15-hours-from-my-event-timestamp/m-p/347655#M63822</link>
      <description>&lt;P&gt;@shraddhamuduli, try with either one of the following approaches:&lt;/P&gt;

&lt;P&gt;1) Pass &lt;CODE&gt;-15h@h&lt;/CODE&gt; as the earliest snap to time for your query using Splunk Time Picker. Following is the Simple XML example:&lt;/P&gt;

&lt;P&gt;2) Use &lt;CODE&gt;earliest&lt;/CODE&gt; and &lt;CODE&gt;latest&lt;/CODE&gt; options in the base search to apply the &lt;CODE&gt;-15h@h&lt;/CODE&gt; as the earliest time as selected in the time picker.&lt;/P&gt;

&lt;P&gt;Following is a run anywhere dashboard based on Splunk _internal Index which exemplifies the two approaches:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;Splunk Answers 577166 - Pull Events from 15 hours back&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="time" token="tokTime"&amp;gt;
      &amp;lt;label&amp;gt;&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;
        &amp;lt;earliest&amp;gt;-15h@h&amp;lt;/earliest&amp;gt;
        &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
      &amp;lt;/default&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;Option 1 - Time passed through earliest and latest options for Search in Simple XML- Splunk Internal Log Errors&amp;lt;/title&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=_internal sourcetype=splunkd log_level!="INFO"
| stats count by component            
          &amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;$tokTime.earliest$&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;$tokTime.latest$&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;Option 2 - Time passed through earliest and latest options in the Base Search - Splunk Internal Log Errors&amp;lt;/title&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=_internal sourcetype=splunkd log_level!="INFO" earliest="$tokTime.earliest$" latest="$tokTime.latest$"
| stats count by component            
          &amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Sep 2017 10:04:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-15-hours-from-my-event-timestamp/m-p/347655#M63822</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-09-25T10:04:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract 15 hours from my event timestamp</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-15-hours-from-my-event-timestamp/m-p/347656#M63823</link>
      <description>&lt;P&gt;Hi @niketnilay actually you are showing results that are &amp;gt;than 15 hours from now . but my question is ...i have current time now() and the last updated event time for a job , say current time is 16:04 pm and the last updated _time for a job is 24/09 09:00 am . so this job was complete in last status . but as the status hasnot updated to started yet and the timesta,mp is more than 15 hours then i can conclude that the job  is still running ..i will forcibly convert the status of this job from complete toi pending !&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2017 10:36:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-15-hours-from-my-event-timestamp/m-p/347656#M63823</guid>
      <dc:creator>Mohsin123</dc:creator>
      <dc:date>2017-09-25T10:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract 15 hours from my event timestamp</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-15-hours-from-my-event-timestamp/m-p/347657#M63824</link>
      <description>&lt;P&gt;Hi - @Anonymous   ·&lt;/P&gt;

&lt;P&gt;| eval current_time=strptime(strftime(now(),"%m-%d-%Y %H:%M:%S"),"%m-%d-%Y %H:%M:%S") |eval job_time=strptime(strftime(_time,"%m-%d-%Y %H:%M:%S"),"%m-%d-%Y %H:%M:%S") |  eval diff=round((current_time-job_time)/3600,2)| eval IsPending=if (job_status="Complete" AND diff&amp;gt;=15, "Pending","Running")&lt;/P&gt;

&lt;P&gt;1- You really need to be careful with you _time format, the code above assumes your _time is like 09-23-2017 17:23:08 format, else you just need to pass the pope format. It will affect the field diff as well. in short current_time-job_time in this case gives the difference in hours.&lt;BR /&gt;
2- You need to figure out the proper job_status field or the job completion status field name in you events.&lt;BR /&gt;
3 -Lastly, even if the job is complete and time elapsed is 14.9 hours it will still come as pending&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:56:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-15-hours-from-my-event-timestamp/m-p/347657#M63824</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2020-09-29T15:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract 15 hours from my event timestamp</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-15-hours-from-my-event-timestamp/m-p/347658#M63825</link>
      <description>&lt;P&gt;thanku so much..i will try this tomorrow&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2017 16:42:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-15-hours-from-my-event-timestamp/m-p/347658#M63825</guid>
      <dc:creator>Mohsin123</dc:creator>
      <dc:date>2017-09-25T16:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract 15 hours from my event timestamp</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-15-hours-from-my-event-timestamp/m-p/347659#M63826</link>
      <description>&lt;P&gt;@Anonymous, following query might change as per the fields/values you have in your real-time data. Current query is based on partial information provided in your details. Assuming &lt;CODE&gt;status&lt;/CODE&gt; as the field containing job status (PS: field names are case sensitive, so make sure that it matches exactly as the field present in your data). Couple of values to be used in the query are "running" and "complete". Values are case insensitive, however make sure the values are the same event without same casing.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;YourBaseSearch&amp;gt;
| eval status=if(now()-_time&amp;gt;54000 AND status=="complete","running",status)
| &amp;lt;YourRemainingSearch&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Since &lt;CODE&gt;_time&lt;/CODE&gt; and &lt;CODE&gt;now()&lt;/CODE&gt; will give epoch times they can directly be used in calculation (without any manipulation/conversion).&lt;BR /&gt;
PS: 54000 sec = 15*60* 60 sec&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:56:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-15-hours-from-my-event-timestamp/m-p/347659#M63826</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T15:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract 15 hours from my event timestamp</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-15-hours-from-my-event-timestamp/m-p/347660#M63827</link>
      <description>&lt;P&gt;hey, did you try it out?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 18:25:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-subtract-15-hours-from-my-event-timestamp/m-p/347660#M63827</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2017-09-26T18:25:33Z</dc:date>
    </item>
  </channel>
</rss>

