<?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: Why is the time difference not evaluating correctly? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-time-difference-not-evaluating-correctly/m-p/439162#M76571</link>
    <description>&lt;P&gt;You could of course just timechart the daily runtime value by assigning &lt;CODE&gt;_time = startTime&lt;/CODE&gt; and then running a timechart with a &lt;CODE&gt;span=1d&lt;/CODE&gt;. That doesn't visualize when the job started and stopped exactly (I thought that is what you were after), but does allow you to show a line/bar chart to show the runtime trend over time.&lt;/P&gt;

&lt;P&gt;For example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats earliest(_time) as startTime, latest(_time) as endTime by JobName
| eval _time=startTime
| eval runTime=(endTime-startTime)
| timechart span=1d avg(runTime) as runTime by jobName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note: this charts the runtime as a number of seconds. If jobs typically take several minutes or hours to run, you might be better of displaying it as number of minutes. For example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats earliest(_time) as startTime, latest(_time) as endTime by JobName
| eval _time=startTime
| eval runTime=round((endTime-startTime)/60,1)
| timechart span=1d avg(runTime) as runTime by jobName
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 25 Jun 2019 07:06:51 GMT</pubDate>
    <dc:creator>FrankVl</dc:creator>
    <dc:date>2019-06-25T07:06:51Z</dc:date>
    <item>
      <title>Why is the time difference not evaluating correctly?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-time-difference-not-evaluating-correctly/m-p/439153#M76562</link>
      <description>&lt;P&gt;I am working to find the difference between two events and have the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats earliest(_time) as startTime, latest(_time) as endTime by JobName
| eval time=strftime(_time, "%H:%M:%S")
| eval runTime=(endTime-startTime)
| eval runTime=strftime(runTime,"%H:%M:%S")
| table JobName, runTime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am getting back a runTime of 22:43:35, which is not what I expect or want. I would like the time to show starting from 0, I want the runTime to show in a format of 03:23:00; 3 hours and 23 minutes.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2019 13:56:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-time-difference-not-evaluating-correctly/m-p/439153#M76562</guid>
      <dc:creator>aohls</dc:creator>
      <dc:date>2019-06-24T13:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the time difference not evaluating correctly?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-time-difference-not-evaluating-correctly/m-p/439154#M76563</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats earliest(_time) as startTime, latest(_time) as endTime by JobName
| eval time=strftime(_time, "%H:%M:%S")
| eval runTime=(endTime-startTime)
| eval runTime=tostring(runTime,"duration")
| table JobName, runTime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Jun 2019 14:04:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-time-difference-not-evaluating-correctly/m-p/439154#M76563</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2019-06-24T14:04:01Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the time difference not evaluating correctly?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-time-difference-not-evaluating-correctly/m-p/439155#M76564</link>
      <description>&lt;P&gt;@somesoni2 That worked perfect and exactly what I was looking for.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2019 14:07:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-time-difference-not-evaluating-correctly/m-p/439155#M76564</guid>
      <dc:creator>aohls</dc:creator>
      <dc:date>2019-06-24T14:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the time difference not evaluating correctly?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-time-difference-not-evaluating-correctly/m-p/439156#M76565</link>
      <description>&lt;P&gt;Yeah,  &lt;CODE&gt;tostring(runTime,"duration")&lt;/CODE&gt; should work.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2019 14:08:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-time-difference-not-evaluating-correctly/m-p/439156#M76565</guid>
      <dc:creator>VatsalJagani</dc:creator>
      <dc:date>2019-06-24T14:08:49Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the time difference not evaluating correctly?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-time-difference-not-evaluating-correctly/m-p/439157#M76566</link>
      <description>&lt;P&gt;Would this mean that I cannot use the runTime in a timechart? The runTime is the running of jobs and I was looking to show the daily runs to graph over time.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2019 14:15:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-time-difference-not-evaluating-correctly/m-p/439157#M76566</guid>
      <dc:creator>aohls</dc:creator>
      <dc:date>2019-06-24T14:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the time difference not evaluating correctly?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-time-difference-not-evaluating-correctly/m-p/439158#M76567</link>
      <description>&lt;P&gt;runTime was in seconds, after using tostring we have converted into string. You can use integer in timechart not string.&lt;BR /&gt;
