<?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: Why does my regular expression work in search, but it does not work in transforms.conf? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-does-my-regular-expression-work-in-search-but-it-does-not/m-p/293367#M88578</link>
    <description>&lt;P&gt;Thanks somesoni2.  your REGEX works when i test it at regex101.com but not in my transforms.conf.  this data is still getting to my indexer.&lt;/P&gt;</description>
    <pubDate>Tue, 14 Feb 2017 22:37:49 GMT</pubDate>
    <dc:creator>murhammr</dc:creator>
    <dc:date>2017-02-14T22:37:49Z</dc:date>
    <item>
      <title>Why does my regular expression work in search, but it does not work in transforms.conf?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-my-regular-expression-work-in-search-but-it-does-not/m-p/293361#M88572</link>
      <description>&lt;P&gt;I'm having trouble converting a search string into a working regular expression in transforms.conf to send events to the nullQueue.  here is a sample XML event:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;record version="2" event="stat(2)" modifier="fe" host="hostname.goeshere.com " iso8601="2017-02-04 04:03:52.223 -06:00"&amp;gt; &amp;lt;path&amp;gt;/path/to/oracle/product/version/db/lib/libavl.so.1&amp;lt;/path&amp;gt; &amp;lt;subject audit-uid="username" uid="oracle" gid="dba" ruid="oracle" rgid="dba" pid="18395" sid="2390772688" tid="16257 131094 hostname.goeshere.com"/&amp;gt; &amp;lt;return errval="failure: No such file or directory" retval="-1"/&amp;gt; &amp;lt;/record&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;i want to send an event to nullQueue if all 3 strings are in the event:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;event="stat(2)"    
uid="oracle"
retval="-1"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;i can craft a regex that finds these entries in search &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"event="stat(2)"*uid="oracle"*retval="-1""
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but i can't seem to figure out how to get this working properly in transforms.conf.  I've tried removing the outer set of quotes, escaping the quotes, escaping the non-alphas, using different regex for the wildcards besides *.&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;cat transforms.conf &lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;PRE&gt;&lt;CODE&gt;[null_queue_filter]
REGEX = event=\"stat(2)\"*uid=\"oracle\"*retval=\"-1\"
DEST_KEY = queue
FORMAT = nullQueue
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;cat props.conf&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;PRE&gt;&lt;CODE&gt;[audit_xml]
KV_MODE = xml
TIME_PREFIX = iso8601\=\"
BREAK_ONLY_BEFORE = \
SHOULD_LINEMERGE = true
TRANSFORMS-audit_xml = null_queue_filter
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Feb 2017 22:07:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-my-regular-expression-work-in-search-but-it-does-not/m-p/293361#M88572</guid>
      <dc:creator>murhammr</dc:creator>
      <dc:date>2017-02-09T22:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: Why does my regular expression work in search, but it does not work in transforms.conf?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-my-regular-expression-work-in-search-but-it-does-not/m-p/293362#M88573</link>
      <description>&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;I didn't see you pointed the props to use the transforms:&lt;BR /&gt;
&lt;STRONG&gt;TRANSFORMS-audit_xml= audit_xml&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;[audit_xml] &lt;BR /&gt;
KV_MODE = xml &lt;BR /&gt;
TIME_PREFIX = iso8601=\" &lt;BR /&gt;
BREAK_ONLY_BEFORE = \ &lt;BR /&gt;
TRANSFORMS-audit_xml= audit_xml&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;The following REGEX worked, tested at regex101.com:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;event=\"stat\(2\)\".*uid=\"oracle\".*retval=\"-1\"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[null_queue_filter] 
REGEX = event=\"stat\(2\)\".*uid=\"oracle\".*retval=\"-1\"
DEST_KEY = queue 
FORMAT = nullQueue 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:49:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-my-regular-expression-work-in-search-but-it-does-not/m-p/293362#M88573</guid>
      <dc:creator>ehudb</dc:creator>
      <dc:date>2020-09-29T12:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: Why does my regular expression work in search, but it does not work in transforms.conf?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-my-regular-expression-work-in-search-but-it-does-not/m-p/293363#M88574</link>
      <description>&lt;P&gt;i must have omitted part of my props.conf in the original post:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[audit_xml]
