<?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 Calculate percentage of multiple values, different events in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-of-multiple-values-different-events/m-p/213456#M62619</link>
    <description>&lt;P&gt;I am trying to display the percentage of Total Modems against Total Modems on Card 0.&lt;/P&gt;

&lt;P&gt;The XML I am given unfortunately breaks up data from essentially one event into three:&lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://i.imgur.com/T84LY2R.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="C:\\splunk_files\\summary.xml" host="OSSTEST01" index="prtg_cmts" sourcetype="PRTG_API" | rex "(&amp;lt;sensor&amp;gt;)(?&amp;lt;sensor&amp;gt;.*)&amp;lt;" | rex "(&amp;lt;group&amp;gt;)(?&amp;lt;group&amp;gt;.*)&amp;lt;" | rex "(&amp;lt;lastvalue&amp;gt;)(?&amp;lt;value&amp;gt;\d+)\s" | search group="Bertha/Hewitt CMTS" | table _time, group, sensor, value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have tried running a sub search to get &lt;EM&gt;just&lt;/EM&gt; total modem count, and then compare that to the count of the two other rows, using &lt;STRONG&gt;eventstats&lt;/STRONG&gt;, but that was not successful. &lt;/P&gt;</description>
    <pubDate>Mon, 26 Sep 2016 16:25:09 GMT</pubDate>
    <dc:creator>evan_roggenkamp</dc:creator>
    <dc:date>2016-09-26T16:25:09Z</dc:date>
    <item>
      <title>Calculate percentage of multiple values, different events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-of-multiple-values-different-events/m-p/213456#M62619</link>
      <description>&lt;P&gt;I am trying to display the percentage of Total Modems against Total Modems on Card 0.&lt;/P&gt;

&lt;P&gt;The XML I am given unfortunately breaks up data from essentially one event into three:&lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://i.imgur.com/T84LY2R.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="C:\\splunk_files\\summary.xml" host="OSSTEST01" index="prtg_cmts" sourcetype="PRTG_API" | rex "(&amp;lt;sensor&amp;gt;)(?&amp;lt;sensor&amp;gt;.*)&amp;lt;" | rex "(&amp;lt;group&amp;gt;)(?&amp;lt;group&amp;gt;.*)&amp;lt;" | rex "(&amp;lt;lastvalue&amp;gt;)(?&amp;lt;value&amp;gt;\d+)\s" | search group="Bertha/Hewitt CMTS" | table _time, group, sensor, value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have tried running a sub search to get &lt;EM&gt;just&lt;/EM&gt; total modem count, and then compare that to the count of the two other rows, using &lt;STRONG&gt;eventstats&lt;/STRONG&gt;, but that was not successful. &lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2016 16:25:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-of-multiple-values-different-events/m-p/213456#M62619</guid>
      <dc:creator>evan_roggenkamp</dc:creator>
      <dc:date>2016-09-26T16:25:09Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage of multiple values, different events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-of-multiple-values-different-events/m-p/213457#M62620</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="C:\\splunk_files\\summary.xml" host="OSSTEST01" index="prtg_cmts" sourcetype="PRTG_API" | rex "(&amp;lt;group&amp;gt;)(?&amp;lt;group&amp;gt;.*)&amp;lt;" | search group="Bertha/Hewitt CMTS"  | rex "(&amp;lt;sensor&amp;gt;)(?&amp;lt;sensor&amp;gt;.*)&amp;lt;" | rex "(&amp;lt;lastvalue&amp;gt;)(?&amp;lt;value&amp;gt;\d+)\s"  | table _time, group, sensor, value | eventstats sum(value) as Total by _time group | eval Percentage=round(value*100/Total,2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Updated&lt;/STRONG&gt;&lt;BR /&gt;
If I'm not wrong, it easy to implement by just changing &lt;CODE&gt;eventstats sum(..&lt;/CODE&gt; to &lt;CODE&gt;eventstats max(..&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="C:\\splunk_files\\summary.xml" host="OSSTEST01" index="prtg_cmts" sourcetype="PRTG_API" | rex "(&amp;lt;group&amp;gt;)(?&amp;lt;group&amp;gt;.*)&amp;lt;" | search group="Bertha/Hewitt CMTS"  | rex "(&amp;lt;sensor&amp;gt;)(?&amp;lt;sensor&amp;gt;.*)&amp;lt;" | rex "(&amp;lt;lastvalue&amp;gt;)(?&amp;lt;value&amp;gt;\d+)\s"  | table _time, group, sensor, value | eventstats max(value) as Total by _time group | eval Percentage=round(value*100/Total,2)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Sep 2016 16:44:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-of-multiple-values-different-events/m-p/213457#M62620</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-09-26T16:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage of multiple values, different events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-of-multiple-values-different-events/m-p/213458#M62621</link>
      <description>&lt;P&gt;That is helpful. I maybe forgot to mention, the first row is actually the total and the values below it fractional representations of it (they add up to the total). &lt;/P&gt;

&lt;P&gt;So in this case:&lt;BR /&gt;
The first row has the total modems: 126&lt;BR /&gt;
Upstream 5 has 86  modems online so it has 68% of the modems online&lt;BR /&gt;
Upstream 6 has 40 modems online so it has 32% of the modems online&lt;/P&gt;

&lt;P&gt;So there are 100% of the modems online. That is what I would like to represent in a single value field.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2016 17:58:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-of-multiple-values-different-events/m-p/213458#M62621</guid>
      <dc:creator>evan_roggenkamp</dc:creator>
      <dc:date>2016-09-26T17:58:58Z</dc:date>
    </item>
  </channel>
</rss>

