<?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: Need help to calculate percentage. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Need-help-to-calculate-percentage/m-p/682703#M233222</link>
    <description>&lt;P&gt;Remember that after each step in your processing pipeline you get only those restults from the immediately preceeding command. So if you do all those | where commands in a row, first one will filter out all those results for which the getperct wasnt more than 50, the second one will filter out (of those remaining after first where) those that do not fit the next condition and so on.&lt;/P&gt;&lt;P&gt;So your three wheres in a row are equivalent to&lt;/P&gt;&lt;PRE&gt;| where getperct&amp;gt;50 AND putperct&amp;gt;10 AND deleteperct&amp;gt;80&lt;/PRE&gt;&lt;P&gt;but you want at least one of those condiitons fulfilled so you want&lt;/P&gt;&lt;PRE&gt;| where (getperct&amp;gt;50) OR (putperct&amp;gt;10&amp;gt; OR (deleteperct&amp;gt;80)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 02 Apr 2024 07:47:41 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2024-04-02T07:47:41Z</dc:date>
    <item>
      <title>Need help to calculate percentage.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-to-calculate-percentage/m-p/682525#M233164</link>
      <description>&lt;LI-CODE lang="markup"&gt;|mstats sum(Transactions) as Transaction_count where index=metrics-logs application=login services IN(get, put, delete) span=1h by services
|streamstats by services
|timechart span=1h values(Transaction_count) by services&lt;/LI-CODE&gt;&lt;P&gt;Results:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;_time&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;get&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;put&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;delete&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;2024-01-22&amp;nbsp; 09:00&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;7654.000000&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;17854.000000&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;9876.000000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;2024-01-22&amp;nbsp; 10:00&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;5643.000000&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;2345.000000&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;1267.000000&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From the above query we want to calculate percentage&amp;nbsp; between 2 values.&lt;BR /&gt;For example : For get field , we want percentage between 2 hours(09:00 and 10:00)&lt;/P&gt;&lt;P&gt;7654.000000/5643.000000*100&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;how to do this??&lt;/P&gt;</description>
      <pubDate>Sun, 31 Mar 2024 17:20:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-to-calculate-percentage/m-p/682525#M233164</guid>
      <dc:creator>Ash1</dc:creator>
      <dc:date>2024-03-31T17:20:56Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to calculate percentage.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-to-calculate-percentage/m-p/682543#M233169</link>
      <description>&lt;P&gt;You need to "carry over" value from one results row to another using autoregress command or streamstats.&lt;/P&gt;&lt;P&gt;Autoregress is pretty straightforward. For example in this case&lt;/P&gt;&lt;PRE&gt;| autoregress get as old_get&lt;/PRE&gt;&lt;P&gt;Streamstats seems a bit more complicated but can be a pretty powerful tool. Alternative to autoregress here would be&lt;/P&gt;&lt;PRE&gt;| streamstats current=f window=1 values(get) as old_get&lt;/PRE&gt;&lt;P&gt;One caveat to both those commands - they are applied in order of the returned events which by default is the reverse chronological order which means you'd be copying values from a newer result to the older one. If that's not what you want, you'll need to resort your results.&lt;/P&gt;</description>
      <pubDate>Sun, 31 Mar 2024 21:59:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-to-calculate-percentage/m-p/682543#M233169</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-03-31T21:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to calculate percentage.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-to-calculate-percentage/m-p/682545#M233171</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;, i tried the query u suggested its working as expected. please find the below query.&lt;BR /&gt;but my concern is we want to use this query as an alert, where condition as&lt;BR /&gt;getperct &amp;gt;50&amp;nbsp; , putperct &amp;gt;10 , deleteperct &amp;gt;80 trigger alert&lt;BR /&gt;&lt;BR /&gt;but when i give this 3 conditions its not working as expected, here alert should trigger even if one condition meets.&lt;/P&gt;&lt;PRE&gt;|mstats sum(Transactions) as Transaction_count where index=metrics-logs application=login services IN(get, put, delete) span=1h by services
|timechart span=1h values(Transaction_count) by services
|autoregress get as old_get
|autoregress get as old_put
|autoregress get as old_delete
|eval getperct=round(old_get/get*100,2)
|eval putperct=round(old_put/put*100,2)
|eval deleteperct=round(old_delete/delete*100,2)
|table getperct putperct deleteperct&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2024 00:31:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-to-calculate-percentage/m-p/682545#M233171</guid>
      <dc:creator>Ash1</dc:creator>
      <dc:date>2024-04-01T00:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to calculate percentage.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-to-calculate-percentage/m-p/682597#M233187</link>
      <description>&lt;P&gt;Are you sure you wanted old value of &lt;STRONG&gt;get&lt;/STRONG&gt; as &lt;STRONG&gt;old_put&lt;/STRONG&gt;?&lt;/P&gt;&lt;P&gt;Also, you can just do your condition as | where command to find only those matching results. Then you'd trigger alert only if you had any results at all.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2024 09:33:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-to-calculate-percentage/m-p/682597#M233187</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-04-01T09:33:34Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to calculate percentage.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-to-calculate-percentage/m-p/682662#M233205</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;, sorry it was a typo erro&lt;/P&gt;
&lt;P&gt;Are you sure you wanted old value of get as old_put? ---&amp;nbsp;sorry it was a typo error&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, you can just do your condition as | where command to find only those matching results. Then you'd trigger alert only if you had any results at all.-- soory I used where condition but it's not working&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;|Where getperct&amp;gt;50

|Where putperct&amp;gt;10

|Where deleteperct&amp;gt;80&lt;/LI-CODE&gt;
&lt;P&gt;I want to receive error even if any one condition match, but I am not getting&lt;/P&gt;
&lt;P&gt;Can u pls help&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2024 22:12:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-to-calculate-percentage/m-p/682662#M233205</guid>
      <dc:creator>Ash1</dc:creator>
      <dc:date>2024-04-01T22:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to calculate percentage.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-to-calculate-percentage/m-p/682703#M233222</link>
      <description>&lt;P&gt;Remember that after each step in your processing pipeline you get only those restults from the immediately preceeding command. So if you do all those | where commands in a row, first one will filter out all those results for which the getperct wasnt more than 50, the second one will filter out (of those remaining after first where) those that do not fit the next condition and so on.&lt;/P&gt;&lt;P&gt;So your three wheres in a row are equivalent to&lt;/P&gt;&lt;PRE&gt;| where getperct&amp;gt;50 AND putperct&amp;gt;10 AND deleteperct&amp;gt;80&lt;/PRE&gt;&lt;P&gt;but you want at least one of those condiitons fulfilled so you want&lt;/P&gt;&lt;PRE&gt;| where (getperct&amp;gt;50) OR (putperct&amp;gt;10&amp;gt; OR (deleteperct&amp;gt;80)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2024 07:47:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-to-calculate-percentage/m-p/682703#M233222</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-04-02T07:47:41Z</dc:date>
    </item>
  </channel>
</rss>

