<?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: regex working in search but not when used from props/transforms in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-is-regex-working-in-search-but-not-when-used-from-props/m-p/635020#M220612</link>
    <description>&lt;P&gt;All regexes are automatically prepended with (?ms) so you don't have to set it explicitly.&lt;/P&gt;&lt;PRE&gt;* dotall (?s) and multi-line (?m) modifiers are added in front of the regex.
  So internally, the regex becomes (?ms)&amp;lt;regex&amp;gt;.&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 18 Mar 2023 09:34:37 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2023-03-18T09:34:37Z</dc:date>
    <item>
      <title>Why is regex working in search but not when used from props/transforms?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-regex-working-in-search-but-not-when-used-from-props/m-p/634931#M220571</link>
      <description>&lt;P&gt;We have some logs coming in the following format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;ERROR | 2023-03-16 01:27:14 EDT | field1=field1_value | field2=field2_value | field3=field3_value | field4=field4_value | field5=field5_value | field6=field6_value | field7={} | message=Message String with spaces.
java.stacktrace.Exception: Exception Details.
	at ...
	at ...
	at ...
	at ...&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Splunk's default extraction works well in getting all key=value pairs, except for the field "message" where only first word before the space is extracted&amp;nbsp; and drops the rest.&lt;/P&gt;
