<?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: More Efficient Query Dedup to Stats Distinct Count in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/More-Efficient-Query-Dedup-to-Stats-Distinct-Count/m-p/172801#M49556</link>
    <description>&lt;P&gt;Hi Tom, thank you very much for taking the time to reply to my post and for the guidance.&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
    <pubDate>Thu, 13 Aug 2015 08:30:36 GMT</pubDate>
    <dc:creator>IRHM73</dc:creator>
    <dc:date>2015-08-13T08:30:36Z</dc:date>
    <item>
      <title>More Efficient Query Dedup to Stats Distinct Count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/More-Efficient-Query-Dedup-to-Stats-Distinct-Count/m-p/172799#M49554</link>
      <description>&lt;P&gt;Hi, I wonder whether someone could help me please.&lt;/P&gt;

&lt;P&gt;I'm using the search below to successfully produce a pie chart with desired results.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;tags.transactionName = "Send Email Alert"  auditType="TxSucceeded"  | eval shortForm='detail.formId'."  " | eval shortForm =  substr(shortForm, 1, 6) | sort 0  detail.messageId  | dedup detail.messageId  | chart count by shortForm  | eval pieSlice=shortForm  + " " + count  | fields pieSlice, count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Because this search takes a while to load I'm looking at making this more efficient by removing the dedup element of search, so I've changed this to:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;tags.transactionName = "Send Email Alert"  auditType="TxSucceeded"  | eval shortForm='detail.formId'."  " | eval shortForm =  substr(shortForm, 1, 6) | sort 0  detail.messageId  | **stats dc(detail.messageId)**  | chart count by shortForm  | eval pieSlice=shortForm  + " " + count  | fields pieSlice, count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The problem is, is that this no longer produces any results so I've clearly done something wrong.&lt;/P&gt;

&lt;P&gt;I just wondered whether someone may be able to look at this please and let me know where I've gone wrong.&lt;/P&gt;

&lt;P&gt;Many thanks and kindest regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2015 07:06:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/More-Efficient-Query-Dedup-to-Stats-Distinct-Count/m-p/172799#M49554</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-08-13T07:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: More Efficient Query Dedup to Stats Distinct Count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/More-Efficient-Query-Dedup-to-Stats-Distinct-Count/m-p/172800#M49555</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;if you run your search up to this point:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; tags.transactionName = "Send Email Alert"  auditType="TxSucceeded"  | eval shortForm='detail.formId'."  " | eval shortForm =  substr(shortForm, 1, 6) | sort 0  detail.messageId  | **stats dc(detail.messageId)** 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;you will see that after the statd dc there is only one field "dc(detail.messageId)" left. Thats why the rest of your search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| chart count by shortForm  | eval pieSlice=shortForm  + " " + count  | fields pieSlice, count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;produces no result. Because it uses fields like count and shortForm. But these fields are no longer existent.&lt;/P&gt;

&lt;P&gt;Greetings&lt;/P&gt;

&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2015 08:23:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/More-Efficient-Query-Dedup-to-Stats-Distinct-Count/m-p/172800#M49555</guid>
      <dc:creator>tom_frotscher</dc:creator>
      <dc:date>2015-08-13T08:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: More Efficient Query Dedup to Stats Distinct Count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/More-Efficient-Query-Dedup-to-Stats-Distinct-Count/m-p/172801#M49556</link>
      <description>&lt;P&gt;Hi Tom, thank you very much for taking the time to reply to my post and for the guidance.&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2015 08:30:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/More-Efficient-Query-Dedup-to-Stats-Distinct-Count/m-p/172801#M49556</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-08-13T08:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: More Efficient Query Dedup to Stats Distinct Count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/More-Efficient-Query-Dedup-to-Stats-Distinct-Count/m-p/172802#M49557</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;i would try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; tags.transactionName = "Send Email Alert"  auditType="TxSucceeded"  | eval shortForm='detail.formId'."  " | eval shortForm =  substr(shortForm, 1, 6) | sort 0  detail.messageId  | stats dc(detail.messageId) first(shortForm) as shortForm by "detail.messageId" | chart count by shortForm  | eval pieSlice=shortForm  + " " + count  | fields pieSlice, count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;to adjust your search. But verify your results.&lt;/P&gt;

&lt;P&gt;In general if you use something like this in your search: &lt;CODE&gt;...| sort 0  detail.messageId  | dedup detail.messageId  |...&lt;/CODE&gt;. Try to think about what the search execute here. You first sort a huge list of events, just to throw out the most events with the dedup in the next step. It would ofcourse be faster if you first throw out the most events and after that, sort the now smaller list of events.&lt;/P&gt;

&lt;P&gt;Greetings &lt;/P&gt;

&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2015 08:48:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/More-Efficient-Query-Dedup-to-Stats-Distinct-Count/m-p/172802#M49557</guid>
      <dc:creator>tom_frotscher</dc:creator>
      <dc:date>2015-08-13T08:48:35Z</dc:date>
    </item>
    <item>
      <title>Re: More Efficient Query Dedup to Stats Distinct Count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/More-Efficient-Query-Dedup-to-Stats-Distinct-Count/m-p/172803#M49558</link>
      <description>&lt;P&gt;Hi Tom, thank you for this, it works perfectly. Thank you also for the guidance on the 'sort' and 'dedup' steps and the steps that they should be introduced.&lt;/P&gt;

&lt;P&gt;Kind Regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2015 09:18:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/More-Efficient-Query-Dedup-to-Stats-Distinct-Count/m-p/172803#M49558</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-08-13T09:18:08Z</dc:date>
    </item>
  </channel>
</rss>

