<?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 to edit my search to get the last software inventory for each computer? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-get-the-last-software-inventory-for/m-p/242267#M72075</link>
    <description>&lt;P&gt;@rjthibod, thanks for your suggestion but it does not work as it only returns one event by host. &lt;/P&gt;

&lt;P&gt;Basically, a software inventory for a given computer is made of multiple "software" event (let's say ~200-500 different software per computer).&lt;BR /&gt;
For a given inventory, I guaranty that InventoryDate is the same for software "events" part of same inventory upload. _time is also equals to InventoryDate&lt;/P&gt;

&lt;P&gt;So for #2, I am looking for a search that:&lt;BR /&gt;
For each computer/host:&lt;BR /&gt;
1. Get latest inventory date &lt;BR /&gt;
2. Return all software events having _time (or Inventory date) equals to latest inventory date &lt;/P&gt;</description>
    <pubDate>Tue, 11 Oct 2016 13:52:42 GMT</pubDate>
    <dc:creator>sylbaea</dc:creator>
    <dc:date>2016-10-11T13:52:42Z</dc:date>
    <item>
      <title>How to edit my search to get the last software inventory for each computer?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-get-the-last-software-inventory-for/m-p/242265#M72073</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I am collecting into Splunk computer software inventory periodically sent by all my computers.&lt;/P&gt;

&lt;P&gt;Each inventoried software is generating a Splunk event similar to:&lt;BR /&gt;
host = COMPUTERNAME&lt;BR /&gt;
inventoryDate = (timestamp)&lt;BR /&gt;
SoftwarePublisher&lt;BR /&gt;
SoftwareName&lt;BR /&gt;
SoftwareVersion&lt;BR /&gt;
(...)&lt;/P&gt;

&lt;P&gt;Each computer sent its inventory every two days.&lt;/P&gt;

&lt;P&gt;From there, I want to build the following searches into Splunk&lt;BR /&gt;
1. Get latest inventory for a given computer at a specific point in time&lt;BR /&gt;
2. Get latest inventory from all computers at a specific point in time&lt;/P&gt;

&lt;P&gt;For #1, I successfully used the following search filtering time period as required:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(...) host=&amp;lt;COMPUTERNAME&amp;gt;| eventstats max(InventoryDate) as LastInventoryDate | where InventoryDate=LastInventoryDate 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It works as expected, but is it the most optimized way to proceed?&lt;/P&gt;

&lt;P&gt;For #2, I cannot find how to get the equivalent, basically removing the filter on host and getting all latest inventory.&lt;BR /&gt;
Any suggestion ?&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2016 13:23:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-get-the-last-software-inventory-for/m-p/242265#M72073</guid>
      <dc:creator>sylbaea</dc:creator>
      <dc:date>2016-10-11T13:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to get the last software inventory for each computer?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-get-the-last-software-inventory-for/m-p/242266#M72074</link>
      <description>&lt;P&gt;Assuming your timestamping is correctly parsed and your events are in correct time order, the following should work for your first request&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;... host=&amp;lt;COMPUTERNAME&amp;gt; | head 1&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;For #2, I am not sure if this is the most efficient but I think it works&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;... | stats latest(_time) as _time latest(_raw) as _raw by host  | extract | table _time host *&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2016 13:43:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-get-the-last-software-inventory-for/m-p/242266#M72074</guid>
      <dc:creator>rjthibod</dc:creator>
      <dc:date>2016-10-11T13:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to get the last software inventory for each computer?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-get-the-last-software-inventory-for/m-p/242267#M72075</link>
      <description>&lt;P&gt;@rjthibod, thanks for your suggestion but it does not work as it only returns one event by host. &lt;/P&gt;

&lt;P&gt;Basically, a software inventory for a given computer is made of multiple "software" event (let's say ~200-500 different software per computer).&lt;BR /&gt;
For a given inventory, I guaranty that InventoryDate is the same for software "events" part of same inventory upload. _time is also equals to InventoryDate&lt;/P&gt;

&lt;P&gt;So for #2, I am looking for a search that:&lt;BR /&gt;
For each computer/host:&lt;BR /&gt;
1. Get latest inventory date &lt;BR /&gt;
2. Return all software events having _time (or Inventory date) equals to latest inventory date &lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2016 13:52:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-get-the-last-software-inventory-for/m-p/242267#M72075</guid>
      <dc:creator>sylbaea</dc:creator>
      <dc:date>2016-10-11T13:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to get the last software inventory for each computer?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-get-the-last-software-inventory-for/m-p/242268#M72076</link>
      <description>&lt;P&gt;Have you tried this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(...) | eventstats max(InventoryDate) as LastInventoryDate by host | where InventoryDate=LastInventoryDate | table host InventoryDate SoftwarePublisher SoftwareName SoftwareVersion
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Oct 2016 14:17:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-get-the-last-software-inventory-for/m-p/242268#M72076</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-10-11T14:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to get the last software inventory for each computer?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-get-the-last-software-inventory-for/m-p/242269#M72077</link>
      <description>&lt;P&gt;Thanks a lot. I was not far, I was just missing the "by host" &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2016 14:34:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-get-the-last-software-inventory-for/m-p/242269#M72077</guid>
      <dc:creator>sylbaea</dc:creator>
      <dc:date>2016-10-11T14:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to get the last software inventory for each computer?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-get-the-last-software-inventory-for/m-p/242270#M72078</link>
      <description>&lt;P&gt;Sorry for the confusion on my part. Glad you got what you needed in the other answer.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2016 14:39:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-get-the-last-software-inventory-for/m-p/242270#M72078</guid>
      <dc:creator>rjthibod</dc:creator>
      <dc:date>2016-10-11T14:39:22Z</dc:date>
    </item>
  </channel>
</rss>