But I don't think timechart will fit here, you can use &lt;A href="https://splunkbase.splunk.com/app/3120/"&gt;Timeline visualization&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2019 14:26:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-time-difference-not-evaluating-correctly/m-p/439158#M76567</guid>
      <dc:creator>VatsalJagani</dc:creator>
      <dc:date>2019-06-24T14:26:35Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the time difference not evaluating correctly?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-time-difference-not-evaluating-correctly/m-p/439159#M76568</link>
      <description>&lt;P&gt;runtime is just the number of seconds between start and end time. Not sure how you envisioned timecharting that &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
You might want to take a look at visualization add-ons that are perhaps more suitable for displaying job runtimes over time. e.g.: &lt;A href="https://splunkbase.splunk.com/app/3120/"&gt;https://splunkbase.splunk.com/app/3120/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Also: not sure what that &lt;CODE&gt;| eval time=strftime(_time, "%H:%M:%S")&lt;/CODE&gt; is doing there, as there is no &lt;CODE&gt;_time&lt;/CODE&gt; field anymore after that stats command. But then again, you're not using that field anyway.&lt;/P&gt;

&lt;P&gt;PS: you could also do &lt;CODE&gt;| stats range(_time) as runTime by JobName| eval runTime=tostring(runTime,"duration")&lt;/CODE&gt; . But if you really want to visualize the job run on a timescale, you are probably going to need those start and end time values.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2019 14:30:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-time-difference-not-evaluating-correctly/m-p/439159#M76568</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-06-24T14:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the time difference not evaluating correctly?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-time-difference-not-evaluating-correctly/m-p/439160#M76569</link>
      <description>&lt;P&gt;That makes sense. The idea was that these jobs run every day so I wanted to keep track of the run time to chart how long it is taking over time; really to trend the items over time.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2019 15:56:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-time-difference-not-evaluating-correctly/m-p/439160#M76569</guid>
      <dc:creator>aohls</dc:creator>
      <dc:date>2019-06-24T15:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the time difference not evaluating correctly?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-time-difference-not-evaluating-correctly/m-p/439161#M76570</link>
      <description>&lt;P&gt;Minor Revisions &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats earliest(_time) as startTime, latest(_time) as endTime by JobName
| eval runTime=(endTime-startTime)
| eval time=strftime(runTime, "%H:%M:%S")
| table JobName, time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Jun 2019 16:33:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-time-difference-not-evaluating-correctly/m-p/439161#M76570</guid>
      <dc:creator>sumanssah</dc:creator>
      <dc:date>2019-06-24T16:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the time difference not evaluating correctly?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-time-difference-not-evaluating-correctly/m-p/439162#M76571</link>
      <description>&lt;P&gt;You could of course just timechart the daily runtime value by assigning &lt;CODE&gt;_time = startTime&lt;/CODE&gt; and then running a timechart with a &lt;CODE&gt;span=1d&lt;/CODE&gt;. That doesn't visualize when the job started and stopped exactly (I thought that is what you were after), but does allow you to show a line/bar chart to show the runtime trend over time.&lt;/P&gt;

&lt;P&gt;For example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats earliest(_time) as startTime, latest(_time) as endTime by JobName
| eval _time=startTime
| eval runTime=(endTime-startTime)
| timechart span=1d avg(runTime) as runTime by jobName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note: this charts the runtime as a number of seconds. If jobs typically take several minutes or hours to run, you might be better of displaying it as number of minutes. For example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats earliest(_time) as startTime, latest(_time) as endTime by JobName
| eval _time=startTime
| eval runTime=round((endTime-startTime)/60,1)
| timechart span=1d avg(runTime) as runTime by jobName
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Jun 2019 07:06:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-time-difference-not-evaluating-correctly/m-p/439162#M76571</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-06-25T07:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the time difference not evaluating correctly?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-time-difference-not-evaluating-correctly/m-p/439163#M76572</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats range(_time) AS runTime BY JobName
| table JobName, runTime
| fieldformat runTime = tostring(runTime, "duration")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Jul 2019 18:27:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-time-difference-not-evaluating-correctly/m-p/439163#M76572</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-07-01T18:27:16Z</dc:date>
    </item>
  </channel>
</rss>

