<?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 do I extract one set from another? in Knowledge Management</title>
    <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-extract-one-set-from-another/m-p/501470#M8428</link>
    <description>&lt;P&gt;Really neat @DalJeanis &lt;/P&gt;</description>
    <pubDate>Fri, 31 Jan 2020 18:40:05 GMT</pubDate>
    <dc:creator>danielbb</dc:creator>
    <dc:date>2020-01-31T18:40:05Z</dc:date>
    <item>
      <title>How do I extract one set from another?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-extract-one-set-from-another/m-p/501464#M8422</link>
      <description>&lt;P&gt;I have something like -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=os_solaris sourcetype=cpu | stats count by host 
| join type=left host [|search index=os_solaris sourcetype=vmstat | stats count by host ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I actually like to substract the output of &lt;CODE&gt;index=os_solaris sourcetype=vmstat | stats count by host&lt;/CODE&gt; from the bigger set of &lt;CODE&gt;index=os_solaris sourcetype=cpu | stats count by host&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;How can I do that?&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2020 14:58:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-do-I-extract-one-set-from-another/m-p/501464#M8422</guid>
      <dc:creator>danielbb</dc:creator>
      <dc:date>2020-01-31T14:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract one set from another?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-extract-one-set-from-another/m-p/501465#M8423</link>
      <description>&lt;P&gt;Are you wanting a total count of hosts from vmstat minux the total count of hosts from cpu? Give this a try:&lt;/P&gt;

&lt;P&gt;**&lt;BR /&gt;
index=os_solaris sourcetype=cpu | where host!="" | stats count as Count1&lt;BR /&gt;
 | join type=left host [|search index=os_solaris sourcetype=vmstat | where host!="" | stats count as Count2]&lt;BR /&gt;
| eval Total=(Count2 - Count1)&lt;BR /&gt;
| fields Total&lt;BR /&gt;
**&lt;/P&gt;

&lt;P&gt;First I got the total count of events from &lt;CODE&gt;sourcetype=cpu&lt;/CODE&gt; and where &lt;CODE&gt;host&lt;/CODE&gt; field is not empty and named that count as &lt;CODE&gt;Count1&lt;/CODE&gt;.&lt;BR /&gt;
Second I got the total count of events from &lt;CODE&gt;sourcetype=vmstat&lt;/CODE&gt; and where &lt;CODE&gt;host&lt;/CODE&gt; field is not empty and named that count as &lt;CODE&gt;Count2&lt;/CODE&gt;.&lt;BR /&gt;
Next I create a new field called Total and take the total count of &lt;CODE&gt;Count2&lt;/CODE&gt; and subtract &lt;CODE&gt;Count1&lt;/CODE&gt; from that value.&lt;BR /&gt;
Finally I just print the Total field to get a single integer.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:58:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-do-I-extract-one-set-from-another/m-p/501465#M8423</guid>
      <dc:creator>13tsavage</dc:creator>
      <dc:date>2020-09-30T03:58:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract one set from another?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-extract-one-set-from-another/m-p/501466#M8424</link>
      <description>&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/483528/how-to-get-subsearch-to-return-a-result-which-is-n.html"&gt;How to get subsearch to return a result which is NOT EQUAL to the returned value?&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;This thread relates to it...&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2020 15:23:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-do-I-extract-one-set-from-another/m-p/501466#M8424</guid>
      <dc:creator>danielbb</dc:creator>
      <dc:date>2020-01-31T15:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract one set from another?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-extract-one-set-from-another/m-p/501467#M8425</link>
      <description>&lt;P&gt;Okay, not what I thought you were wanting. That is pretty neat, does that previous question help you at all?&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2020 15:43:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-do-I-extract-one-set-from-another/m-p/501467#M8425</guid>
      <dc:creator>13tsavage</dc:creator>
      <dc:date>2020-01-31T15:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract one set from another?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-extract-one-set-from-another/m-p/501468#M8426</link>
      <description>&lt;P&gt;What I need is the list of hosts subtracted from the other one - &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=os_solaris sourcetype=cpu | stats count by host&lt;/CODE&gt; returns 100 hosts and the other one returns 40, the subtraction should return the list of 60 hosts. &lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2020 16:47:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-do-I-extract-one-set-from-another/m-p/501468#M8426</guid>
      <dc:creator>danielbb</dc:creator>
      <dc:date>2020-01-31T16:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract one set from another?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-extract-one-set-from-another/m-p/501469#M8427</link>
      <description>&lt;P&gt;Try something like &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=os_solaris ( sourcetype=cpu OR sourcetype=vmstat )
| eval cpucount=case(sourcetype="cpu",1)
| eval vmcount=case(sourcetype="vmstat",1)
| stats sum(cpucount) as cpucount sum(vmcount) as vmcount by host
| eval diffcount=cpucount-vmcount
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It can be written more succinctly, as this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=os_solaris ( sourcetype=cpu OR sourcetype=vmstat )
| stats sum(eval(case(sourcetype="cpu",1)) as cpucount 
    sum(eval(case(sourcetype="vmstat",1))) as vmcount 
    sum(eval(case(sourcetype="cpu",1,sourcetype="vmstat",-1))) as diffcount 
    by host
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 31 Jan 2020 17:24:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-do-I-extract-one-set-from-another/m-p/501469#M8427</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2020-01-31T17:24:43Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract one set from another?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-extract-one-set-from-another/m-p/501470#M8428</link>
      <description>&lt;P&gt;Really neat @DalJeanis &lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2020 18:40:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-do-I-extract-one-set-from-another/m-p/501470#M8428</guid>
      <dc:creator>danielbb</dc:creator>
      <dc:date>2020-01-31T18:40:05Z</dc:date>
    </item>
  </channel>
</rss>

