<?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 edit my search to get total time of events (last-first) and sum by source, by host? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-search-to-get-total-time-of-events-last-first-and/m-p/250080#M48105</link>
    <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main host="*"  
                 | stats earliest(_time) as First latest(_time) as Last by host source 
                 | eval difference=Last-First 
                 | stats sum(difference) as total_difference by host
                 | eval todifference=tostring(total_difference, "duration")  
                 | table host todifference
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you convert your duration to string, you would not be able to plot it. (y-axis values should be numeric) So remove the &lt;CODE&gt;| eval todifferen...&lt;/CODE&gt; from the above search and use the appropriate visualization.&lt;/P&gt;</description>
    <pubDate>Mon, 10 Oct 2016 19:36:41 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2016-10-10T19:36:41Z</dc:date>
    <item>
      <title>How to edit my search to get total time of events (last-first) and sum by source, by host?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-search-to-get-total-time-of-events-last-first-and/m-p/250078#M48103</link>
      <description>&lt;P&gt;So I am trying to get the cumulative sum of all the time taken by each host, so far I could cumulate for a single host, how can i loop through all the hosts  and show it in a table&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main host="XYZ"  
                | stats earliest(_time) as First latest(_time) as Last by source 
                | eval difference=Last-First 
                | stats sum(difference) as total_difference 
                | eval todifference=tostring(total_difference, "duration")  
                | table todifference
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;host1, time-taken&lt;BR /&gt;
host2, time-taken&lt;/P&gt;

&lt;P&gt;And then perhaps plot the time in a timechart with x-axis with host-names and Y-axis with time taken&lt;/P&gt;</description>
      <pubDate>Mon, 10 Oct 2016 19:06:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-search-to-get-total-time-of-events-last-first-and/m-p/250078#M48103</guid>
      <dc:creator>smhsplunk</dc:creator>
      <dc:date>2016-10-10T19:06:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to get total time of events (last-first) and sum by source, by host?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-search-to-get-total-time-of-events-last-first-and/m-p/250079#M48104</link>
      <description>&lt;P&gt;How about this? Do you need the first and last by source? or by host?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=main   
                 | stats earliest(_time) as First latest(_time) as Last by host 
                 | eval difference=Last-First 
                 | eval todifference=tostring(total_difference, "duration")  
                 | table todifference
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Oct 2016 19:25:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-search-to-get-total-time-of-events-last-first-and/m-p/250079#M48104</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-10-10T19:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to get total time of events (last-first) and sum by source, by host?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-search-to-get-total-time-of-events-last-first-and/m-p/250080#M48105</link>
      <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main host="*"  
                 | stats earliest(_time) as First latest(_time) as Last by host source 
                 | eval difference=Last-First 
                 | stats sum(difference) as total_difference by host
                 | eval todifference=tostring(total_difference, "duration")  
                 | table host todifference
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you convert your duration to string, you would not be able to plot it. (y-axis values should be numeric) So remove the &lt;CODE&gt;| eval todifferen...&lt;/CODE&gt; from the above search and use the appropriate visualization.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Oct 2016 19:36:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-search-to-get-total-time-of-events-last-first-and/m-p/250080#M48105</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-10-10T19:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to get total time of events (last-first) and sum by source, by host?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-search-to-get-total-time-of-events-last-first-and/m-p/250081#M48106</link>
      <description>&lt;P&gt;It has to go through all the sources to find the total time taken by each source, then add those times&lt;/P&gt;

&lt;P&gt;What the above does is that it gives you time difference between the last event of last source minus first event of first source (you can have many times in between where no events may not happen...), hence by source in my code. &lt;/P&gt;

&lt;P&gt;so first and last by source and then add it cumulatively to find by host&lt;BR /&gt;
Then show table exact time taken by each host&lt;/P&gt;

&lt;P&gt;I wanted to do "by source by host" but it doesnt work&lt;/P&gt;</description>
      <pubDate>Mon, 10 Oct 2016 19:37:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-search-to-get-total-time-of-events-last-first-and/m-p/250081#M48106</guid>
      <dc:creator>smhsplunk</dc:creator>
      <dc:date>2016-10-10T19:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to get total time of events (last-first) and sum by source, by host?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-search-to-get-total-time-of-events-last-first-and/m-p/250082#M48107</link>
      <description>&lt;P&gt;This seems to give me all times over all the hosts. I want total time by each host&lt;/P&gt;

&lt;P&gt;host1 time-takenX&lt;BR /&gt;
host2 time-takenY&lt;/P&gt;</description>
      <pubDate>Mon, 10 Oct 2016 19:43:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-search-to-get-total-time-of-events-last-first-and/m-p/250082#M48107</guid>
      <dc:creator>smhsplunk</dc:creator>
      <dc:date>2016-10-10T19:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to get total time of events (last-first) and sum by source, by host?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-search-to-get-total-time-of-events-last-first-and/m-p/250083#M48108</link>
      <description>&lt;P&gt;Strange, if you're using the query as-is, it's should give you one row per host as we're using  &lt;CODE&gt;| stats sum(difference) as total_difference by host&lt;/CODE&gt; . Can you double check?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Oct 2016 19:48:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-search-to-get-total-time-of-events-last-first-and/m-p/250083#M48108</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-10-10T19:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to get total time of events (last-first) and sum by source, by host?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-search-to-get-total-time-of-events-last-first-and/m-p/250084#M48109</link>
      <description>&lt;P&gt;You are right! Sorry I missed that part,&lt;BR /&gt;
I will get started with the plotting now&lt;/P&gt;</description>
      <pubDate>Mon, 10 Oct 2016 19:54:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-search-to-get-total-time-of-events-last-first-and/m-p/250084#M48109</guid>
      <dc:creator>smhsplunk</dc:creator>
      <dc:date>2016-10-10T19:54:15Z</dc:date>
    </item>
  </channel>
</rss>

