<?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: Query assistance needed with unrelated data set in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Query-assistance-needed-with-unrelated-data-set/m-p/25973#M4956</link>
    <description>&lt;P&gt;Thank you. I've made heavy edits of the original to outline the data, and details much more clearly.&lt;/P&gt;</description>
    <pubDate>Thu, 12 Apr 2012 20:20:03 GMT</pubDate>
    <dc:creator>jgauthier</dc:creator>
    <dc:date>2012-04-12T20:20:03Z</dc:date>
    <item>
      <title>Query assistance needed with unrelated data set</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-assistance-needed-with-unrelated-data-set/m-p/25971#M4954</link>
      <description>&lt;P&gt;Ugh!  I hate having to ask for query help, but I'm close.. but not close enough.  Basically, I have two sets of data.  I want to compare information in a field from set 'A', to the cumulative set of records in set 'B'.  So, my set 'A' data will look something like this:&lt;/P&gt;

&lt;P&gt;[EDITED to include real data]&lt;/P&gt;

&lt;P&gt;In my environment, I run a visualization cluster.  One area I want to get visibility into is overallocation of CPUs.  Using splunk, I am recording a lot of machine information from the Hypervisors.  &lt;/P&gt;

&lt;P&gt;For instance a data set for a hypervisor looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Timestamp=1334260801
Host=S-HYPERV2
Source=ComputerSystem
Name=S-HYPERV2
NumbOfProcs=16
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In this data set, I am interested in NumbOfProcs.&lt;BR /&gt;
In the second data set, I am going to count how my virtual processors are allocated, and compare that to the total above.  That data set looks like this:&lt;BR /&gt;
(record 1)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Timestamp=1334260801
Host=S-HYPERV2
Source=HypervGuestCPU
HCPU="v-sqldb:Hv VP 0"
PercGuestTime=17
PercHostTime=1
PercTotalTime=18
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(record 2)&lt;BR /&gt;
    Timestamp=1334260801&lt;BR /&gt;
    Host=S-HYPERV2&lt;BR /&gt;
    Source=HypervGuestCPU&lt;BR /&gt;
    HCPU="v-sqldb:Hv VP 1"&lt;BR /&gt;
    PercGuestTime=2&lt;BR /&gt;
    PercHostTime=0&lt;BR /&gt;
    PercTotalTime=2&lt;/P&gt;

&lt;P&gt;For each record, it's a unique vcpu.  So, I have done this to get pretty close:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Host="*HYPERV*" AND sourcetype="HypervGuestCPU" AND NOT HCPU="_Total" |dedup HCPU | chart count(HCPU) by host | appendcols [search Host="*HYPERV*" AND sourcetype="ComputerSystem"  | dedup Host | eval NumbofCPUs=(NumbOfProcs) | chart sum(NumbofCPUs) by Host ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Issues I have are, that I don't like the output.  I also am just dumping out out,I would prefer to be able to compare the numbers (total and the count).&lt;BR /&gt;
Additionally, if there are no vcpus being used, then I have a weird looking table.&lt;/P&gt;

&lt;P&gt;Ultimately, I attempting to get the output of :&lt;BR /&gt;
Server            VCPUs                  Physical&lt;BR /&gt;
S-HYPERV2           2                      16&lt;/P&gt;

&lt;P&gt;And it would be fantastic if I could actually compare them for alerting.  I'm afraid this is a little over my query foo.  &lt;/P&gt;

&lt;P&gt;This doesn't have the Total number in it, but this another method I was using to build the data set:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Host="*HYPERV*" AND sourcetype="ComputerSystem" OR sourcetype="HypervGuestCPU" AND NOT HCPU="_Total" | dedup HCPU |eventstats count(HCPU) as VCPU by Host | dedup Host| table Host, VCPU 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But this is just Host by VCPU, in a table.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2012 19:08:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-assistance-needed-with-unrelated-data-set/m-p/25971#M4954</guid>
      <dc:creator>jgauthier</dc:creator>
      <dc:date>2012-04-12T19:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: Query assistance needed with unrelated data set</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-assistance-needed-with-unrelated-data-set/m-p/25972#M4955</link>
      <description>&lt;P&gt;Are you sure you got the 1's and 2's correct in your post? Also, I'm not quite sure what you want to accomplish. &lt;/P&gt;

&lt;P&gt;I think it would be easier to help you if you posted real events, but mask out/change ip-addresses etc&lt;/P&gt;

