<?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: Counting from metadata and inputcsv in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Counting-from-metadata-and-inputcsv/m-p/181372#M52285</link>
    <description>&lt;P&gt;Hi DereckKing,&lt;/P&gt;

&lt;P&gt;you could do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| metadata type=hosts index=* | stats count(host) as myCount | eval key="foo" | lookup assetinventory key as key OUTPUT value AS newCount | eval myPerc=myCount*100/newCount | table myCount myPerc
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I did setup a &lt;CODE&gt;lookup&lt;/CODE&gt; based on the following dummy &lt;CODE&gt;lookup&lt;/CODE&gt; file:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;key,value
foo,30
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;this is needed to do some dummy &lt;CODE&gt;lookup&lt;/CODE&gt; and will get back the total number of your &lt;CODE&gt;assetinventory&lt;/CODE&gt;. The &lt;CODE&gt;lookup&lt;/CODE&gt; file can be updated on a nightly base by running a saved search which will search all reporting hosts and updates the lookup with &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0.2/SearchReference/Outputlookup"&gt;outputlookup&lt;/A&gt; &lt;/P&gt;

&lt;P&gt;There is probably some other way to achieve this, but this will get you started.&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
    <pubDate>Tue, 11 Mar 2014 12:20:40 GMT</pubDate>
    <dc:creator>MuS</dc:creator>
    <dc:date>2014-03-11T12:20:40Z</dc:date>
    <item>
      <title>Counting from metadata and inputcsv</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-from-metadata-and-inputcsv/m-p/181371#M52284</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;I have a use case whereby I would like to report how many assets I am monitoring in splunk, as a percentage of the total.&lt;/P&gt;

&lt;P&gt;To get the number of reporting hosts I use the search;&lt;BR /&gt;
| metadata type=hosts index=* | stats count AS reporting_hosts&lt;/P&gt;

&lt;P&gt;To get the total number of assets I have, I use a lookup to my asset file&lt;BR /&gt;
| inputlookup assetinventory | stats count AS total_assets&lt;/P&gt;

&lt;P&gt;Both of these work fine in isolation, but what I cant figure out is how I can use both searches at the same time, and return a stacked chart (or even just a percentage single value would be fine).&lt;/P&gt;

&lt;P&gt;Regards&lt;BR /&gt;
Derek.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Mar 2014 11:44:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-from-metadata-and-inputcsv/m-p/181371#M52284</guid>
      <dc:creator>DerekKing</dc:creator>
      <dc:date>2014-03-11T11:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: Counting from metadata and inputcsv</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-from-metadata-and-inputcsv/m-p/181372#M52285</link>
      <description>&lt;P&gt;Hi DereckKing,&lt;/P&gt;

&lt;P&gt;you could do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| metadata type=hosts index=* | stats count(host) as myCount | eval key="foo" | lookup assetinventory key as key OUTPUT value AS newCount | eval myPerc=myCount*100/newCount | table myCount myPerc
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I did setup a &lt;CODE&gt;lookup&lt;/CODE&gt; based on the following dummy &lt;CODE&gt;lookup&lt;/CODE&gt; file:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;key,value
foo,30
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;this is needed to do some dummy &lt;CODE&gt;lookup&lt;/CODE&gt; and will get back the total number of your &lt;CODE&gt;assetinventory&lt;/CODE&gt;. The &lt;CODE&gt;lookup&lt;/CODE&gt; file can be updated on a nightly base by running a saved search which will search all reporting hosts and updates the lookup with &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0.2/SearchReference/Outputlookup"&gt;outputlookup&lt;/A&gt; &lt;/P&gt;

&lt;P&gt;There is probably some other way to achieve this, but this will get you started.&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Tue, 11 Mar 2014 12:20:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-from-metadata-and-inputcsv/m-p/181372#M52285</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-03-11T12:20:40Z</dc:date>
    </item>
    <item>
      <title>Re: Counting from metadata and inputcsv</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-from-metadata-and-inputcsv/m-p/181373#M52286</link>
      <description>&lt;P&gt;Hi Derek&lt;/P&gt;

&lt;P&gt;As both searches return a single value, you could use appendcols to associate the results from both queries, so something like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;
| metadata type=hosts index=* 
| stats count AS reporting_hosts 
| appendcols [| inputlookup assetinventory | stats count AS total_assets] 
| eval perc=reporting_hosts/total_assets*100
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Dave&lt;/P&gt;</description>
      <pubDate>Tue, 11 Mar 2014 14:02:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-from-metadata-and-inputcsv/m-p/181373#M52286</guid>
      <dc:creator>davebrooking</dc:creator>
      <dc:date>2014-03-11T14:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: Counting from metadata and inputcsv</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-from-metadata-and-inputcsv/m-p/181374#M52287</link>
      <description>&lt;P&gt;Thanks Mus - that did indeed get me started.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Mar 2014 14:26:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-from-metadata-and-inputcsv/m-p/181374#M52287</guid>
      <dc:creator>DerekKing</dc:creator>
      <dc:date>2014-03-11T14:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: Counting from metadata and inputcsv</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-from-metadata-and-inputcsv/m-p/181375#M52288</link>
      <description>&lt;P&gt;Thanks Dave, Exactly what I was looking for, &lt;/P&gt;

&lt;P&gt;Derek.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Mar 2014 14:26:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-from-metadata-and-inputcsv/m-p/181375#M52288</guid>
      <dc:creator>DerekKing</dc:creator>
      <dc:date>2014-03-11T14:26:39Z</dc:date>
    </item>
  </channel>
</rss>