KV_MODE = xml
TIME_PREFIX = iso8601\=\"
BREAK_ONLY_BEFORE = \&amp;lt;record
SHOULD_LINEMERGE = true
TRANSFORMS-audit_xml = null_queue_filter
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Feb 2017 23:00:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-my-regular-expression-work-in-search-but-it-does-not/m-p/293363#M88574</guid>
      <dc:creator>murhammr</dc:creator>
      <dc:date>2017-02-09T23:00:21Z</dc:date>
    </item>
    <item>
      <title>Re: Why does my regular expression work in search, but it does not work in transforms.conf?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-my-regular-expression-work-in-search-but-it-does-not/m-p/293364#M88575</link>
      <description>&lt;P&gt;Escaping quotes is not necessary in the Transforms.conf, and additionally, for the &lt;CODE&gt;REGEX&lt;/CODE&gt; to match and filter, you must have a capture group. Be careful with the &lt;CODE&gt;uid&lt;/CODE&gt; matching, as your sample data has &lt;CODE&gt;ruid&lt;/CODE&gt; which might match and be a false positive. So in the below regex, I made the &lt;CODE&gt;.*&lt;/CODE&gt; capture non-greedy to capture up to the first instance of &lt;CODE&gt;uid=&lt;/CODE&gt;, instead of the match of &lt;CODE&gt;ruid&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; REGEX = (event="stat\(2\)".*?uid="oracle".+retval="-1")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should filter your events to the null queue.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Feb 2017 17:47:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-my-regular-expression-work-in-search-but-it-does-not/m-p/293364#M88575</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2017-02-11T17:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: Why does my regular expression work in search, but it does not work in transforms.conf?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-my-regular-expression-work-in-search-but-it-does-not/m-p/293365#M88576</link>
      <description>&lt;P&gt;Thanks alacercogitatus but this is not working for me either.  I tried your REGEX on my heavy forwarder but these events are still getting to my indexer.  &lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2017 19:29:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-my-regular-expression-work-in-search-but-it-does-not/m-p/293365#M88576</guid>
      <dc:creator>murhammr</dc:creator>
      <dc:date>2017-02-14T19:29:05Z</dc:date>
    </item>
    <item>
      <title>Re: Why does my regular expression work in search, but it does not work in transforms.conf?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-my-regular-expression-work-in-search-but-it-does-not/m-p/293366#M88577</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; REGEX = event=\"stat\(2\)\".+\suid=\"oracle\".+\sretval=\"-1\"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Feb 2017 19:48:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-my-regular-expression-work-in-search-but-it-does-not/m-p/293366#M88577</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-02-14T19:48:21Z</dc:date>
    </item>
    <item>
      <title>Re: Why does my regular expression work in search, but it does not work in transforms.conf?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-my-regular-expression-work-in-search-but-it-does-not/m-p/293367#M88578</link>
      <description>&lt;P&gt;Thanks somesoni2.  your REGEX works when i test it at regex101.com but not in my transforms.conf.  this data is still getting to my indexer.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2017 22:37:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-my-regular-expression-work-in-search-but-it-does-not/m-p/293367#M88578</guid>
      <dc:creator>murhammr</dc:creator>
      <dc:date>2017-02-14T22:37:49Z</dc:date>
    </item>
    <item>
      <title>Re: Why does my regular expression work in search, but it does not work in transforms.conf?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-my-regular-expression-work-in-search-but-it-does-not/m-p/293368#M88579</link>
      <description>&lt;P&gt;I finally got this working.  This is my working REGEX in transforms.conf.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;REGEX = (?:event\=\"stat\(2\)\"(\w|\W)*\suid\=\"oracle\"(\w|\W)*retval\=\"-1\")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This was a great debugging tip from the answer entitled REGEX and NullQueue problem: &lt;A href="https://answers.splunk.com/answers/108326/regex-and-nullqueue-problem.html"&gt;https://answers.splunk.com/answers/108326/regex-and-nullqueue-problem.html&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=blah| regex _raw="(?:event\=\"stat\(2\)\"(\w|\W)*\suid\=\"oracle\"(\w|\W)*retval\=\"-1\")"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I could successfully find events with any of the 3 string parts      event=\"stat(2)\"      or     \suid=\"oracle\"        or     retval=\"-1\"&lt;BR /&gt;
but putting them together was the problem.    Not sure exactly why the other wildcard regex ( &lt;CODE&gt;*  or .+  or .*&lt;/CODE&gt; )  didn't work.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2017 23:26:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-my-regular-expression-work-in-search-but-it-does-not/m-p/293368#M88579</guid>
      <dc:creator>murhammr</dc:creator>
      <dc:date>2017-02-14T23:26:40Z</dc:date>
    </item>
  </channel>
</rss>

