<?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 build an alert based on status code? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355003#M105033</link>
    <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="YouShouldAlwaysSpecifyAnIndex" sourcetype="AndSourcetypeToo" status_code&amp;gt;=200 AND status_code&amp;lt;=210 
| stats count BY status_code
| where count=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Schedule this to run &lt;CODE&gt;every 5 minutes&lt;/CODE&gt; over the &lt;CODE&gt;last 10 minutes&lt;/CODE&gt; and set to alert when &lt;CODE&gt;number of events&lt;/CODE&gt; and &lt;CODE&gt;is greater than 0&lt;/CODE&gt;.&lt;/P&gt;</description>
    <pubDate>Wed, 09 Aug 2017 13:48:54 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2017-08-09T13:48:54Z</dc:date>
    <item>
      <title>How to build an alert based on status code?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/354994#M105024</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;i have 10 stats codes from 200 to 210, i need to set up an alert. That alert will look at the last 10 mins, if a stats code was not generated in last 10 min, Splunk should send an alert. How could i build a search for this?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 17:57:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/354994#M105024</guid>
      <dc:creator>vemurisurya</dc:creator>
      <dc:date>2020-06-08T17:57:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to build an alert based on status code?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/354995#M105025</link>
      <description>&lt;P&gt;Figuring you are using the GUI to enter the search, use &lt;CODE&gt;-10m@m&lt;/CODE&gt; to &lt;CODE&gt;now&lt;/CODE&gt; in the time picker.&lt;/P&gt;

&lt;P&gt;Then use something like this for the search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... stats_code&amp;gt;199 stats_code&amp;lt;211
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then when you create the alert, set the alert condition to alert if the count of events = 0.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 16:33:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/354995#M105025</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2017-08-08T16:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to build an alert based on status code?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/354996#M105026</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="YouShouldAlwaysSpecifyAnIndex" sourcetype="AndSourcetypeToo" status_code&amp;gt;=200 AND status_code&amp;lt;=210 
| stats count
| where count=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Schedule this to run &lt;CODE&gt;every 5 minutes&lt;/CODE&gt; over the &lt;CODE&gt;last 10 minutes&lt;/CODE&gt; and set to alert &lt;CODE&gt;when number of events&lt;/CODE&gt; and &lt;CODE&gt;is greater than 0&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 17:39:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/354996#M105026</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-08-08T17:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to build an alert based on status code?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/354997#M105027</link>
      <description>&lt;P&gt;I think he wants the case where there are no events. He stated in the question:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;if a stats code was not generated in last 10 min&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 08 Aug 2017 17:46:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/354997#M105027</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2017-08-08T17:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to build an alert based on status code?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/354998#M105028</link>
      <description>&lt;P&gt;yeah correct if no status code were generated in 10 min there splunk need to triggered an alert &lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 17:58:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/354998#M105028</guid>
      <dc:creator>vemurisurya</dc:creator>
      <dc:date>2017-08-08T17:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to build an alert based on status code?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/354999#M105029</link>
      <description>&lt;P&gt;That's what it does (the logic is in the search; I ALWAYS put my logic in the search and use when &lt;CODE&gt;number of events&lt;/CODE&gt; and &lt;CODE&gt;is greater than 0&lt;/CODE&gt;).&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 19:08:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/354999#M105029</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-08-08T19:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to build an alert based on status code?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355000#M105030</link>
      <description>&lt;P&gt;Oops, yeah. I've got egg on &lt;STRONG&gt;my&lt;/STRONG&gt; face. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I didn't realize that was the result until you pointed that out to me. I think the explanation helps the understanding of your method. Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 19:28:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355000#M105030</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2017-08-08T19:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to build an alert based on status code?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355001#M105031</link>
      <description>&lt;P&gt;I need the alert report like, if any code not generate any code with in the last hour that should be send alert like &lt;BR /&gt;
  Status_code   count&lt;BR /&gt;
  200                     0&lt;BR /&gt;
  201                      1&lt;BR /&gt;
202                       5&lt;BR /&gt;
203                       0&lt;/P&gt;

&lt;P&gt;like this if any stats count was 0 then alert will  triggered &lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2017 12:35:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355001#M105031</guid>
      <dc:creator>vemurisurya</dc:creator>
      <dc:date>2017-08-09T12:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to build an alert based on status code?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355002#M105032</link>
      <description>&lt;P&gt;That is different and not the plain reading of what you asked.  See my new answer (soon).&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2017 13:47:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355002#M105032</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-08-09T13:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to build an alert based on status code?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355003#M105033</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="YouShouldAlwaysSpecifyAnIndex" sourcetype="AndSourcetypeToo" status_code&amp;gt;=200 AND status_code&amp;lt;=210 
