<?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: summing values from stats in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/summing-values-from-stats/m-p/323185#M164528</link>
    <description>&lt;P&gt;well I found a way to make it work, not sure if it is the best way though&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=mso_statistics sourcetype=ic_connectivity_5min-too_small  stat_name=subscribers |rex "\d+\s(?&amp;lt;mso&amp;gt;\w+)"|stats max(stat_val) as Subscribers by mso|where like(mso,"%testco%") |stats sum(Subscribers) as count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In the query testco is actually a token value, I substituted it just to illustrate&lt;/P&gt;</description>
    <pubDate>Wed, 06 Dec 2017 20:57:00 GMT</pubDate>
    <dc:creator>dbcase</dc:creator>
    <dc:date>2017-12-06T20:57:00Z</dc:date>
    <item>
      <title>summing values from stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/summing-values-from-stats/m-p/323184#M164527</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a query that produces a stats table that looks like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    company          count
    testco                100
    testcoa              200
    testcob              100
    testcoc              500
    nottestco          50
    otherco             150
    someco             300
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I need to sum up the counts for each company.  In this example testco, testcoa, testcob and testcoc are all the same company just different divisions.  I need to return a value of 900 for testco, 50 for nottestco, 150 for otherco and 300 for someco.&lt;/P&gt;

&lt;P&gt;Seems easy but my brain isn't working today......&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 20:28:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/summing-values-from-stats/m-p/323184#M164527</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2017-12-06T20:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: summing values from stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/summing-values-from-stats/m-p/323185#M164528</link>
      <description>&lt;P&gt;well I found a way to make it work, not sure if it is the best way though&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=mso_statistics sourcetype=ic_connectivity_5min-too_small  stat_name=subscribers |rex "\d+\s(?&amp;lt;mso&amp;gt;\w+)"|stats max(stat_val) as Subscribers by mso|where like(mso,"%testco%") |stats sum(Subscribers) as count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In the query testco is actually a token value, I substituted it just to illustrate&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 20:57:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/summing-values-from-stats/m-p/323185#M164528</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2017-12-06T20:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: summing values from stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/summing-values-from-stats/m-p/323186#M164529</link>
      <description>&lt;P&gt;You may want to use a lookup to federate this information and then search on that field.&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Addfieldsfromexternaldatasources"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Addfieldsfromexternaldatasources&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;You may already have this information in the form of a DB or CMDB.  &lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 21:17:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/summing-values-from-stats/m-p/323186#M164529</guid>
      <dc:creator>Lamar</dc:creator>
      <dc:date>2017-12-06T21:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: summing values from stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/summing-values-from-stats/m-p/323187#M164530</link>
      <description>&lt;P&gt;Hi Lamar,&lt;/P&gt;

&lt;P&gt;I'm not sure I understand what you are trying to say....&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 21:37:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/summing-values-from-stats/m-p/323187#M164530</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2017-12-06T21:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: summing values from stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/summing-values-from-stats/m-p/323188#M164531</link>
      <description>&lt;P&gt;With a lookup, what you can do is something similar to this:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;lookup_file.csv&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mso|company
testco|Company1
testcoa|Company1
testcob|Company1
testcoc|Company1
otherco|Company2
someotherco|Company3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;search&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=mso_statistics sourcetype=ic_connectivity_5min-too_small  stat_name=subscribers | lookup lookup_file mso OUTPUT company | eventstats count by company | stats sum(count) as totals by company
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;EDIT: a letter&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 21:50:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/summing-values-from-stats/m-p/323188#M164531</guid>
      <dc:creator>Lamar</dc:creator>
      <dc:date>2017-12-06T21:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: summing values from stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/summing-values-from-stats/m-p/323189#M164532</link>
      <description>&lt;P&gt;What using a lookup provides is the efficiency of updating one source of information rather than have an incredibly monolithic macro (or god forbid, searches) that include the logic for handling all of the different companies in your data.  You could even go so far as include other types of information about said company in the lookup that could return things like address, type of company, contact information...etc.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 21:54:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/summing-values-from-stats/m-p/323189#M164532</guid>
      <dc:creator>Lamar</dc:creator>
      <dc:date>2017-12-06T21:54:38Z</dc:date>
    </item>
    <item>
      <title>Re: summing values from stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/summing-values-from-stats/m-p/323190#M164533</link>
      <description>&lt;P&gt;If you literally have the table in the original post and just need the output you specified, I'd use this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[ your search] 
| eval company=if(like(company, "testco%"), "testco", company) 
| stats sum(count) AS count BY company 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Dec 2017 21:56:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/summing-values-from-stats/m-p/323190#M164533</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-12-06T21:56:10Z</dc:date>
    </item>
  </channel>
</rss>