&lt;P&gt;/k&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2012 20:01:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-assistance-needed-with-unrelated-data-set/m-p/25972#M4955</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2012-04-12T20:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: Query assistance needed with unrelated data set</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-assistance-needed-with-unrelated-data-set/m-p/25973#M4956</link>
      <description>&lt;P&gt;Thank you. I've made heavy edits of the original to outline the data, and details much more clearly.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2012 20:20:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-assistance-needed-with-unrelated-data-set/m-p/25973#M4956</guid>
      <dc:creator>jgauthier</dc:creator>
      <dc:date>2012-04-12T20:20:03Z</dc:date>
    </item>
    <item>
      <title>Re: Query assistance needed with unrelated data set</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-assistance-needed-with-unrelated-data-set/m-p/25974#M4957</link>
      <description>&lt;P&gt;Hm, I don't have your data to play with, but would something like this be functioning? If both sourcetypes have the same &lt;CODE&gt;host&lt;/CODE&gt; value (as Splunk sees it) this ought to produce someting like what you're after.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=HypervGuestCPU OR sourcetype=ComputerSystem NOT HCPU="_Total" | dedup Name HCPU keepempty=t | stats c(HCPU) AS Virtual_CPUs first(NumbOfProcs) AS PhysicalCPUs by host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let us know if it works,&lt;/P&gt;

&lt;P&gt;/kristian&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2012 22:26:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-assistance-needed-with-unrelated-data-set/m-p/25974#M4957</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2012-04-12T22:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: Query assistance needed with unrelated data set</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-assistance-needed-with-unrelated-data-set/m-p/25975#M4958</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;(sourcetype=ComputerSystem Host="*HYPERV*") OR (sourcetype=HypervGuestCPU NOT HCPU="_Total")
| eval HCPU=coalesce(HCPU,"Not Applicable")
| dedup Host,sourcetype,HCPU
| stats sum(NumbOfProcs) as Physical
        distinct_count(if(HCPU=="Not Applicable",null(),HCPU)) as VCPU
  by Host
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Apr 2012 22:40:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-assistance-needed-with-unrelated-data-set/m-p/25975#M4958</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2012-04-12T22:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: Query assistance needed with unrelated data set</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-assistance-needed-with-unrelated-data-set/m-p/25976#M4959</link>
      <description>&lt;P&gt;Wouldn't the coalescing throw the dc(HCPU) off by one? /k&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2012 22:58:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-assistance-needed-with-unrelated-data-set/m-p/25976#M4959</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2012-04-12T22:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: Query assistance needed with unrelated data set</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-assistance-needed-with-unrelated-data-set/m-p/25977#M4960</link>
      <description>&lt;P&gt;right. fixed that.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2012 23:00:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-assistance-needed-with-unrelated-data-set/m-p/25977#M4960</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2012-04-12T23:00:49Z</dc:date>
    </item>
    <item>
      <title>Re: Query assistance needed with unrelated data set</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-assistance-needed-with-unrelated-data-set/m-p/25978#M4961</link>
      <description>&lt;P&gt;Thanks guys. Both were ridiculously close, considering that the data was not present for you.  I am going to have to look at these and figure out some stuff so I can apply this.  In short, I was able to get kristians to work quicker, with a small modification (removed Name from Dedup). I think the first(NumbOfProcs) was the key. Thanks both so much!&lt;/P&gt;</description>
      <pubDate>Fri, 13 Apr 2012 13:28:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-assistance-needed-with-unrelated-data-set/m-p/25978#M4961</guid>
      <dc:creator>jgauthier</dc:creator>
      <dc:date>2012-04-13T13:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: Query assistance needed with unrelated data set</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-assistance-needed-with-unrelated-data-set/m-p/25979#M4962</link>
      <description>&lt;P&gt;Here is the working query from both of your suggestions:&lt;/P&gt;

&lt;P&gt;sourcetype=HypervGuestCPU OR sourcetype=ComputerSystem NOT HCPU="_Total" | dedup HCPU keepempty=t | stats c(HCPU) AS Virtual_CPUs first(NumbOfProcs) AS PhysicalCPUs by host&lt;/P&gt;

&lt;P&gt;And&lt;/P&gt;

&lt;P&gt;(sourcetype=ComputerSystem Host="&lt;EM&gt;HYPERV&lt;/EM&gt;") OR (sourcetype=HypervGuestCPU NOT HCPU="_Total")&lt;BR /&gt;&lt;BR /&gt;
|  stats first(NumbOfProcs) as Physical distinct_count(HCPU) as VCPU by Host&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:40:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-assistance-needed-with-unrelated-data-set/m-p/25979#M4962</guid>
      <dc:creator>jgauthier</dc:creator>
      <dc:date>2020-09-28T11:40:35Z</dc:date>
    </item>
  </channel>
</rss>

