<?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 Multiple regex in a field extraction in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Multiple-regex-in-a-field-extraction/m-p/311883#M93439</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;What I mean is that I want to parse all the error messages in my logs into one field called Errors but the regular expressions are different. &lt;/P&gt;

&lt;P&gt;Examples:&lt;BR /&gt;
Error: exceed max iterations, iter 120, count_trial 120&lt;BR /&gt;
ERROR setup_acap_venv.sh failed.&lt;BR /&gt;
ERROR    [ac_analysis.tools.merge_annotations:327]&lt;/P&gt;

&lt;P&gt;They don't quite all match up so one field extraction won't encompass all of them. Is there a way to have multiple regex that go into one field? Or is there a way to handle this when indexing the data instead of creating a field extraction?&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 14:12:15 GMT</pubDate>
    <dc:creator>byu168</dc:creator>
    <dc:date>2020-09-29T14:12:15Z</dc:date>
    <item>
      <title>Multiple regex in a field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-regex-in-a-field-extraction/m-p/311883#M93439</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;What I mean is that I want to parse all the error messages in my logs into one field called Errors but the regular expressions are different. &lt;/P&gt;

&lt;P&gt;Examples:&lt;BR /&gt;
Error: exceed max iterations, iter 120, count_trial 120&lt;BR /&gt;
ERROR setup_acap_venv.sh failed.&lt;BR /&gt;
ERROR    [ac_analysis.tools.merge_annotations:327]&lt;/P&gt;

&lt;P&gt;They don't quite all match up so one field extraction won't encompass all of them. Is there a way to have multiple regex that go into one field? Or is there a way to handle this when indexing the data instead of creating a field extraction?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:12:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-regex-in-a-field-extraction/m-p/311883#M93439</guid>
      <dc:creator>byu168</dc:creator>
      <dc:date>2020-09-29T14:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple regex in a field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-regex-in-a-field-extraction/m-p/311884#M93440</link>
      <description>&lt;P&gt;Yes, you can definitely have multiple field extractions in to the same field.&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[&amp;lt;sourcetype&amp;gt;]
REPORT-yourfield = yourfield1,yourfield2,yourfield3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[yourfield1]
REGEX = (?&amp;lt;yourfield&amp;gt;blahblahblah)

[yourfield2]
REGEX = (?&amp;lt;yourfield&amp;gt;moreblahmoreblah)

[yourfield3]
REGEX = (?&amp;lt;yourfield&amp;gt;evenmoreblah)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 May 2017 18:46:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-regex-in-a-field-extraction/m-p/311884#M93440</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2017-05-25T18:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple regex in a field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-regex-in-a-field-extraction/m-p/311885#M93441</link>
      <description>&lt;P&gt;One field extract should work, especially if your logs all lead with 'error' string prefix.  Simple extraction based on your sample events:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;(?i)error[\s:]+(?.*)  OR  (?i)error[^\w]+(?.*(?\]|\.))&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The first one being the more simple/straightforward of the two, with the latter aiming to clean up the extracted data if you are so inclined.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;perl -ne 'print $1.$/ if /error[^\w]+(.*(?&amp;lt;!\]|\.))/i' re_sample&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;exceed max iterations, iter 120, count_trial 120&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;setup_acap_venv.sh failed&lt;/CODE&gt;&lt;/P&gt;

&lt;H2&gt;&lt;CODE&gt;ac_analysis.tools.merge_annotations:327&lt;/CODE&gt;&lt;/H2&gt;

&lt;P&gt;Joe&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2017 19:06:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-regex-in-a-field-extraction/m-p/311885#M93441</guid>
      <dc:creator>jwalbert</dc:creator>
      <dc:date>2017-05-25T19:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple regex in a field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-regex-in-a-field-extraction/m-p/311886#M93442</link>
      <description>&lt;P&gt;Yes, you can do this in the CLI by piping to a  series of &lt;CODE&gt;regex&lt;/CODE&gt; commands back-to-back with the same capture name.  The last successful one will win but none of the unsuccessful ones will damage a previously successful field value creation.&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2017 19:08:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-regex-in-a-field-extraction/m-p/311886#M93442</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-05-25T19:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple regex in a field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-regex-in-a-field-extraction/m-p/311887#M93443</link>
      <description>&lt;P&gt;Thanks! Worked perfectly&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2017 21:33:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-regex-in-a-field-extraction/m-p/311887#M93443</guid>
      <dc:creator>byu168</dc:creator>
      <dc:date>2017-05-25T21:33:56Z</dc:date>
    </item>
  </channel>
</rss>

