<?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 get http error codes count in Security</title>
    <link>https://community.splunk.com/t5/Security/How-to-get-http-error-codes-count/m-p/314228#M12545</link>
    <description>&lt;P&gt;if you want to shorten your search string and get anything which isn't 200 you can also just use&lt;BR /&gt;
status!=200&lt;/P&gt;</description>
    <pubDate>Tue, 30 May 2017 20:55:11 GMT</pubDate>
    <dc:creator>anthonymelita</dc:creator>
    <dc:date>2017-05-30T20:55:11Z</dc:date>
    <item>
      <title>How to get http error codes count</title>
      <link>https://community.splunk.com/t5/Security/How-to-get-http-error-codes-count/m-p/314226#M12543</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have the following log:&lt;/P&gt;

&lt;P&gt;01.01.01.56 - - [20/May/2016:09:22:44 +0000] "GET /parking/js/node.js HTTP/1.1" 302 -&lt;/P&gt;

&lt;P&gt;01.01.01.56 - - [20/May/2016:06:44:44 +0000] "GET /outside/js/node.js HTTP/1.1" 404 -&lt;/P&gt;

&lt;P&gt;How do i run a search to extract all the different HTTP error codes other then 200 and graph the results for example&lt;/P&gt;

&lt;P&gt;http 302 = 130&lt;BR /&gt;
http 404 = 90&lt;BR /&gt;
In the end i want it to be displayed as a bar gragh&lt;/P&gt;

&lt;P&gt;I used:&lt;BR /&gt;
sourcetype=tomcat 400 OR 401 OR 403 OR 404 OR 502 OR 503 &lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 10:00:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-get-http-error-codes-count/m-p/314226#M12543</guid>
      <dc:creator>cloud111</dc:creator>
      <dc:date>2017-05-30T10:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to get http error codes count</title>
      <link>https://community.splunk.com/t5/Security/How-to-get-http-error-codes-count/m-p/314227#M12544</link>
      <description>&lt;P&gt;Have you checked in verbose mode whether http &lt;STRONG&gt;status&lt;/STRONG&gt; field is getting extracted for your &lt;STRONG&gt;tomcat&lt;/STRONG&gt; sourcetype or not? If it is not then ideally you should created a Field Extraction for 304, 404 using Splunk's Interactive Field Extraction through Extract Fields option in the Search Menu. Refer to documentation &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/ExtractfieldsinteractivelywithIFX"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/ExtractfieldsinteractivelywithIFX&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Otherwise temporarily you can create Field extraction directly in your SPL using the rex command if you are aware of Regular Expressions. You might have to try with different types of sample to make sure Regular Expression is universal.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=tomcat 400 OR 401 OR 403 OR 404 OR 502 OR 503
| rex field=_raw "(?ms)^(?:[^ \\n]*){8}(?P&amp;lt;status&amp;gt;\\d+)"
| stats count by status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: Above rex is based on Data Sample Provided. Once you have tested regular expression using rex, you should create a Field Extraction through the Regular Expression.&lt;/P&gt;

&lt;P&gt;Another not so clean option would be to use &lt;STRONG&gt;searchmatch&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=tomcat 400 OR 401 OR 403 OR 404 OR 502 OR 503
| eval status=case(searchmatch("400"),400,searchmatch("401"),401,searchmatch("403"),403,searchmatch("404"),404,searchmatch("502"),502,searchmatch("503"),503,true(),"Unknown")
| stats count by status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Do check out Splunk Add On for Tomcat on Splunkbase, so that Tomcat data is processed as per CIM.&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 14:37:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-get-http-error-codes-count/m-p/314227#M12544</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-05-30T14:37:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to get http error codes count</title>
      <link>https://community.splunk.com/t5/Security/How-to-get-http-error-codes-count/m-p/314228#M12545</link>
      <description>&lt;P&gt;if you want to shorten your search string and get anything which isn't 200 you can also just use&lt;BR /&gt;
status!=200&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 20:55:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-get-http-error-codes-count/m-p/314228#M12545</guid>
      <dc:creator>anthonymelita</dc:creator>
      <dc:date>2017-05-30T20:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to get http error codes count</title>
      <link>https://community.splunk.com/t5/Security/How-to-get-http-error-codes-count/m-p/314229#M12546</link>
      <description>&lt;P&gt;Maybe this? To stop you having to write out every status code except 200. &lt;/P&gt;

&lt;P&gt;anything other than 200 - &lt;BR /&gt;
sourcetype=tomcat | insert regex to extract status here| where status!=200 | stats count by status&lt;/P&gt;

&lt;P&gt;or if you create status as a search time extraction-&lt;BR /&gt;
sourcetype=tomcat status!=200 | stats count by status&lt;/P&gt;

&lt;P&gt;To have a more accurate "error" reading, use &amp;gt;399 &lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 13:38:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-get-http-error-codes-count/m-p/314229#M12546</guid>
      <dc:creator>WalshyB</dc:creator>
      <dc:date>2017-05-31T13:38:12Z</dc:date>
    </item>
  </channel>
</rss>

