<?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 How to get multiple distinct counts for subset of logs in single query? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-multiple-distinct-counts-for-subset-of-logs-in-single/m-p/619974#M215489</link>
    <description>&lt;P&gt;Hello, I am currently using the |append method for some queries, but was curious if there is a better way for me to be writing these? We are trying to create a single alert that could be triggered by various conditions such as total number of failures or total number of unique customer failures. The following is a simplified example of what I am currently doing and would like to improve if anyone knows how:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"base query stuff"
| stats count as TOTAL count(eval(SEVERITY="INFO")) as SUCCESS count(eval(SEVERITY="SOAP-FAULT")) as FAULT count(eval(SEVERITY!="INFO" AND SEVERITY!="SOAP-FAULT")) as ERROR
| append [search "base query stuff" SEVERITY="SOAP-FAULT" | stats dc(userId) as UNIQUE_FAULT]
| where UNIQUE_FAULT &amp;gt; 10 OR FAULT &amp;gt; 20 OR ERROR &amp;gt; 30&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would also love to be able to create a table with all of&amp;nbsp; this data (hence the success variable), which contains the totals of each and unique customer impacts of each!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 07 Nov 2022 19:16:36 GMT</pubDate>
    <dc:creator>Damek</dc:creator>
    <dc:date>2022-11-07T19:16:36Z</dc:date>
    <item>
      <title>How to get multiple distinct counts for subset of logs in single query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-multiple-distinct-counts-for-subset-of-logs-in-single/m-p/619974#M215489</link>
      <description>&lt;P&gt;Hello, I am currently using the |append method for some queries, but was curious if there is a better way for me to be writing these? We are trying to create a single alert that could be triggered by various conditions such as total number of failures or total number of unique customer failures. The following is a simplified example of what I am currently doing and would like to improve if anyone knows how:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"base query stuff"
| stats count as TOTAL count(eval(SEVERITY="INFO")) as SUCCESS count(eval(SEVERITY="SOAP-FAULT")) as FAULT count(eval(SEVERITY!="INFO" AND SEVERITY!="SOAP-FAULT")) as ERROR
| append [search "base query stuff" SEVERITY="SOAP-FAULT" | stats dc(userId) as UNIQUE_FAULT]
| where UNIQUE_FAULT &amp;gt; 10 OR FAULT &amp;gt; 20 OR ERROR &amp;gt; 30&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would also love to be able to create a table with all of&amp;nbsp; this data (hence the success variable), which contains the totals of each and unique customer impacts of each!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2022 19:16:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-multiple-distinct-counts-for-subset-of-logs-in-single/m-p/619974#M215489</guid>
      <dc:creator>Damek</dc:creator>
      <dc:date>2022-11-07T19:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to get multiple distinct counts for subset of logs in single query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-multiple-distinct-counts-for-subset-of-logs-in-single/m-p/620041#M215522</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/251032"&gt;@Damek&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If your base search is common for both searches then you can try this.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"base query stuff" 
| eval SOAP_FAULT_userId = if(SEVERITY=="SOAP-FAULT",userId,null())
| stats count as TOTAL count(eval(SEVERITY="INFO")) as SUCCESS count(eval(SEVERITY="SOAP-FAULT")) as FAULT count(eval(SEVERITY!="INFO" AND SEVERITY!="SOAP-FAULT")) as ERROR dc(SOAP_FAULT_userId) as Splunk&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My Sample Search :&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="SEVERITY,userId
INFO,1
INFO,1
SOAP-FAULT,1
SOAP-FAULT,2
INFO1,1
INFO2,1
OTHER_INFO,1
INFO,1
SOAP-FAULT,1
"
| multikv forceheader=1 
| table SEVERITY userId
| rename comment as "upto this is sample data" 
| eval SOAP_FAULT_userId = if(SEVERITY=="SOAP-FAULT",userId,null())
| stats count as TOTAL count(eval(SEVERITY="INFO")) as SUCCESS count(eval(SEVERITY="SOAP-FAULT")) as FAULT count(eval(SEVERITY!="INFO" AND SEVERITY!="SOAP-FAULT")) as ERROR dc(SOAP_FAULT_userId) as Splunk&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this will help you.&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;KV&lt;BR /&gt;If any of my replies help you to solve the problem Or gain knowledge, an upvote would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 06:07:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-multiple-distinct-counts-for-subset-of-logs-in-single/m-p/620041#M215522</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2022-11-08T06:07:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to get multiple distinct counts for subset of logs in single query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-multiple-distinct-counts-for-subset-of-logs-in-single/m-p/620051#M215527</link>
      <description>&lt;P&gt;In your first stats you can do the dc with this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;dc(eval(if(SEVERITY="SOAP-FAULT", userId, null))) as UNIQUE_FAULT&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 06:46:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-multiple-distinct-counts-for-subset-of-logs-in-single/m-p/620051#M215527</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-11-08T06:46:09Z</dc:date>
    </item>
  </channel>
</rss>

