<?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: sum fields in same event in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/sum-fields-in-same-event/m-p/16269#M2150</link>
    <description>&lt;P&gt;seems like a strange way to have the data extracted, if I follow it correctly. &lt;/P&gt;

&lt;P&gt;If your data was instead extracted where A and B were the actual field names, and they had multivalued values of [1,1] and [2,2] respectively,  instead of the 'somefieldname' and 'somefieldvalue' fields,  it would be a bit easier. In such a case you could get to your end result with: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt; | stats sum(A) sum(B) by _time, _serial
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Apart from that, i think what you need is to use one of the multivalue operators to break out your events into individual single value events and then do a stats by _time _serial as in the above.&lt;/P&gt;</description>
    <pubDate>Sat, 26 Jun 2010 13:19:54 GMT</pubDate>
    <dc:creator>sideview</dc:creator>
    <dc:date>2010-06-26T13:19:54Z</dc:date>
    <item>
      <title>sum fields in same event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-fields-in-same-event/m-p/16268#M2149</link>
      <description>&lt;P&gt;I need to sum fields by other fields in the same event.&lt;/P&gt;

&lt;P&gt;Here is an example event:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time                                somefieldname   somefieldvalue
6/26/10 3:09:23.000 AM               A               1
                                     A               1
                                     B               2
                                     B               2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How could I sum the values in somefieldvalue by somefieldname, then graph the sum.  IE '| timechart span=1m avg(somefieldvalue) by somefield.'&lt;/P&gt;

&lt;P&gt;For this event on the timechart A would equal to 2 and B would equal to 4.&lt;/P&gt;

&lt;P&gt;I'm at a loss.  Any help is appreciated.&lt;/P&gt;

&lt;P&gt;Thanks,
Joe&lt;/P&gt;</description>
      <pubDate>Sat, 26 Jun 2010 10:36:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-fields-in-same-event/m-p/16268#M2149</guid>
      <dc:creator>jrizzobwa</dc:creator>
      <dc:date>2010-06-26T10:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: sum fields in same event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-fields-in-same-event/m-p/16269#M2150</link>
      <description>&lt;P&gt;seems like a strange way to have the data extracted, if I follow it correctly. &lt;/P&gt;

&lt;P&gt;If your data was instead extracted where A and B were the actual field names, and they had multivalued values of [1,1] and [2,2] respectively,  instead of the 'somefieldname' and 'somefieldvalue' fields,  it would be a bit easier. In such a case you could get to your end result with: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt; | stats sum(A) sum(B) by _time, _serial
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Apart from that, i think what you need is to use one of the multivalue operators to break out your events into individual single value events and then do a stats by _time _serial as in the above.&lt;/P&gt;</description>
      <pubDate>Sat, 26 Jun 2010 13:19:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-fields-in-same-event/m-p/16269#M2150</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2010-06-26T13:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: sum fields in same event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-fields-in-same-event/m-p/16270#M2151</link>
      <description>&lt;P&gt;You might be able to use &lt;A href="http://www.splunk.com/base/Documentation/latest/SearchReference/Multikv" rel="nofollow"&gt;multikv&lt;/A&gt; depending on how your actual raw text is structured.  If you are dealing with a text table like format (like shown in your example), then this should work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | multikv fields somefieldname somefieldvalue | timechart sum(somefieldvalue) by somefieldname
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, if &lt;CODE&gt;somefieldname&lt;/CODE&gt; and &lt;CODE&gt;somefieldvalue&lt;/CODE&gt; are two independent multi-value fields, then we are looking at the scenario that Nick was referring to.  Although, I'm not sure I follow what he is suggesting that you do.  I'm not sure this case can be solved without using a custom search script.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jun 2010 00:22:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-fields-in-same-event/m-p/16270#M2151</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-06-29T00:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: sum fields in same event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-fields-in-same-event/m-p/16271#M2152</link>
      <description>&lt;P&gt;I ended up splitting the event into multiple events using &lt;A href="http://www.splunkbase.com/apps/All/4.x/Add-On/app%3asplit" rel="nofollow"&gt;split&lt;/A&gt;.  Then I could use stats and timechart as expected.&lt;/P&gt;

&lt;P&gt;Thanks,
Joe&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2010 04:56:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-fields-in-same-event/m-p/16271#M2152</guid>
      <dc:creator>jrizzobwa</dc:creator>
      <dc:date>2010-07-01T04:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: sum fields in same event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-fields-in-same-event/m-p/16272#M2153</link>
      <description>&lt;P&gt;Here's a custom search command I wrote that provides an "mvsum" operator: &lt;A href="http://jordan.broughs.net/archives/2012/06/mvsum-for-splunk-summing-multi-valued-fields-within-a-single-event"&gt;http://jordan.broughs.net/archives/2012/06/mvsum-for-splunk-summing-multi-valued-fields-within-a-single-event&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jun 2012 15:12:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-fields-in-same-event/m-p/16272#M2153</guid>
      <dc:creator>Jordan_Brough</dc:creator>
      <dc:date>2012-06-29T15:12:38Z</dc:date>
    </item>
  </channel>
</rss>

