<?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 Number of Field Installs ( Counting Latest event only) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Counting-Number-of-Field-Installs-Counting-Latest-event-only/m-p/270567#M81442</link>
    <description>&lt;P&gt;Worked Perfectly thank you! &lt;/P&gt;

&lt;P&gt;P.S. one small thing there is a "(" missing after mvindex on the 3rd line&lt;/P&gt;</description>
    <pubDate>Mon, 25 Jul 2016 20:29:23 GMT</pubDate>
    <dc:creator>raby1996</dc:creator>
    <dc:date>2016-07-25T20:29:23Z</dc:date>
    <item>
      <title>Counting Number of Field Installs ( Counting Latest event only)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-Number-of-Field-Installs-Counting-Latest-event-only/m-p/270563#M81438</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;

&lt;P&gt;I am attempting to count the number of Installs of certain code levels for field machines. Essentially I am extracting this information from some logs, and then I am listing all the code levels by machine serial, this gives me the code level history of a machine. Where I am struggling is being able to list current installs of the code levels, so this would include counts of 0 since not all code levels are currently being used, however I feel that my current approach isn't appropriate , I've included some samples below.&lt;/P&gt;

&lt;P&gt;First part of Search-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Search.......| stats values(code_level) as code_level list(time_on_machine) as time_on_machine by Machine_Serial
| stats dc(Machine_Serial) as installs sum(time_on_machine) by code_level
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Results- &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Machine_Serial                     code_level         time_on_machine

75abc                                  1.1                  365
                                       1.3                  20
                                       1.4                  50 

75dfe                                  1.1                  10
                                       1.3                  15
                                       1.5                  7


75xyz                                  1.3                  25
                                       1.4                  50
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;As mentioned above from this search I can see a historical view of the code history for machines as well as the time it spent on a machine. Essentially only the latest code level ( the one at the bottom of each group I.E the largest one ) would count as an install so for the first group ( serial 75abc ) code level 1.1 would be a current install, but 1.3 and 1.4 would not count towards installs on their respective level, however I do take their time_on_machine field and add that to the rest, so it would look something like this-&lt;/P&gt;

&lt;P&gt;Desired Results-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    code_level         current_installs              time_on_machine_sum  
    1.1                        0                            375
    1.3                        0                            60
    1.4                        2                            100
    1.5                        1                            7
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there any way I can achieve the current_installs portion of this search? Thank you in advance, and please let me know if something was not clear.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:18:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-Number-of-Field-Installs-Counting-Latest-event-only/m-p/270563#M81438</guid>
      <dc:creator>raby1996</dc:creator>
      <dc:date>2020-09-29T10:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: Counting Number of Field Installs ( Counting Latest event only)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-Number-of-Field-Installs-Counting-Latest-event-only/m-p/270564#M81439</link>
      <description>&lt;P&gt;How about this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Search.......| stats dc(Machine_Serial) as current_installs sum(time_on_machine) as  time_on_machine_sum by  code_level
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Jul 2016 17:21:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-Number-of-Field-Installs-Counting-Latest-event-only/m-p/270564#M81439</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-07-25T17:21:16Z</dc:date>
    </item>
    <item>
      <title>Re: Counting Number of Field Installs ( Counting Latest event only)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-Number-of-Field-Installs-Counting-Latest-event-only/m-p/270565#M81440</link>
      <description>&lt;P&gt;Hello sundareshr,&lt;BR /&gt;
I've tried that, but this will return a count that includes code levels that are no longer on that machine so where I should get a 0 for example, I'll end up getting a value of 1 or more. Still thank you&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 17:24:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-Number-of-Field-Installs-Counting-Latest-event-only/m-p/270565#M81440</guid>
      <dc:creator>raby1996</dc:creator>
      <dc:date>2016-07-25T17:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: Counting Number of Field Installs ( Counting Latest event only)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-Number-of-Field-Installs-Counting-Latest-event-only/m-p/270566#M81441</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; Search.......| stats values(code_level) as code_level list(time_on_machine) as time_on_machine by Machine_Serial
| eval latest_code_level=mvindex(code_level,-1)
| eval latest_time_on_machine=mvindex(time_on_machine,-1)
| eval temp=mvzip(code_level,time_on_machine,"#") | fields - code_level, time_on_machine | mvexpand temp | rex field=temp "(?&amp;lt;code_level&amp;gt;.+)#(?&amp;lt;time_on_machine&amp;gt;.+)" | fields - temp
| eval current_install=if(code_level=latest_code_level,1,0)
| stats sum(current_install) as current_install sum(time_on_machine) as time_on_machine by code_level
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Jul 2016 18:33:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-Number-of-Field-Installs-Counting-Latest-event-only/m-p/270566#M81441</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-07-25T18:33:13Z</dc:date>
    </item>
    <item>
      <title>Re: Counting Number of Field Installs ( Counting Latest event only)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-Number-of-Field-Installs-Counting-Latest-event-only/m-p/270567#M81442</link>
      <description>&lt;P&gt;Worked Perfectly thank you! &lt;/P&gt;

&lt;P&gt;P.S. one small thing there is a "(" missing after mvindex on the 3rd line&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 20:29:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-Number-of-Field-Installs-Counting-Latest-event-only/m-p/270567#M81442</guid>
      <dc:creator>raby1996</dc:creator>
      <dc:date>2016-07-25T20:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: Counting Number of Field Installs ( Counting Latest event only)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-Number-of-Field-Installs-Counting-Latest-event-only/m-p/270568#M81443</link>
      <description>&lt;P&gt;Thanks for noticing the type. Just corrected it.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 20:53:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-Number-of-Field-Installs-Counting-Latest-event-only/m-p/270568#M81443</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-07-25T20:53:11Z</dc:date>
    </item>
  </channel>
</rss>