&lt;P&gt;To get around this, I used the following inline regex.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;|  rex field=_raw "message=(?&amp;lt;message&amp;gt;.+)"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This works well in search and extracts the entire message string right until the newline. But when I used the same regex in the configuration file, it seems to be ignoring the newline and continues to match everything else all the way until end of the event. Have tried using EXTRACT as well as REPORT(using transforms.conf) but same result.&lt;/P&gt;
&lt;P&gt;Do props.conf/transforms.conf interpret regex differently?&lt;/P&gt;
&lt;P&gt;To summarize,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;default Splunk extraction,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt; message = Message&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;with inline rex&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;message = Message String with spaces.&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;with regex in props/transforms,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;message = Message String with spaces.
java.stacktrace.Exception: Exception Details.
at ...
at ...
at ...
at ...&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any suggestions on how to use this regex from configuration?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2023 16:07:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-regex-working-in-search-but-not-when-used-from-props/m-p/634931#M220571</guid>
      <dc:creator>att35</dc:creator>
      <dc:date>2023-03-17T16:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: regex working in search but not when used from props/transforms</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-regex-working-in-search-but-not-when-used-from-props/m-p/634942#M220574</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/179828"&gt;@att35&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;please try this regex:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(?ms).*message=(?&amp;lt;message&amp;gt;.+)"&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2023 15:41:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-regex-working-in-search-but-not-when-used-from-props/m-p/634942#M220574</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-03-17T15:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: regex working in search but not when used from props/transforms</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-regex-working-in-search-but-not-when-used-from-props/m-p/634962#M220582</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this with EXTRACT.&amp;nbsp; Renaming the extracted field for comparison.&lt;/P&gt;&lt;P&gt;When I used it with quotes, nothing gets extracted.&amp;nbsp; No Msg field&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;EXTRACT-fullmessage = "(?ms).*message=(?&amp;lt;Msg&amp;gt;.+)"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;And when I try without the quotes, extraction works but it does the same thing as before. Entire event from message onwards gets included.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;EXTRACT-fullmessage = (?ms).*message=(?&amp;lt;Msg&amp;gt;.+)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2023 17:34:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-regex-working-in-search-but-not-when-used-from-props/m-p/634962#M220582</guid>
      <dc:creator>att35</dc:creator>
      <dc:date>2023-03-17T17:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: regex working in search but not when used from props/transforms</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-regex-working-in-search-but-not-when-used-from-props/m-p/634967#M220586</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/179828"&gt;@att35&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;you don't have to use quotes in props.conf.&lt;/P&gt;&lt;P&gt;It should work as you can see at&amp;nbsp;&lt;A href="https://regex101.com/r/EbFNFY/1" target="_blank"&gt;https://regex101.com/r/EbFNFY/1&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2023 18:25:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-regex-working-in-search-but-not-when-used-from-props/m-p/634967#M220586</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-03-17T18:25:39Z</dc:date>
    </item>
    <item>
      <title>Re: regex working in search but not when used from props/transforms</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-regex-working-in-search-but-not-when-used-from-props/m-p/634971#M220587</link>
      <description>&lt;P&gt;What I am trying to extract is the highlighted part.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Splunk_regex_1.png" style="width: 872px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24358i43D319D44C0655B9/image-size/large?v=v2&amp;amp;px=999" role="button" title="Splunk_regex_1.png" alt="Splunk_regex_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If I change that regex to&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(?m).*message=(?&amp;lt;Msg&amp;gt;.+)&lt;/LI-CODE&gt;&lt;P&gt;it works, but when used in props behavior is still the same.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Splunk_regex_2.png" style="width: 881px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24359iCE684AB5FD0FA2A5/image-size/large?v=v2&amp;amp;px=999" role="button" title="Splunk_regex_2.png" alt="Splunk_regex_2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So basically, I only want to extract the message string before the Java stack trace starts.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2023 18:32:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-regex-working-in-search-but-not-when-used-from-props/m-p/634971#M220587</guid>
      <dc:creator>att35</dc:creator>
      <dc:date>2023-03-17T18:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: Why is regex working in search but not when used from props/transforms?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-regex-working-in-search-but-not-when-used-from-props/m-p/634972#M220588</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(?ms).*message=(?&amp;lt;Msg&amp;gt;[^\r\n]+)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Capturing everything till first newline character.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2023 18:33:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-regex-working-in-search-but-not-when-used-from-props/m-p/634972#M220588</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2023-03-17T18:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: regex working in search but not when used from props/transforms</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-regex-working-in-search-but-not-when-used-from-props/m-p/635003#M220604</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/179828"&gt;@att35&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;what happend if you use (?ms) in the props?&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Sat, 18 Mar 2023 07:05:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-regex-working-in-search-but-not-when-used-from-props/m-p/635003#M220604</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-03-18T07:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: regex working in search but not when used from props/transforms</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-regex-working-in-search-but-not-when-used-from-props/m-p/635020#M220612</link>
      <description>&lt;P&gt;All regexes are automatically prepended with (?ms) so you don't have to set it explicitly.&lt;/P&gt;&lt;PRE&gt;* dotall (?s) and multi-line (?m) modifiers are added in front of the regex.
  So internally, the regex becomes (?ms)&amp;lt;regex&amp;gt;.&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Mar 2023 09:34:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-regex-working-in-search-but-not-when-used-from-props/m-p/635020#M220612</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-03-18T09:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: regex working in search but not when used from props/transforms</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-regex-working-in-search-but-not-when-used-from-props/m-p/635021#M220613</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/15147"&gt;@somesoni2&lt;/a&gt;'s solution should work. It captures a string _not_ conaining newlines which means that it stops capturing at first encountered newline.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Mar 2023 09:38:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-regex-working-in-search-but-not-when-used-from-props/m-p/635021#M220613</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-03-18T09:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: regex working in search but not when used from props/transforms</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-regex-working-in-search-but-not-when-used-from-props/m-p/635025#M220616</link>
      <description>&lt;P&gt;It did start the match for message but did not stop at the newline. It continues all the way till end of the event.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Mar 2023 13:23:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-regex-working-in-search-but-not-when-used-from-props/m-p/635025#M220616</guid>
      <dc:creator>att35</dc:creator>
      <dc:date>2023-03-18T13:23:33Z</dc:date>
    </item>
    <item>
      <title>Re: regex working in search but not when used from props/transforms</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-regex-working-in-search-but-not-when-used-from-props/m-p/635026#M220617</link>
      <description>&lt;P&gt;Yes.&amp;nbsp; That solution worked perfectly. It stopped at the newline and extracted only the characters before that.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Mar 2023 13:24:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-regex-working-in-search-but-not-when-used-from-props/m-p/635026#M220617</guid>
      <dc:creator>att35</dc:creator>
      <dc:date>2023-03-18T13:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: Why is regex working in search but not when used from props/transforms?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-regex-working-in-search-but-not-when-used-from-props/m-p/635027#M220618</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/15147"&gt;@somesoni2&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This did the trick.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Mar 2023 13:25:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-regex-working-in-search-but-not-when-used-from-props/m-p/635027#M220618</guid>
      <dc:creator>att35</dc:creator>
      <dc:date>2023-03-18T13:25:33Z</dc:date>
    </item>
  </channel>
</rss>

