<?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: check if current usage breached last highest value by a given percentage over multiple sources in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/check-if-current-usage-breached-last-highest-value-by-a-given/m-p/115712#M30696</link>
    <description>&lt;P&gt;I've been trying to edit the original text of the question to make it clearer, but I  can't get past the captcha...&lt;/P&gt;</description>
    <pubDate>Wed, 15 Jan 2014 17:50:39 GMT</pubDate>
    <dc:creator>splunek</dc:creator>
    <dc:date>2014-01-15T17:50:39Z</dc:date>
    <item>
      <title>check if current usage breached last highest value by a given percentage over multiple sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/check-if-current-usage-breached-last-highest-value-by-a-given/m-p/115709#M30693</link>
      <description>&lt;P&gt;Hi.&lt;BR /&gt;
I'm a splunk newbie and I am trying to construct a query over multiple sources that will do a sum of points over a day in 1 hr buckets and tell me whether in the past hour I have breached the max bucket size by a factor of 10%.  I have tried to do this via a subsearch, which is very slow and I can't get it to quite work, or as one query, where I got the counts, but can't figure out how to get it to tell me whether it breached the max.&lt;/P&gt;

&lt;P&gt;Here is what I have so far: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;query returning pts for each event| bin _time span=1h as hour | stats sum(pts) as sum_pts by hour  sourcetype
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any help at all would be greatly appreciated!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2014 16:58:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/check-if-current-usage-breached-last-highest-value-by-a-given/m-p/115709#M30693</guid>
      <dc:creator>splunek</dc:creator>
      <dc:date>2014-01-15T16:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: check if current usage breached last highest value by a given percentage over multiple sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/check-if-current-usage-breached-last-highest-value-by-a-given/m-p/115710#M30694</link>
      <description>&lt;P&gt;This is a much faster way to get index volume by sourcetype: &lt;BR /&gt;
&lt;CODE&gt;index=_internal source=*metrics.log group=per_sourcetype_thruput series!=_* |  eval totalGB = (kb/1024)/1024 | bin _time span=1h as hour |convert ctime(hour) as Hour| stats sum(totalGB) as totalGB by Hour series |rename series AS Sourcetype&lt;/CODE&gt;&lt;BR /&gt;
I'm not sure how to compare one hour to the next, but I know it can be done.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2014 17:20:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/check-if-current-usage-breached-last-highest-value-by-a-given/m-p/115710#M30694</guid>
      <dc:creator>lukejadamec</dc:creator>
      <dc:date>2014-01-15T17:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: check if current usage breached last highest value by a given percentage over multiple sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/check-if-current-usage-breached-last-highest-value-by-a-given/m-p/115711#M30695</link>
      <description>&lt;P&gt;That's not exactly what I'm looking for, as I'm actually looking for a specific log line that returns # of points processed per query, and that is the sum I am looking at, although I guess I can used index volume as a proxy for that, but that wouldn't be very exact.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2014 17:27:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/check-if-current-usage-breached-last-highest-value-by-a-given/m-p/115711#M30695</guid>
      <dc:creator>splunek</dc:creator>
      <dc:date>2014-01-15T17:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: check if current usage breached last highest value by a given percentage over multiple sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/check-if-current-usage-breached-last-highest-value-by-a-given/m-p/115712#M30696</link>
      <description>&lt;P&gt;I've been trying to edit the original text of the question to make it clearer, but I  can't get past the captcha...&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2014 17:50:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/check-if-current-usage-breached-last-highest-value-by-a-given/m-p/115712#M30696</guid>
      <dc:creator>splunek</dc:creator>
      <dc:date>2014-01-15T17:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: check if current usage breached last highest value by a given percentage over multiple sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/check-if-current-usage-breached-last-highest-value-by-a-given/m-p/115713#M30697</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;query returning pts for each event earliest=-24h@h latest=@h
| bin _time span=1h as hour 
| eval thisHour = if (hour &amp;lt;= relative_time(now(),"-1h@h"),0,1)
| stats sum(pts) as sum_pts by hour sourcetype thisHour
| stats max(sum_pts) as maxPts by sourcetype thisHour
| eval pts = if(thisHour==1,maxPts,0)
| eval maxPts = if(thisHour==0,maxPts,0)
| stats sum(maxPts) as maxPts sum(pts) as PtsThisHour by sourcetype
| where PtsThisHour &amp;gt;= (maxPts * 1.1) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This could probably be shortened, but it will be fast. Here is a line-by-line explanation&lt;/P&gt;

