<?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 Exclude statusCodes that are Not Three Digits in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Exclude-statusCodes-that-are-Not-Three-Digits/m-p/539221#M152523</link>
    <description>&lt;P&gt;I'm trying to pick up the status codes for a given api, 4XX and 5XX.&amp;nbsp; I've typically done this with something like this: (changed the index, source and sourceUrl to be generic)&lt;/P&gt;&lt;P&gt;index="ralph" source="/var/log/containers/api.log" sourceUrl="/url/api/api_name" (statusCode=4* OR statusCode=\5*)&lt;BR /&gt;| timechart span=15m@m usenull=false count(statusCode) by statusCode&lt;/P&gt;&lt;P&gt;This has worked in the past, but I'm running into a situation for some api's where my search is returning values such as: 4, 40, 41 44, 401, 403, 404, 5, 50, 51, 500, 503, 504, etc.&lt;/P&gt;&lt;P&gt;My goal is to exclude anything that is NOT three digits (i.e. 4, 40, 41 44, 5, 50, 51) I've tried doing something like: statusCode=40* this excluded everything except 40. I tried statusCode=40\d&amp;nbsp; Thought i'd try, =40? but nothing is working.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a wildcard combo that would allow me to search where it must contain the 40 and one additional number? So I'd get just 400, 401, 4XX&lt;/P&gt;&lt;P&gt;I'm not very experienced with regex, but it seems like that might be the path?&lt;/P&gt;&lt;P&gt;Appreciate your help!&lt;BR /&gt;Thanks, rick&lt;/P&gt;</description>
    <pubDate>Tue, 09 Feb 2021 21:03:15 GMT</pubDate>
    <dc:creator>rick4039</dc:creator>
    <dc:date>2021-02-09T21:03:15Z</dc:date>
    <item>
      <title>Exclude statusCodes that are Not Three Digits</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Exclude-statusCodes-that-are-Not-Three-Digits/m-p/539221#M152523</link>
      <description>&lt;P&gt;I'm trying to pick up the status codes for a given api, 4XX and 5XX.&amp;nbsp; I've typically done this with something like this: (changed the index, source and sourceUrl to be generic)&lt;/P&gt;&lt;P&gt;index="ralph" source="/var/log/containers/api.log" sourceUrl="/url/api/api_name" (statusCode=4* OR statusCode=\5*)&lt;BR /&gt;| timechart span=15m@m usenull=false count(statusCode) by statusCode&lt;/P&gt;&lt;P&gt;This has worked in the past, but I'm running into a situation for some api's where my search is returning values such as: 4, 40, 41 44, 401, 403, 404, 5, 50, 51, 500, 503, 504, etc.&lt;/P&gt;&lt;P&gt;My goal is to exclude anything that is NOT three digits (i.e. 4, 40, 41 44, 5, 50, 51) I've tried doing something like: statusCode=40* this excluded everything except 40. I tried statusCode=40\d&amp;nbsp; Thought i'd try, =40? but nothing is working.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a wildcard combo that would allow me to search where it must contain the 40 and one additional number? So I'd get just 400, 401, 4XX&lt;/P&gt;&lt;P&gt;I'm not very experienced with regex, but it seems like that might be the path?&lt;/P&gt;&lt;P&gt;Appreciate your help!&lt;BR /&gt;Thanks, rick&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 21:03:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Exclude-statusCodes-that-are-Not-Three-Digits/m-p/539221#M152523</guid>
      <dc:creator>rick4039</dc:creator>
      <dc:date>2021-02-09T21:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude statusCodes that are Not Three Digits</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Exclude-statusCodes-that-are-Not-Three-Digits/m-p/539223#M152524</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/217349"&gt;@rick4039&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A number of ways to do this, here are two ways&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where match(statusCode, "^[45][01]\d$")

| regex statusCode="^[45][01]\d$"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;use this after the initial search. It allows for the middle digit to be a 0 or 1, but you can change that as needed. The 3rd digit can be any number.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 21:25:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Exclude-statusCodes-that-are-Not-Three-Digits/m-p/539223#M152524</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-02-09T21:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude statusCodes that are Not Three Digits</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Exclude-statusCodes-that-are-Not-Three-Digits/m-p/539363#M152546</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;Thanks!!&lt;/P&gt;&lt;P&gt;I've tried using both in my query but was having a bit of trouble.&amp;nbsp; I'm continuing to edit my query with your recommendations to get it to work.&amp;nbsp; Your recommendation on using the |where command turned me on to using it with greater than, less than.&amp;nbsp;&lt;/P&gt;&lt;P&gt;| where statusCode&amp;gt;=400 AND statusCode&amp;lt;499&lt;/P&gt;&lt;P&gt;This solved my immediate need and gave me a good example on using regex in my queries.&lt;/P&gt;&lt;P&gt;Thanks!!&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 21:31:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Exclude-statusCodes-that-are-Not-Three-Digits/m-p/539363#M152546</guid>
      <dc:creator>rick4039</dc:creator>
      <dc:date>2021-02-10T21:31:14Z</dc:date>
    </item>
  </channel>
</rss>

