<?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 add values of multiple variable, where the number of variable differs in different events in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-values-of-multiple-variable-where-the-number-of/m-p/119029#M31891</link>
    <description>&lt;P&gt;&lt;CODE&gt;xmlkv&lt;/CODE&gt; won't create the total, but it should extract the fields.&lt;/P&gt;

&lt;P&gt;I edited the regular expression above - maybe it will work now.&lt;/P&gt;

&lt;P&gt;I also added the command to sum the values in a multi-valued field.&lt;/P&gt;</description>
    <pubDate>Wed, 19 Nov 2014 15:12:23 GMT</pubDate>
    <dc:creator>lguinn2</dc:creator>
    <dc:date>2014-11-19T15:12:23Z</dc:date>
    <item>
      <title>How to add values of multiple variable, where the number of variable differs in different events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-values-of-multiple-variable-where-the-number-of/m-p/119022#M31884</link>
      <description>&lt;P&gt;i have a field in my log as "BookCount 10 /BookCount"&lt;BR /&gt;
if a Library pass contains more than one members then the field repeats based on the number of members.&lt;BR /&gt;
For Ex:  If a Library pass has 1 members, then my log returns 1 bookcount values as "BookCount 10 /BookCount"&lt;BR /&gt;
If a Library pass has 3 members, then my log returns three bookcount values as below,&lt;BR /&gt;
 "BookCount 10 /BookCount"       "BookCount 50 /BookCount"     "BookCount 40 /BookCount"&lt;BR /&gt;
I want to get the sum of bookcount. &lt;BR /&gt;
I am using rex "(openTag)BookCount(?CountOfBook.*)(closeTag)BookCount"|stats list(CountOfBook) as "TotalCount".&lt;BR /&gt;
I am getting only the first value.&lt;/P&gt;

&lt;P&gt;Can anyone suggest me a better query to implement this????&lt;/P&gt;</description>
      <pubDate>Tue, 18 Nov 2014 12:40:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-values-of-multiple-variable-where-the-number-of/m-p/119022#M31884</guid>
      <dc:creator>harish_ka</dc:creator>
      <dc:date>2014-11-18T12:40:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to add values of multiple variable, where the number of variable differs in different events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-values-of-multiple-variable-where-the-number-of/m-p/119023#M31885</link>
      <description>&lt;P&gt;"BookCount 10 /BookCount" is a tag. I was not able to use &amp;lt;&amp;gt; in this text box.&lt;BR /&gt;
openTag(BookCount)-value-CloseTag(BookCount)&lt;/P&gt;</description>
      <pubDate>Tue, 18 Nov 2014 12:52:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-values-of-multiple-variable-where-the-number-of/m-p/119023#M31885</guid>
      <dc:creator>harish_ka</dc:creator>
      <dc:date>2014-11-18T12:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to add values of multiple variable, where the number of variable differs in different events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-values-of-multiple-variable-where-the-number-of/m-p/119024#M31886</link>
      <description>&lt;P&gt;Can anyone help me on this????&lt;/P&gt;</description>
      <pubDate>Tue, 18 Nov 2014 14:33:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-values-of-multiple-variable-where-the-number-of/m-p/119024#M31886</guid>
      <dc:creator>harish_ka</dc:creator>
      <dc:date>2014-11-18T14:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to add values of multiple variable, where the number of variable differs in different events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-values-of-multiple-variable-where-the-number-of/m-p/119025#M31887</link>
      <description>&lt;P&gt;I assume that the format is actually XML, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;BookCount&amp;gt;10&amp;lt;/BookCount&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;BookCount&amp;gt;10&amp;lt;/BookCount&amp;gt;&amp;lt;BookCount&amp;gt;50&amp;lt;/BookCount&amp;gt;&amp;lt;BookCount&amp;gt;40&amp;lt;/BookCount&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;with no quotation marks?&lt;/P&gt;</description>
      <pubDate>Tue, 18 Nov 2014 15:47:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-values-of-multiple-variable-where-the-number-of/m-p/119025#M31887</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2014-11-18T15:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to add values of multiple variable, where the number of variable differs in different events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-values-of-multiple-variable-where-the-number-of/m-p/119026#M31888</link>
      <description>&lt;P&gt;If the data is formatted as XML, you could try the xmlkv command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere
| xmlkv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;CODE&gt;rex&lt;/CODE&gt; is only going to give you the first value, because your regular expression only finds the first value. &lt;BR /&gt;
You could try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere
| rex max_match=0 "\&amp;lt;BookCount\&amp;gt;\s*(?&amp;lt;CountOfBook&amp;gt;\d+)\s*\&amp;lt;\/BookCount\&amp;gt;"
| mvexpand CountOfBook
| stats sum(CountofBook) as TotalBooks
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should extract multiple values of BookCount; you will end up with a multi-valued field.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Nov 2014 15:55:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-values-of-multiple-variable-where-the-number-of/m-p/119026#M31888</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2014-11-18T15:55:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to add values of multiple variable, where the number of variable differs in different events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-values-of-multiple-variable-where-the-number-of/m-p/119027#M31889</link>
      <description>&lt;P&gt;So how to add this values?&lt;BR /&gt;
i need the total value of BookCount&lt;/P&gt;</description>
      <pubDate>Tue, 18 Nov 2014 16:36:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-values-of-multiple-variable-where-the-number-of/m-p/119027#M31889</guid>
      <dc:creator>harish_ka</dc:creator>
      <dc:date>2014-11-18T16:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to add values of multiple variable, where the number of variable differs in different events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-values-of-multiple-variable-where-the-number-of/m-p/119028#M31890</link>
      <description>&lt;P&gt;Thanks Lguinn. &lt;BR /&gt;
But this regex didnt work for me. &lt;BR /&gt;
Can you explain how can i use xmlkv for getting this total of CountOfBook&lt;/P&gt;</description>
      <pubDate>Wed, 19 Nov 2014 12:53:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-values-of-multiple-variable-where-the-number-of/m-p/119028#M31890</guid>
      <dc:creator>harish_ka</dc:creator>
      <dc:date>2014-11-19T12:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to add values of multiple variable, where the number of variable differs in different events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-values-of-multiple-variable-where-the-number-of/m-p/119029#M31891</link>
      <description>&lt;P&gt;&lt;CODE&gt;xmlkv&lt;/CODE&gt; won't create the total, but it should extract the fields.&lt;/P&gt;

&lt;P&gt;I edited the regular expression above - maybe it will work now.&lt;/P&gt;

&lt;P&gt;I also added the command to sum the values in a multi-valued field.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Nov 2014 15:12:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-values-of-multiple-variable-where-the-number-of/m-p/119029#M31891</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2014-11-19T15:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to add values of multiple variable, where the number of variable differs in different events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-values-of-multiple-variable-where-the-number-of/m-p/119030#M31892</link>
      <description>&lt;P&gt;It worked...&lt;BR /&gt;
Thank You so much...&lt;BR /&gt;
:)&lt;/P&gt;</description>
      <pubDate>Wed, 19 Nov 2014 16:04:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-values-of-multiple-variable-where-the-number-of/m-p/119030#M31892</guid>
      <dc:creator>harish_ka</dc:creator>
      <dc:date>2014-11-19T16:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to add values of multiple variable, where the number of variable differs in different events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-values-of-multiple-variable-where-the-number-of/m-p/119031#M31893</link>
      <description>&lt;P&gt;How can i get the sum of bookcount if the BookCount tags are not appeared one after another in my log??&lt;BR /&gt;
LIke below&lt;/P&gt;

&lt;P&gt;"BookCount 10 /BookCount" "BookName ABC /BookName" ......."BookCount 50 /BookCount" "BookName XYZ /BookName"......"BookCount 40 /BookCount"&lt;/P&gt;</description>
      <pubDate>Thu, 04 Dec 2014 07:55:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-values-of-multiple-variable-where-the-number-of/m-p/119031#M31893</guid>
      <dc:creator>harish_ka</dc:creator>
      <dc:date>2014-12-04T07:55:56Z</dc:date>
    </item>
  </channel>
</rss>

