<?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: Optimize rex command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Optimize-rex-command/m-p/467678#M131644</link>
    <description>&lt;P&gt;Try adding the &lt;CODE&gt;max_match=0&lt;/CODE&gt; option to the &lt;CODE&gt;rex&lt;/CODE&gt; command.&lt;/P&gt;

&lt;P&gt;Two separate &lt;CODE&gt;rex&lt;/CODE&gt; commands should work since they each search for different strings.  We can avoid conflicts using two fields and &lt;CODE&gt;coalesce&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "(Converted segments:(\s\w{3}+\s-)+\s+(?&amp;lt;grammar_error_reason1&amp;gt;.+) from here" 
| rex "(?&amp;lt;grammar_error_reason2&amp;gt;Can't find the \w+ segment\.)"
| eval grammar_error_reason = coalesce(grammar_reason1, grammar_error_reason2)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 18 Dec 2019 14:54:12 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2019-12-18T14:54:12Z</dc:date>
    <item>
      <title>Optimize rex command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Optimize-rex-command/m-p/467675#M131641</link>
      <description>&lt;P&gt;Hi all, &lt;/P&gt;

&lt;P&gt;I want to extract fields form log events.&lt;/P&gt;

&lt;P&gt;I have two errors patterns :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EDICPP 4-1-1-0 exception: Mandatory element is missing.  Error at &amp;lt;src/CBRSegmentDecoders.cpp:21405 Error in segment CSC 06 1 1A TKA in element #2. 
    ------  Error at &amp;lt;src/CBRMessageDecoders.cpp:121 Error in group Group id: _294728_G_CBR in element #3. 
    ------  Decoding error in message AIRRQT 15 2 1A PNR in element #4 at character 240 of the buffer, using charset B  Converted segments: ORG - BLK - AMD - AVC - BIN -  Cannot convert CSC from here==&amp;gt;+9998WSSU'Last segment correctly processed: CSC+7906:/++9998WSSU'
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Can't find the UNH segment.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What i want is to create a field named grammar_error_reason that contain exactly "Can not convert FOO" or "Can't find the FOO segment".&lt;/P&gt;

&lt;P&gt;Here is my rex command :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(Converted segments:(\s\w{3}+\s-)+\s|)(?&amp;lt;grammar_error_reason&amp;gt;.+) (from here|segment\.)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can you help me please.&lt;/P&gt;

&lt;P&gt;Kind regards,&lt;BR /&gt;
Clement&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:24:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Optimize-rex-command/m-p/467675#M131641</guid>
      <dc:creator>clementros</dc:creator>
      <dc:date>2020-09-30T03:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: Optimize rex command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Optimize-rex-command/m-p/467676#M131642</link>
      <description>&lt;P&gt;This regex may work for you.  If it doesn't, consider using two &lt;CODE&gt;rex&lt;/CODE&gt; commands - one for each error pattern,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "(?J)(Converted segments:(\s\w{3}+\s-)+\s+(?&amp;lt;grammar_error_reason&amp;gt;.+) from here|(?&amp;lt;grammar_error_reason&amp;gt;Can't find the \w+ segment\.))"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Dec 2019 14:00:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Optimize-rex-command/m-p/467676#M131642</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-12-18T14:00:07Z</dc:date>
    </item>
    <item>
      <title>Re: Optimize rex command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Optimize-rex-command/m-p/467677#M131643</link>
      <description>&lt;P&gt;Hi @richgalloway, &lt;/P&gt;

&lt;P&gt;Unfortunatly your rex command do not work cause it exceeded configured match_limit. &lt;/P&gt;

&lt;P&gt;If i use two rex command to extract info i think i will have a problem. The regex to extract the second pattern "Can't find the UNH segment." also match with the other pattern. &lt;/P&gt;

&lt;P&gt;How can i say if you match with the first do not try the second ? &lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2019 14:25:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Optimize-rex-command/m-p/467677#M131643</guid>
      <dc:creator>clementros</dc:creator>
      <dc:date>2019-12-18T14:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: Optimize rex command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Optimize-rex-command/m-p/467678#M131644</link>
      <description>&lt;P&gt;Try adding the &lt;CODE&gt;max_match=0&lt;/CODE&gt; option to the &lt;CODE&gt;rex&lt;/CODE&gt; command.&lt;/P&gt;

&lt;P&gt;Two separate &lt;CODE&gt;rex&lt;/CODE&gt; commands should work since they each search for different strings.  We can avoid conflicts using two fields and &lt;CODE&gt;coalesce&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "(Converted segments:(\s\w{3}+\s-)+\s+(?&amp;lt;grammar_error_reason1&amp;gt;.+) from here" 
| rex "(?&amp;lt;grammar_error_reason2&amp;gt;Can't find the \w+ segment\.)"
| eval grammar_error_reason = coalesce(grammar_reason1, grammar_error_reason2)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Dec 2019 14:54:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Optimize-rex-command/m-p/467678#M131644</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-12-18T14:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: Optimize rex command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Optimize-rex-command/m-p/467679#M131645</link>
      <description>&lt;P&gt;Thank you @richgalloway, &lt;/P&gt;

&lt;P&gt;This command works for me : &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="dbtkbkmalformed" CDCATEGORY=GRAMMAR_ERROR 
| rex "Converted segments:(\s\w{3}+\s-)+\s+(?&amp;lt;grammar_error_reason1&amp;gt;[\w\s]+) from here" 
| rex "(?&amp;lt;grammar_error_reason2&amp;gt;Can't find the \w+ segment\.)" 
| eval grammar_error_reason = coalesce(grammar_reason1, grammar_error_reason2)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Dec 2019 15:28:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Optimize-rex-command/m-p/467679#M131645</guid>
      <dc:creator>clementros</dc:creator>
      <dc:date>2019-12-18T15:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: Optimize rex command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Optimize-rex-command/m-p/467680#M131646</link>
      <description>&lt;P&gt;Be sure to do something with your duplicate question:&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/790422/optimize-rex-command.html"&gt;https://answers.splunk.com/answers/790422/optimize-rex-command.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2019 20:35:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Optimize-rex-command/m-p/467680#M131646</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-12-18T20:35:54Z</dc:date>
    </item>
  </channel>
</rss>

