<?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 up all the values using a delimiter when corresponding keys are different in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Sum-up-all-the-values-using-a-delimiter-when-corresponding-keys/m-p/277455#M83672</link>
    <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval s="[11/Dec/2015:04:45:26 +481] Topic1_0=[9,7,2] Topic1_1=[3,2,1] Topic1_2=[6,4,2] Topic1_3=[2,1,1]
[11/Dec/2015:04:45:26 +481] Topic2_0=[5,3,2] Topic2_1=[2,1,1] Topic2_2=[0,0,0] Topic2_3=[1,1,0]"
| rex max_match=0 field=s "\]\s(?&amp;lt;top&amp;gt;\w+)_\d=\[(?&amp;lt;prod&amp;gt;\d+),(?&amp;lt;cons&amp;gt;\d+),(?&amp;lt;lag&amp;gt;\d+)" 
| eval z=mvzip(top, prod) | eval z=mvzip(z, cons) | eval z=mvzip(z, lag)
| mvexpand z
| eval t=split(z, ",")
| eval Topic=mvindex(t, 0) | eval prod=mvindex(t, 1) | eval cons=mvindex(t, 2) | eval lag=mvindex(t, 3)
| stats sum(prod) as Produced, sum(cons) as Consumed, sum(lag) as Lag by Topic
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 11 Dec 2015 15:10:08 GMT</pubDate>
    <dc:creator>sundareshr</dc:creator>
    <dc:date>2015-12-11T15:10:08Z</dc:date>
    <item>
      <title>Sum up all the values using a delimiter when corresponding keys are different</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-up-all-the-values-using-a-delimiter-when-corresponding-keys/m-p/277454#M83671</link>
      <description>&lt;P&gt;I have Splunk logs as shown in below format from a Kafka server's topic metadata.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Topic#No_Partion#No = [F1,F2,F3]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;F1= Produced Message Count to this Topic by a producer group&lt;BR /&gt;
F2=Consumed Message Count from this Topic by a consumer group&lt;BR /&gt;
F3=Total lag count between producer and consumer i.e F1-F2&lt;/P&gt;

&lt;P&gt;Sample logs:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[11/Dec/2015:04:45:26 +481] Topic1_0=[9,7,2] Topic1_1=[3,2,1] Topic1_2=[6,4,2] Topic1_3=[2,1,1]
[11/Dec/2015:04:45:26 +481] Topic2_0=[5,3,2] Topic2_1=[2,1,1] Topic2_2=[0,0,0] Topic2_3=[1,1,0]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now I need the sum of message counts of specific Topic from all part-ions&lt;BR /&gt;
Total messages produced to Topic1 = 20 {9+3+6+2}&lt;BR /&gt;
Total messages consumed from Topic1 = 14 {7+2+4+1}&lt;BR /&gt;
Lag count between consumer and producer using Topic1= 6{2+1+2+1}&lt;/P&gt;

&lt;P&gt;Can someone help with a Splunk query.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Dec 2015 06:49:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-up-all-the-values-using-a-delimiter-when-corresponding-keys/m-p/277454#M83671</guid>
      <dc:creator>vpuneeth007</dc:creator>
      <dc:date>2015-12-11T06:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: Sum up all the values using a delimiter when corresponding keys are different</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-up-all-the-values-using-a-delimiter-when-corresponding-keys/m-p/277455#M83672</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval s="[11/Dec/2015:04:45:26 +481] Topic1_0=[9,7,2] Topic1_1=[3,2,1] Topic1_2=[6,4,2] Topic1_3=[2,1,1]
[11/Dec/2015:04:45:26 +481] Topic2_0=[5,3,2] Topic2_1=[2,1,1] Topic2_2=[0,0,0] Topic2_3=[1,1,0]"
| rex max_match=0 field=s "\]\s(?&amp;lt;top&amp;gt;\w+)_\d=\[(?&amp;lt;prod&amp;gt;\d+),(?&amp;lt;cons&amp;gt;\d+),(?&amp;lt;lag&amp;gt;\d+)" 
| eval z=mvzip(top, prod) | eval z=mvzip(z, cons) | eval z=mvzip(z, lag)
| mvexpand z
| eval t=split(z, ",")
| eval Topic=mvindex(t, 0) | eval prod=mvindex(t, 1) | eval cons=mvindex(t, 2) | eval lag=mvindex(t, 3)
| stats sum(prod) as Produced, sum(cons) as Consumed, sum(lag) as Lag by Topic
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Dec 2015 15:10:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-up-all-the-values-using-a-delimiter-when-corresponding-keys/m-p/277455#M83672</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2015-12-11T15:10:08Z</dc:date>
    </item>
  </channel>
</rss>

