<?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 How can I rex on an exact error code? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-rex-on-an-exact-error-code/m-p/201089#M58287</link>
    <description>&lt;P&gt;Hello ppl&lt;BR /&gt;
I have a set of Error messages in an event log that looks like this &lt;BR /&gt;
&lt;CODE&gt;ERROR [43f796d8da]&lt;/CODE&gt; there are several codes like this in the events, so i don't want to miss out extracting them&lt;/P&gt;

&lt;P&gt;What would be the rex command so that I could extract the Error codes and assign it to a field called &lt;STRONG&gt;Errortype&lt;/STRONG&gt;?&lt;/P&gt;</description>
    <pubDate>Tue, 01 Nov 2016 14:47:03 GMT</pubDate>
    <dc:creator>splgeek</dc:creator>
    <dc:date>2016-11-01T14:47:03Z</dc:date>
    <item>
      <title>How can I rex on an exact error code?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-rex-on-an-exact-error-code/m-p/201089#M58287</link>
      <description>&lt;P&gt;Hello ppl&lt;BR /&gt;
I have a set of Error messages in an event log that looks like this &lt;BR /&gt;
&lt;CODE&gt;ERROR [43f796d8da]&lt;/CODE&gt; there are several codes like this in the events, so i don't want to miss out extracting them&lt;/P&gt;

&lt;P&gt;What would be the rex command so that I could extract the Error codes and assign it to a field called &lt;STRONG&gt;Errortype&lt;/STRONG&gt;?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 14:47:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-rex-on-an-exact-error-code/m-p/201089#M58287</guid>
      <dc:creator>splgeek</dc:creator>
      <dc:date>2016-11-01T14:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: How can I rex on an exact error code?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-rex-on-an-exact-error-code/m-p/201090#M58288</link>
      <description>&lt;P&gt;If the error code exists once in every log event then try these please:&lt;/P&gt;

&lt;P&gt;1)  If you want the ERROR word and square brackets in the string as well:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yourBaseSearch
| rex "(?&amp;lt;Errortype&amp;gt;ERROR\s\[[^\]]+\])"
| complete your query using Errortype field
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See result &lt;A href="https://regex101.com/r/FuRLtO/4"&gt;here&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;2) If you only want only the code within the brackets, try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yourBaseSearch
| rex "ERROR\s\[(?&amp;lt;Errortype&amp;gt;[^\]]+)\]"
| complete your query using Errortype field
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See results &lt;A href="https://regex101.com/r/FuRLtO/6"&gt;here&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 15:05:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-rex-on-an-exact-error-code/m-p/201090#M58288</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-11-01T15:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: How can I rex on an exact error code?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-rex-on-an-exact-error-code/m-p/201091#M58289</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;|rex "\w+\s\[(?&amp;lt;Errortype&amp;gt;[^\]]+)]"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Explanation:&lt;BR /&gt;
A. Word with one or more letter&lt;BR /&gt;
B. one or more space&lt;BR /&gt;
C. starting bracket '['&lt;BR /&gt;
D. One or more Non-Closing bracket ']' character (will be the field value)&lt;BR /&gt;
E. Closing bracket ']'&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 15:05:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-rex-on-an-exact-error-code/m-p/201091#M58289</guid>
      <dc:creator>ehudb</dc:creator>
      <dc:date>2016-11-01T15:05:31Z</dc:date>
    </item>
  </channel>
</rss>

