<?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: Using Multiple stats list in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Using-Multiple-stats-list/m-p/12434#M1020</link>
    <description>&lt;P&gt;I have worked this out with 2 points&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;By default, join will only join one result to each which is why my others get lost.  Adding "join max=0..." means that it will join all results where they match, not just the first match.&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;Ive then followed this all with a stats values(queues),values(topics) by instance as suggested by Lowell which takes only the unique values for each and creates my columns.&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;</description>
    <pubDate>Wed, 05 May 2010 16:10:12 GMT</pubDate>
    <dc:creator>Hazel</dc:creator>
    <dc:date>2010-05-05T16:10:12Z</dc:date>
    <item>
      <title>Using Multiple stats list</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-Multiple-stats-list/m-p/12429#M1015</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I am trying to build up a report using multiple stats, but I am having issues with duplication.&lt;/P&gt;

&lt;P&gt;I will do one search, eg &lt;/P&gt;

&lt;PRE&gt;
index="ems" sourcetype="queueconfig" | multikv noheader=true | rename Column_1 as queues | stats list(queues) by instance
&lt;/PRE&gt;

&lt;P&gt;It splits the events into single lines and then I use stats to group them by instance&lt;/P&gt;

&lt;P&gt;I have the following search that does the same for topics&lt;/P&gt;

&lt;PRE&gt;
index="ems" sourcetype="topicconfig" | multikv noheader=true | rename Column_1 as topics | stats list(topics) by instance
&lt;/PRE&gt;

&lt;P&gt;But now I want to join them into one search like this - &lt;/P&gt;

&lt;PRE&gt;
index="ems" sourcetype="queueconfig" | multikv noheader=true | rename Column_1 as queues | join instance [search index="ems" sourcetype="topicconfig" | multikv noheader=true | rename Column_1 as topics] | stats list(queues),list(topics) by instance
&lt;/PRE&gt;

&lt;P&gt;The issue that I am having is that at the time I join the topics in, the topics show up multiple times - it will join by instance, so for every queue line it fines it adds the topic line&lt;/P&gt;

&lt;P&gt;eg if queues are queue1, queue2 and topics are topic1, you will get&lt;/P&gt;

&lt;PRE&gt;
queue1  topic1
queue2 topic1
&lt;/PRE&gt;

&lt;P&gt;So, when I do the lists, I get multiple not unique values in list(topics).  If you add a uniq/dedup after, it doesnt have any effect. Is there a way to remove the duplicates? I am not approaching this the right way?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2010 15:06:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-Multiple-stats-list/m-p/12429#M1015</guid>
      <dc:creator>Hazel</dc:creator>
      <dc:date>2010-04-28T15:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: Using Multiple stats list</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-Multiple-stats-list/m-p/12430#M1016</link>
      <description>&lt;P&gt;Have you tried replacing:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
  &lt;P&gt;&lt;CODE&gt;| stats list(my_field) by my_group&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;with:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
  &lt;P&gt;&lt;CODE&gt;| stats values(my_field) by my_group&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;&lt;CODE&gt;values(field)&lt;/CODE&gt; will give you a multi-valued field with a single occurrence of each unique value.  Where as &lt;CODE&gt;list(field)&lt;/CODE&gt; will give you a multi-value field that contains all of the values of that field in the order they were given.&lt;/P&gt;

&lt;P&gt;See &lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0/SearchReference/CommonStatsFunctions" rel="nofollow"&gt;Common Stats Functions&lt;/A&gt; in the online docs.&lt;/P&gt;

&lt;P&gt;It may also beneficial to do multiple stats operations.  I couldn't test this, but here's a guess  at slightly different approach:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
  &lt;P&gt;&lt;CODE&gt;index="ems" sourcetype="queueconfig" | multikv noheader=true | stats values(Column_1) as queues by instance | join instance [search index="ems" sourcetype="topicconfig" | multikv noheader=true | stats values(Column_1) as topics by instance] | stats values(queues),values(topics) by instance&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;&lt;EM&gt;Side note:&lt;/EM&gt;  You may find this search could be a good candidate for leveraging macros, since a large portion  of it is duplicated.  Sometime that helps readability and reusablility.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2010 22:57:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-Multiple-stats-list/m-p/12430#M1016</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-04-28T22:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: Using Multiple stats list</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-Multiple-stats-list/m-p/12431#M1017</link>
      <description>&lt;P&gt;Hello. Thankyou for your reply, this is interest - it has helped to remove that problem but has unmasked another.  Where I have multiple values for the topic results, when it joins the searches together, it only links in the top value to each, rather than keeping all... any ideas?&lt;/P&gt;

&lt;P&gt;Eg. if topic results were sample, sample.topic, sample.topic2, only sample is passed in and kept in the joint search. If i run the topic search separately, I get multiple results for each instance!&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2010 23:40:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-Multiple-stats-list/m-p/12431#M1017</guid>
      <dc:creator>Hazel</dc:creator>
      <dc:date>2010-04-28T23:40:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using Multiple stats list</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-Multiple-stats-list/m-p/12432#M1018</link>
      <description>&lt;P&gt;To be honest, I've never really been able to make &lt;CODE&gt;join&lt;/CODE&gt; work for me.  I guess I keep doing something wrong, but I always find a different solution that actually works, like using &lt;CODE&gt;transaction&lt;/CODE&gt;, &lt;CODE&gt;stats&lt;/CODE&gt;, sometimes even &lt;CODE&gt;loadcsv append=t&lt;/CODE&gt;...  sometimes I use &lt;CODE&gt;set&lt;/CODE&gt; but that one can be a pain too.  Good luck&lt;/P&gt;</description>
      <pubDate>Thu, 29 Apr 2010 00:32:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-Multiple-stats-list/m-p/12432#M1018</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-04-29T00:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using Multiple stats list</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-Multiple-stats-list/m-p/12433#M1019</link>
      <description>&lt;P&gt;Maybe try using &lt;CODE&gt;append&lt;/CODE&gt;.  As long as have you do something like &lt;CODE&gt;search1 | append [ search2 ] | stats values()..., by instance&lt;/CODE&gt; could work.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Apr 2010 00:37:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-Multiple-stats-list/m-p/12433#M1019</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-04-29T00:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: Using Multiple stats list</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-Multiple-stats-list/m-p/12434#M1020</link>
      <description>&lt;P&gt;I have worked this out with 2 points&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;By default, join will only join one result to each which is why my others get lost.  Adding "join max=0..." means that it will join all results where they match, not just the first match.&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;Ive then followed this all with a stats values(queues),values(topics) by instance as suggested by Lowell which takes only the unique values for each and creates my columns.&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Wed, 05 May 2010 16:10:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-Multiple-stats-list/m-p/12434#M1020</guid>
      <dc:creator>Hazel</dc:creator>
      <dc:date>2010-05-05T16:10:12Z</dc:date>
    </item>
  </channel>
</rss>