| stats count BY status_code
| where count=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Schedule this to run &lt;CODE&gt;every 5 minutes&lt;/CODE&gt; over the &lt;CODE&gt;last 10 minutes&lt;/CODE&gt; and set to alert when &lt;CODE&gt;number of events&lt;/CODE&gt; and &lt;CODE&gt;is greater than 0&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2017 13:48:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355003#M105033</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-08-09T13:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to build an alert based on status code?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355004#M105034</link>
      <description>&lt;P&gt;this will shows only status code exist  in the events , if no stats code in the events , it doesn't shows any value, so here no visibility of the stats for the stats_code&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2017 14:54:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355004#M105034</guid>
      <dc:creator>vemurisurya</dc:creator>
      <dc:date>2017-08-09T14:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to build an alert based on status code?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355005#M105035</link>
      <description>&lt;P&gt;Huh?  Oh, he wanted an alert when NONE of those events had been generated.  Nope, still doesnt' work for me.  &lt;/P&gt;

&lt;P&gt;Ah, never mind, you posted the correct code on a new answer.&lt;/P&gt;

&lt;P&gt;Here's the code for checking if ANY of those eleven event numbers had failed to be produced. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="YouShouldAlwaysSpecifyAnIndex" sourcetype="AndSourcetypeToo" status_code&amp;gt;=200 AND status_code&amp;lt;=210 
 | fields status_code
 | append [|stats count | eval status_code =mvrange(200,211) | mvexpand status_code |table status_code]
 | stats count BY status_code
 | eval count=count-1
 | where count=0
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Aug 2017 16:54:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355005#M105035</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-08-09T16:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to build an alert based on status code?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355006#M105036</link>
      <description>&lt;P&gt;HA HA HA!  I am an idiot!  This is a "how many dogs didn't bark last night" problem!&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2017 22:51:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355006#M105036</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-08-09T22:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to build an alert based on status code?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355007#M105037</link>
      <description>&lt;P&gt;Like this (for real this time):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="YouShouldAlwaysSpecifyAnIndex" sourcetype="AndSourcetypeToo" status_code&amp;gt;=200 AND status_code&amp;lt;=210 
| appendpipe
    [| gentimes start=200 end=210 
    | streamstats count AS status_code
    | eval status_code = status_code + 199
    | fields status_code] 
| stats count BY status_code 
| eval count=count-1
| where count=0
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Aug 2017 23:00:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355007#M105037</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-08-09T23:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to build an alert based on status code?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355008#M105038</link>
      <description>&lt;P&gt;The trick is that you cannot count events that didn't happen so you have to pretend that everything happened once to instantiate a counter for each one and then back down by 1.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2017 23:01:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355008#M105038</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-08-09T23:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to build an alert based on status code?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355009#M105039</link>
      <description>&lt;P&gt;If possible, &lt;CODE&gt;Unaccept&lt;/CODE&gt; this answer and &lt;CODE&gt;Accept&lt;/CODE&gt; my other one, which has the full/correct answer (which this one alludes to).&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2017 13:46:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355009#M105039</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-08-10T13:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to build an alert based on status code?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355010#M105040</link>
      <description>&lt;P&gt;@woodcock can you explain this query please?&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 06:45:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355010#M105040</guid>
      <dc:creator>ksharma7</dc:creator>
      <dc:date>2020-06-03T06:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to build an alert based on status code?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355011#M105041</link>
      <description>&lt;P&gt;@woodcock can you please explain this query and what if I have to monitor only 200 status code not a range of codes..what modified query can work in that case?if you could help please&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 13:27:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355011#M105041</guid>
      <dc:creator>ksharma7</dc:creator>
      <dc:date>2020-06-03T13:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to build an alert based on status code?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355012#M105042</link>
      <description>&lt;P&gt;@vemurisurya can you explain the query you used to solve this problem and what if I have to monitor only one status code say 200 and want the same thing you stated&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 13:36:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-an-alert-based-on-status-code/m-p/355012#M105042</guid>
      <dc:creator>ksharma7</dc:creator>
      <dc:date>2020-06-03T13:36:29Z</dc:date>
    </item>
  </channel>
</rss>