&lt;P&gt;1- search - I added the &lt;CODE&gt;earliest&lt;/CODE&gt; and &lt;CODE&gt;latest&lt;/CODE&gt;because the search should to start and end on hour boundaries to be accurate.&lt;BR /&gt;&lt;BR /&gt;
2 - eval - sets a field that will be &lt;CODE&gt;1&lt;/CODE&gt; if the data is from the last hour, and &lt;CODE&gt;0&lt;/CODE&gt; otherwise. This lets us avoid a subsearch or join&lt;BR /&gt;&lt;BR /&gt;
3 - stats - Add up the points for each sourcetype by hour AND whether or not the thisHour is set. We should still have 24 results for each sourcetype.&lt;BR /&gt;&lt;BR /&gt;
4 - stats - Figure out the max points for each sourcetype. Including thisHour means we will get two results for each sourcetype - one result which reflects just the sum for the past hour, and the other result which contains the maximum of the other 23 hours.&lt;BR /&gt;&lt;BR /&gt;
4 &amp;amp; 5 - eval - These two statements effectively move the "maxPts" for the the past hour into its own field named "pts"&lt;BR /&gt;&lt;BR /&gt;
6 - stats - collapses the two results for each sourcetype into a single result&lt;BR /&gt;&lt;BR /&gt;
7 - where - excludes the results for sourcetypes that don't meet the criteria&lt;/P&gt;

&lt;P&gt;HTH!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2014 21:47:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/check-if-current-usage-breached-last-highest-value-by-a-given/m-p/115713#M30697</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2014-01-15T21:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: check if current usage breached last highest value by a given percentage over multiple sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/check-if-current-usage-breached-last-highest-value-by-a-given/m-p/115714#M30698</link>
      <description>&lt;P&gt;Thanks, but I'm still having some trouble.  I needed to put the "-1h@h" in quotes or it wouldn't evaluate, and also, it seems to break at step 4, at which point I get no results.  I can't seem to fix it.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2014 22:06:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/check-if-current-usage-breached-last-highest-value-by-a-given/m-p/115714#M30698</guid>
      <dc:creator>splunek</dc:creator>
      <dc:date>2014-01-15T22:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: check if current usage breached last highest value by a given percentage over multiple sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/check-if-current-usage-breached-last-highest-value-by-a-given/m-p/115715#M30699</link>
      <description>&lt;P&gt;Ok, there were just a couple of typos.  One of the sourcetypes was spelled sourceType, and the maxPts and PtsThisHour were reversed, but other than that, works like a charm!  Thank you so much!&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2014 14:43:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/check-if-current-usage-breached-last-highest-value-by-a-given/m-p/115715#M30699</guid>
      <dc:creator>splunek</dc:creator>
      <dc:date>2014-01-16T14:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: check if current usage breached last highest value by a given percentage over multiple sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/check-if-current-usage-breached-last-highest-value-by-a-given/m-p/115716#M30700</link>
      <description>&lt;P&gt;Here was the final version that worked for me, for reference:&lt;/P&gt;

&lt;P&gt;query returning pts for each event earliest=-24h@h latest=@h&lt;BR /&gt;
| bin _time span=1h as hour &lt;BR /&gt;
| eval thisHour = if (hour &amp;lt;= relative_time(now(),"-1h@h"),1,0)&lt;BR /&gt;
| stats sum(pts) as sum_pts by hour sourcetype thisHour&lt;BR /&gt;
| stats max(sum_pts) as maxPts by sourcetype thisHour&lt;BR /&gt;
| eval pts = if(thisHour==0,maxPts,0)&lt;BR /&gt;
| eval maxPts = if(thisHour==1,maxPts,0)&lt;BR /&gt;
| stats sum(maxPts) as maxPts sum(pts) as PtsThisHour by sourcetype&lt;BR /&gt;
| where PtsThisHour &amp;gt;= (maxPts * 1.1)&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:40:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/check-if-current-usage-breached-last-highest-value-by-a-given/m-p/115716#M30700</guid>
      <dc:creator>splunek</dc:creator>
      <dc:date>2020-09-28T15:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: check if current usage breached last highest value by a given percentage over multiple sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/check-if-current-usage-breached-last-highest-value-by-a-given/m-p/115717#M30701</link>
      <description>&lt;P&gt;Sorry about the typos - I updated my answer for future reference.&lt;/P&gt;

&lt;P&gt;Thanks for sticking with it!&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2014 19:15:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/check-if-current-usage-breached-last-highest-value-by-a-given/m-p/115717#M30701</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2014-01-16T19:15:05Z</dc:date>
    </item>
  </channel>
</rss>

