<?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: Find percentage of two numbers in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Find-percentage-of-two-numbers/m-p/515215#M144647</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/96704"&gt;@FraserC1&lt;/a&gt;&amp;nbsp;, my bad I misunderstood your requirement on the %, here is what I think should help&lt;/P&gt;&lt;P&gt;index="automox" sourcetype="automox:devices" server_group="*"&lt;BR /&gt;| dedup name&lt;BR /&gt;|top pending, server_group&lt;BR /&gt;| fields - percent&lt;BR /&gt;| eventstats sum(count) as total by server_group&lt;BR /&gt;| eval percent=round(count*100/total,2)&lt;BR /&gt;| fields - total&lt;BR /&gt;| sort server_group&lt;/P&gt;&lt;P&gt;and then you can use |where&amp;nbsp;pending=false&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 20 Aug 2020 13:39:07 GMT</pubDate>
    <dc:creator>Nisha18789</dc:creator>
    <dc:date>2020-08-20T13:39:07Z</dc:date>
    <item>
      <title>Find percentage of two numbers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-percentage-of-two-numbers/m-p/515155#M144621</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to search through some patch data to find percentage of devices that have been patched against the total amount of machines.&lt;BR /&gt;The search I have is below:&lt;/P&gt;&lt;P&gt;index="automox" sourcetype="automox:devices"&lt;BR /&gt;| dedup name&lt;BR /&gt;| eval patch_pend=if(pending_patches&amp;gt;0, 1, 0)&lt;BR /&gt;| eval patched=if(pending_patches=0, 1, 0)&lt;BR /&gt;| stats sum(patch_pend) , count(name) AS total, sum(patched)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I first have to run an eval to find the amount of machines with pending patches more than 0, this gives me the filed patch_pend and then eval to get patched machines.&lt;/P&gt;&lt;P&gt;Then I used stats to get the total amount within patch_pend and also count names which is total amount of machines and finally get the total patched machines.&lt;/P&gt;&lt;P&gt;Then my thought was to do another eval similar to below:&lt;/P&gt;&lt;P&gt;| eval perc=round(patch_pend*100/total,2)&lt;/P&gt;&lt;P&gt;But what this gives me is just one full pie chart with the total at 100%.&lt;/P&gt;&lt;P&gt;So I have these three numbers:&lt;/P&gt;&lt;P&gt;Total amount of machines&lt;BR /&gt;machines with patches pending&lt;BR /&gt;Machines with no patches pending&lt;/P&gt;&lt;P&gt;What I want to show is the percentage of machines that have 0 patches.&lt;BR /&gt;Can anyone point me in the right direction to do this?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Aug 2020 09:40:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-percentage-of-two-numbers/m-p/515155#M144621</guid>
      <dc:creator>FraserC1</dc:creator>
      <dc:date>2020-08-20T09:40:09Z</dc:date>
    </item>
    <item>
      <title>Re: Find percentage of two numbers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-percentage-of-two-numbers/m-p/515161#M144625</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/96704"&gt;@FraserC1&lt;/a&gt;&amp;nbsp;, this should work&lt;/P&gt;&lt;P&gt;| index="automox" sourcetype="automox:devices"&lt;BR /&gt;| dedup name&lt;BR /&gt;| eval patch_pend=if(pending_patches&amp;gt;0, 1, 0)&lt;BR /&gt;| eval patched=if(pending_patches=0, 1, 0)&lt;BR /&gt;| stats sum(patch_pend) as patch_pend , count(name) AS total, sum(patched) as patched&lt;BR /&gt;| eval %patch_pend=round((patch_pend*100/total),2)&lt;BR /&gt;| eval %patched=round((patched*100/total),2)&lt;BR /&gt;| fields %*&lt;BR /&gt;| transpose&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope it helps!&lt;/P&gt;&lt;P&gt;Please upvote my response if it resolves this issue.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Aug 2020 10:20:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-percentage-of-two-numbers/m-p/515161#M144625</guid>
      <dc:creator>Nisha18789</dc:creator>
      <dc:date>2020-08-20T10:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: Find percentage of two numbers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-percentage-of-two-numbers/m-p/515167#M144627</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/215670"&gt;@Nisha18789&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This has done exactly what I want, thank you!&lt;/P&gt;&lt;P&gt;I wonder if you could help me with one other query?&lt;/P&gt;&lt;P&gt;It is in the same index and sourcetype, I've now been asked if I can show the same information for each server group.&lt;/P&gt;&lt;P&gt;The search I have is:&lt;/P&gt;&lt;P&gt;index="automox" sourcetype="automox:devices" server_group="*"&lt;BR /&gt;| dedup name&lt;BR /&gt;| stats count by pending, server_group&lt;BR /&gt;| eventstats sum(count) as perc&lt;BR /&gt;| eval perc=round(count*100/perc,2)&lt;BR /&gt;| search pending=false&lt;BR /&gt;| table pending, count, perc, server_group&lt;/P&gt;&lt;P&gt;However this just gives a percentage based on the amount of machines within each server group, which is not what I was looking for.&lt;/P&gt;&lt;P&gt;What I want is like below:&lt;/P&gt;&lt;TABLE width="208px"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="70px"&gt;pending&lt;/TD&gt;&lt;TD width="53px"&gt;count&lt;/TD&gt;&lt;TD width="53px"&gt;perc&lt;/TD&gt;&lt;TD width="108px"&gt;server_group&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="70px"&gt;FALSE&lt;/TD&gt;&lt;TD width="53px"&gt;9&lt;/TD&gt;&lt;TD width="53px"&gt;8.11&lt;/TD&gt;&lt;TD width="108px"&gt;Linux Servers&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="70px"&gt;FALSE&lt;/TD&gt;&lt;TD width="53px"&gt;1&lt;/TD&gt;&lt;TD width="53px"&gt;0.9&lt;/TD&gt;&lt;TD width="108px"&gt;Linux Workstations&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="70px"&gt;FALSE&lt;/TD&gt;&lt;TD width="53px"&gt;4&lt;/TD&gt;&lt;TD width="53px"&gt;3.6&lt;/TD&gt;&lt;TD width="108px"&gt;MacOS Workstations&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="70px"&gt;FALSE&lt;/TD&gt;&lt;TD width="53px"&gt;30&lt;/TD&gt;&lt;TD width="53px"&gt;27.03&lt;/TD&gt;&lt;TD width="108px"&gt;Windows Server Full&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="70px"&gt;FALSE&lt;/TD&gt;&lt;TD width="53px"&gt;4&lt;/TD&gt;&lt;TD width="53px"&gt;3.6&lt;/TD&gt;&lt;TD width="108px"&gt;Windows Workstations&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the percentage is based on the total amount of machines, rather than how many exist within the server group.&lt;/P&gt;&lt;P&gt;As an example, if I run your search you provided with the extra bit, server_group="Windows Workstations", then the percentages it gives me are:&lt;/P&gt;&lt;TABLE border="0" width="128" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="64" height="20"&gt;column&lt;/TD&gt;&lt;TD width="64"&gt;row 1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;%patch_pend&lt;/TD&gt;&lt;TD&gt;90.48&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;%patched&lt;/TD&gt;&lt;TD&gt;9.52&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;And this is what I would expect.&lt;/P&gt;&lt;P&gt;The reason I am trying to do this, is so that on a dashboard I can show a trellis view of each server group and the percentage of unpatched(or patched) machines.&lt;/P&gt;&lt;P&gt;I hope that makes sense and sorry for the wall of text!&lt;/P&gt;</description>
      <pubDate>Thu, 20 Aug 2020 10:32:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-percentage-of-two-numbers/m-p/515167#M144627</guid>
      <dc:creator>FraserC1</dc:creator>
      <dc:date>2020-08-20T10:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: Find percentage of two numbers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-percentage-of-two-numbers/m-p/515175#M144631</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/96704"&gt;@FraserC1&lt;/a&gt;&amp;nbsp;,&amp;nbsp; I am a little confused on what data&amp;nbsp;pending field contains, but below query will give you an idea on how to do what you are looking for, let me know if you have any questions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;| index="automox" sourcetype="automox:devices" server_group="*"&lt;BR /&gt;| dedup name&lt;BR /&gt;| eval pending_servergrp="%"+pending+" : "+server_group&lt;BR /&gt;| stats count by pending_servergrp&lt;BR /&gt;| addcoltotals labelfield=pending_servergrp label=Total&lt;BR /&gt;| transpose 0 header_field=pending_servergrp&lt;BR /&gt;| fields - column&lt;BR /&gt;| foreach %*&lt;BR /&gt;[ eval %&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt; = ROUND('%&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;'*100/Total,2) ]&lt;BR /&gt;| fields - Total&lt;BR /&gt;| transpose&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please upvote my response if it resolves this issue.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Aug 2020 11:06:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-percentage-of-two-numbers/m-p/515175#M144631</guid>
      <dc:creator>Nisha18789</dc:creator>
      <dc:date>2020-08-20T11:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: Find percentage of two numbers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-percentage-of-two-numbers/m-p/515177#M144632</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/215670"&gt;@Nisha18789&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apologies I should have explained, the pending field is either "true" or "false", if true it means there are still patches to apply.&lt;/P&gt;&lt;P&gt;Thanks for the search query I will try it just now.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Aug 2020 11:08:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-percentage-of-two-numbers/m-p/515177#M144632</guid>
      <dc:creator>FraserC1</dc:creator>
      <dc:date>2020-08-20T11:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: Find percentage of two numbers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-percentage-of-two-numbers/m-p/515182#M144634</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/215670"&gt;@Nisha18789&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I tried the search but unfortunately it doesn't show me what I was looking for.&lt;BR /&gt;I am trying to use the first search you provided, but show those results for all of the server groups.&lt;/P&gt;&lt;P&gt;If I just use pending=true, that should only show me devices that have pending patches. And from there I would like to know the percentage of that number in relation to all the machines in the same server group.&lt;/P&gt;&lt;P&gt;Appreciate your help with this.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Aug 2020 11:21:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-percentage-of-two-numbers/m-p/515182#M144634</guid>
      <dc:creator>FraserC1</dc:creator>
      <dc:date>2020-08-20T11:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: Find percentage of two numbers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-percentage-of-two-numbers/m-p/515191#M144637</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/96704"&gt;@FraserC1&lt;/a&gt;&amp;nbsp;, it would be simple then if I understand it correctly you can use this for the tabular data&lt;/P&gt;&lt;P&gt;index="automox" sourcetype="automox:devices" server_group="*"&lt;BR /&gt;| dedup name&lt;BR /&gt;|top pending, server_group&lt;BR /&gt;| where pending="false"&lt;BR /&gt;| addcoltotals labelfield=pending label=patchedServers&lt;BR /&gt;| eval percent=if(pending="patchedServers",100-percent,percent)&lt;BR /&gt;| eval count=if(pending="patchedServers","",count)&lt;/P&gt;&lt;P&gt;But if you need bar chart, you need to get rid of other columns , so you can below two lines after above query&lt;/P&gt;&lt;P&gt;| eval pending_servergrp=pending+ ":"+server_group&lt;/P&gt;&lt;P&gt;| fields - count pending&amp;nbsp;server_group&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if that helps!&lt;/P&gt;</description>
      <pubDate>Thu, 20 Aug 2020 11:58:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-percentage-of-two-numbers/m-p/515191#M144637</guid>
      <dc:creator>Nisha18789</dc:creator>
      <dc:date>2020-08-20T11:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: Find percentage of two numbers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-percentage-of-two-numbers/m-p/515211#M144644</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/215670"&gt;@Nisha18789&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I think this is almost it, the only problem is the percentages.&lt;BR /&gt;It would need to be a percentage of the total amount of unpatched machines in each server group rather than the current "100-percent" calculation it is doing.&lt;BR /&gt;I think the calculation would be:&lt;/P&gt;&lt;P&gt;unpatched_machines/total_machines_in_group*100&lt;/P&gt;&lt;P&gt;Thanks again for your help!&lt;/P&gt;</description>
      <pubDate>Thu, 20 Aug 2020 13:17:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-percentage-of-two-numbers/m-p/515211#M144644</guid>
      <dc:creator>FraserC1</dc:creator>
      <dc:date>2020-08-20T13:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: Find percentage of two numbers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-percentage-of-two-numbers/m-p/515215#M144647</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/96704"&gt;@FraserC1&lt;/a&gt;&amp;nbsp;, my bad I misunderstood your requirement on the %, here is what I think should help&lt;/P&gt;&lt;P&gt;index="automox" sourcetype="automox:devices" server_group="*"&lt;BR /&gt;| dedup name&lt;BR /&gt;|top pending, server_group&lt;BR /&gt;| fields - percent&lt;BR /&gt;| eventstats sum(count) as total by server_group&lt;BR /&gt;| eval percent=round(count*100/total,2)&lt;BR /&gt;| fields - total&lt;BR /&gt;| sort server_group&lt;/P&gt;&lt;P&gt;and then you can use |where&amp;nbsp;pending=false&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Aug 2020 13:39:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-percentage-of-two-numbers/m-p/515215#M144647</guid>
      <dc:creator>Nisha18789</dc:creator>
      <dc:date>2020-08-20T13:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: Find percentage of two numbers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-percentage-of-two-numbers/m-p/515228#M144649</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/215670"&gt;@Nisha18789&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yup this is exactly what I was looking for.&lt;BR /&gt;Can't thank you enough for taking the time to help me with this!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Very much appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Aug 2020 14:22:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-percentage-of-two-numbers/m-p/515228#M144649</guid>
      <dc:creator>FraserC1</dc:creator>
      <dc:date>2020-08-20T14:22:59Z</dc:date>
    </item>
  </channel>
</rss>

