<?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 calculate ratio between 2 fields? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-ratio-between-2-fields/m-p/584642#M10405</link>
    <description>&lt;P&gt;To rephrase, you want to count the &lt;EM&gt;number of events&lt;/EM&gt; where field &lt;FONT face="courier new,courier"&gt;Total&lt;/FONT&gt; &amp;gt; 200, and compare with &lt;U&gt;total&lt;/U&gt; number of events in which field &lt;FONT face="courier new,courier"&gt;Total&lt;/FONT&gt; exists. &amp;nbsp;This would be an easy one except our brains tricks us when the field name is Total. &amp;nbsp;I have been in this type of confusion a lot.&lt;/P&gt;&lt;P&gt;To eliminate this mental trap, instead of "rename AdditionalData.Total as Total", let's "rename AdditionalData.Total as someMetric".&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;sourcetype="*user-program*" Additional.Data=*
| rename AdditionalData.Total as someMetric
| eval highLatency=if(someMetric&amp;gt;200,1,0)
| stats count sum(highLatency) as highLatency
| eval Ratio = highLatency/count&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 11 Feb 2022 05:53:40 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2022-02-11T05:53:40Z</dc:date>
    <item>
      <title>How to calculate ratio between 2 fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-ratio-between-2-fields/m-p/584585#M10401</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I want to calculate a ratio between two fields (i know it suppose to be an easy one but looks like im missing something)&lt;BR /&gt;&lt;BR /&gt;i want to count all the Totals and then check where Total &amp;gt; 200&amp;nbsp; as latency and count them all&amp;nbsp;&lt;BR /&gt;after i have both of them i want to check if the ration between them is &amp;gt; 0.3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;sourcetype="*user-program*" 
| rename AdditionalData.Total as Total 
| eval Latency=if(Total&amp;gt;200,Total,null()) 
|eval Ratio = Total/Latency&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this one returning no results&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 22:52:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-ratio-between-2-fields/m-p/584585#M10401</guid>
      <dc:creator>sarit_s</dc:creator>
      <dc:date>2022-02-10T22:52:47Z</dc:date>
    </item>
    <item>
      <title>Re: calculate ratio between 2 fields</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-ratio-between-2-fields/m-p/584610#M10402</link>
      <description>&lt;P&gt;I'm not sure what you're trying to achieve. Maybe it's the wording.&lt;/P&gt;&lt;P&gt;Counting usually means that you want to count how many separate events (possibly fulfilling some condition) yoy have.&lt;/P&gt;&lt;P&gt;With your search you're calculating values in every event. It doesn't have anything to do with any counting.&lt;/P&gt;&lt;P&gt;For every event you're calculating a field called Ratio, which can have a value of 1 (if Total was bigger than 200 - in this case Latency is also set to equal to Total an the ratio is obviously 1) or null (if Total is less or equal to 200, Latency is set to null and you can't calculate ratio from null).&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 22:42:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-ratio-between-2-fields/m-p/584610#M10402</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-02-10T22:42:09Z</dc:date>
    </item>
    <item>
      <title>Re: calculate ratio between 2 fields</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-ratio-between-2-fields/m-p/584613#M10403</link>
      <description>&lt;P&gt;What are you counting? There doesn't appear to be appear stats command.&lt;/P&gt;&lt;P&gt;Also, if Total is greater than 200, Latency will be the same as Total so Latency/Total will be 1, otherwise Latency will be null so Total/Latency will be null. Given that you are getting no results, this would suggest Total is never greater than 200.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 22:46:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-ratio-between-2-fields/m-p/584613#M10403</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-02-10T22:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: calculate ratio between 2 fields</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-ratio-between-2-fields/m-p/584615#M10404</link>
      <description>&lt;P&gt;there are lots of total&amp;gt;200&lt;BR /&gt;what im trying to calculate is the count of total&lt;BR /&gt;the count of where total&amp;gt;200&lt;/P&gt;&lt;P&gt;and then calculate the ratio between them&lt;/P&gt;&lt;P&gt;after i have the result of the ratio i want to check if the ration is &amp;gt; 0.3 and raise an alert&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 22:53:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-ratio-between-2-fields/m-p/584615#M10404</guid>
      <dc:creator>sarit_s</dc:creator>
      <dc:date>2022-02-10T22:53:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate ratio between 2 fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-ratio-between-2-fields/m-p/584642#M10405</link>
      <description>&lt;P&gt;To rephrase, you want to count the &lt;EM&gt;number of events&lt;/EM&gt; where field &lt;FONT face="courier new,courier"&gt;Total&lt;/FONT&gt; &amp;gt; 200, and compare with &lt;U&gt;total&lt;/U&gt; number of events in which field &lt;FONT face="courier new,courier"&gt;Total&lt;/FONT&gt; exists. &amp;nbsp;This would be an easy one except our brains tricks us when the field name is Total. &amp;nbsp;I have been in this type of confusion a lot.&lt;/P&gt;&lt;P&gt;To eliminate this mental trap, instead of "rename AdditionalData.Total as Total", let's "rename AdditionalData.Total as someMetric".&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;sourcetype="*user-program*" Additional.Data=*
| rename AdditionalData.Total as someMetric
| eval highLatency=if(someMetric&amp;gt;200,1,0)
| stats count sum(highLatency) as highLatency
| eval Ratio = highLatency/count&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Feb 2022 05:53:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-ratio-between-2-fields/m-p/584642#M10405</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-02-11T05:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: calculate ratio between 2 fields</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-ratio-between-2-fields/m-p/584644#M10406</link>
      <description>&lt;P&gt;So you want to&lt;/P&gt;&lt;PRE&gt;| stats count(Total) as total count(eval(Total&amp;gt;200)) as matched&lt;BR /&gt;| eval ratio=matched/total&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Feb 2022 06:07:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-ratio-between-2-fields/m-p/584644#M10406</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-02-11T06:07:09Z</dc:date>
    </item>
  </channel>
</rss>

