<?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: To Get sum of hosts in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/To-Get-sum-of-hosts/m-p/202171#M58632</link>
    <description>&lt;P&gt;Hey, you gave me some points, but did I answer the question?  If so, can you let us know which search worked?&lt;/P&gt;</description>
    <pubDate>Thu, 14 Apr 2016 04:18:57 GMT</pubDate>
    <dc:creator>jkat54</dc:creator>
    <dc:date>2016-04-14T04:18:57Z</dc:date>
    <item>
      <title>To Get sum of hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/To-Get-sum-of-hosts/m-p/202166#M58627</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;i have a simple query where i am getting response times by host. i want to get the sum of hosts as a filed. I have to use that field in Slack.&lt;/P&gt;

&lt;P&gt;host=xxx* sourcetype=yyyyy | stats avg(time) by host&lt;/P&gt;

&lt;P&gt;So i have tried to use eventstats but that did not accept host as an argument. Any suggestions please?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 03:24:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/To-Get-sum-of-hosts/m-p/202166#M58627</guid>
      <dc:creator>xvxt006</dc:creator>
      <dc:date>2016-04-14T03:24:18Z</dc:date>
    </item>
    <item>
      <title>Re: To Get sum of hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/To-Get-sum-of-hosts/m-p/202167#M58628</link>
      <description>&lt;P&gt;If you mean a distinct count of hosts:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; host=xxx* sourcetype=yyyyy | stats avg(time) dc(host) by host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, with the by clause dc(host) will always equal 1 so you'll need something like appendpipe:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; host=xxx* sourcetype=yyyyy | stats avg(time) by host | appendpipe [stats dc(host)]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Maybe you're looking to addcoltotals?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; host=xxx* sourcetype=yyyyy  | stats avg(time) by host | addcoltotals fieldname=avg(time))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you mean a sum of time by hosts:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; host=xxx* sourcetype=yyyyy | stats avg(time) sum(time) by host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you meant something else, please explain.&lt;/P&gt;

&lt;P&gt;There's also commands called addtotals, appendcols, append, etc. which you may be interested in.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 03:39:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/To-Get-sum-of-hosts/m-p/202167#M58628</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-04-14T03:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: To Get sum of hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/To-Get-sum-of-hosts/m-p/202168#M58629</link>
      <description>&lt;P&gt;Hi, Thank you for the reply. Say there are 4 distinct hosts, i need a filed which shows that count as 4. As i mentioned, i want to use that in Slack.  &lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 03:43:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/To-Get-sum-of-hosts/m-p/202168#M58629</guid>
      <dc:creator>xvxt006</dc:creator>
      <dc:date>2016-04-14T03:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: To Get sum of hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/To-Get-sum-of-hosts/m-p/202169#M58630</link>
      <description>&lt;P&gt;Ok you want appendcols most likely:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; host=xxx* sourcetype=yyyyy | stats avg(time) by host | appendcols [search host=xxx* sourcetype=yyyyy |stats dc(host)]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or maybe remove the by clause:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; host=xxx* sourcetype=yyyyy | stats avg(time) dc(host)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Unfortunately I have no idea what is meant by "want to use that in Slack" as I have no experience with "Slack".&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 03:55:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/To-Get-sum-of-hosts/m-p/202169#M58630</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-04-14T03:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: To Get sum of hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/To-Get-sum-of-hosts/m-p/202170#M58631</link>
      <description>&lt;P&gt;This is probably worth a good read too as it goes into differences between chart and stats:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/32001/difference-between-stats-and-chart.html"&gt;https://answers.splunk.com/answers/32001/difference-between-stats-and-chart.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 04:02:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/To-Get-sum-of-hosts/m-p/202170#M58631</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-04-14T04:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: To Get sum of hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/To-Get-sum-of-hosts/m-p/202171#M58632</link>
      <description>&lt;P&gt;Hey, you gave me some points, but did I answer the question?  If so, can you let us know which search worked?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 04:18:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/To-Get-sum-of-hosts/m-p/202171#M58632</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-04-14T04:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: To Get sum of hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/To-Get-sum-of-hosts/m-p/202172#M58633</link>
      <description>&lt;P&gt;Hi, Thanks for your responses.  Those were helpful in finding out different options. i have used appendcols and in combination with eventstats count(eval(match(host, "^x.*"))) as TotalHosts&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 04:27:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/To-Get-sum-of-hosts/m-p/202172#M58633</guid>
      <dc:creator>xvxt006</dc:creator>
      <dc:date>2016-04-14T04:27:08Z</dc:date>
    </item>
    <item>
      <title>Re: To Get sum of hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/To-Get-sum-of-hosts/m-p/202173#M58634</link>
      <description>&lt;P&gt;Hi @xvxt006&lt;/P&gt;

&lt;P&gt;Glad you were able to find a solution through @jkat54 &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Please don't forget to resolve the post by clicking "Accept" directly below his answer. This will make it easier to find for other users with similar questions. &lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2016 00:01:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/To-Get-sum-of-hosts/m-p/202173#M58634</guid>
      <dc:creator>ppablo</dc:creator>
      <dc:date>2016-04-19T00:01:44Z</dc:date>
    </item>
  </channel>
</rss>

