<?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: Rex Field Question in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417803#M169233</link>
    <description>&lt;P&gt;Do you want to extract them as multi-value in the same field or separate fields?&lt;/P&gt;</description>
    <pubDate>Thu, 24 May 2018 16:06:57 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2018-05-24T16:06:57Z</dc:date>
    <item>
      <title>Rex Field Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417790#M169220</link>
      <description>&lt;P&gt;I have a message field in an event id that isn't extracting properly. The part I've having an issue with is when there's a special character in the middle (of unknown length string) of the string.&lt;/P&gt;

&lt;P&gt;For example, I can extract "test\user" with no issues, but when I have something like below:&lt;/P&gt;

&lt;P&gt;test\user.name&lt;BR /&gt;
test\user-name&lt;BR /&gt;
test\username-was-here&lt;BR /&gt;
test\username-was-not.here$&lt;/P&gt;

&lt;P&gt;I'm unable to extract them. I've tried:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=Message "(?&amp;lt;SubjectID&amp;gt;[1-9A-Za-z$].+[-$._].+[1-9A-Za-z$]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I've tried the $ with the \$ as well, but this doesn't provide any results. I've also tried taking the 'test\user-name' field and plug it in directly to see if it was show me a result, but that failed to work as well. Is there a way to do this where I could take into account all scenarios above? &lt;/P&gt;

&lt;P&gt;Here's the log entry:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/5036i6323B010C3479F0A/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Below is a message that doesn't work due to spaces in the name/ID:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/5037iE53A3CCED1731E2C/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;BR /&gt;
Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 14:15:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417790#M169220</guid>
      <dc:creator>johnblakley</dc:creator>
      <dc:date>2018-05-24T14:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: Rex Field Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417791#M169221</link>
      <description>&lt;P&gt;can  you provide whole raw data (with important data to be masked) to understand starting and ending to extract id&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 14:35:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417791#M169221</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-05-24T14:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: Rex Field Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417792#M169222</link>
      <description>&lt;P&gt;Added to original post...thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 14:42:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417792#M169222</guid>
      <dc:creator>johnblakley</dc:creator>
      <dc:date>2018-05-24T14:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: Rex Field Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417793#M169223</link>
      <description>&lt;P&gt;so here are you trying to extract  security id?&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 14:46:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417793#M169223</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-05-24T14:46:57Z</dc:date>
    </item>
    <item>
      <title>Re: Rex Field Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417794#M169224</link>
      <description>&lt;P&gt;Yes for both Subject and Target accounts. My regex works on test sites to capture all special characters, but Splunk doesn't work. It's simple enough to do "\w+[-].+[-].+" and it will find anything with two dashes. Splunk won't complain, but it will return a blank result with rex for the extracted field in &lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 14:50:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417794#M169224</guid>
      <dc:creator>johnblakley</dc:creator>
      <dc:date>2018-05-24T14:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: Rex Field Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417795#M169225</link>
      <description>&lt;P&gt;try this for Subject accounts&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...|rex field=raw "Subject:\nSecurity ID:(?&amp;lt;SubjectSecurityID&amp;gt;\S+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 May 2018 14:58:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417795#M169225</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-05-24T14:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: Rex Field Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417796#M169226</link>
      <description>&lt;P&gt;Okay, thank you! Field=raw doesn't work for some reason, but this seems to:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=Message "Subject:\s+Security\s+ID:\s+(?&amp;lt;SubjectSecurityID&amp;gt;\S+)" | table SubjectSecurityID
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 May 2018 15:14:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417796#M169226</guid>
      <dc:creator>johnblakley</dc:creator>
      <dc:date>2018-05-24T15:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: Rex Field Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417797#M169227</link>
      <description>&lt;P&gt;now try this for both:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| rex field=Message "(?ms)Subject:\nSecurity ID:(?&amp;lt;SubjectSecurityID&amp;gt;\S+).*Target Account:\nSecurity ID:(?&amp;lt;TargetSecurityID&amp;gt;\S+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 May 2018 15:18:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417797#M169227</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-05-24T15:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: Rex Field Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417798#M169228</link>
      <description>&lt;P&gt;@johnblankley, which field are you trying to extract?&lt;BR /&gt;
It is Security ID or Account Name or Logon ID? Also is it from Subject or from Target Account?&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 15:34:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417798#M169228</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-05-24T15:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: Rex Field Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417799#M169229</link>
      <description>&lt;P&gt;Security ID from both Subject and Target sections. &lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 15:37:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417799#M169229</guid>
      <dc:creator>johnblakley</dc:creator>
      <dc:date>2018-05-24T15:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: Rex Field Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417800#M169230</link>
      <description>&lt;P&gt;This is very close! I had to modify it a little, but I noticed a new issue. How can I take into account the SubjectSecurityID to have a space? What I'm seeing is "NT AUTHORITY\SYSTEM" only shows "NT". I've played around with adding something like "(?\S+\s+\w+), but that's not working.&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 15:44:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417800#M169230</guid>
      <dc:creator>johnblakley</dc:creator>
      <dc:date>2018-05-24T15:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: Rex Field Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417801#M169231</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| rex field=Message  "(?ms)Subject:\nSecurity ID:(?&amp;lt;SubjectSecurityID&amp;gt;.*)Account Name.*Target Account:\nSecurity ID:(?&amp;lt;TargetSecurityID&amp;gt;.*)Account Name"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 May 2018 15:56:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417801#M169231</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-05-24T15:56:26Z</dc:date>
    </item>
    <item>
      <title>Re: Rex Field Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417802#M169232</link>
      <description>&lt;P&gt;Unfortunately, that didn't work. It looks like the message field is one line of characters, so the Subject now becomes the full message when using .*&lt;/P&gt;

&lt;P&gt;The result is this:&lt;BR /&gt;
NT AUTHORITY\SYSTEM Account Name:   xxxx$ Account Domain:   xxxx Logon ID:  0x3e7&lt;/P&gt;

&lt;P&gt;It should just be:&lt;BR /&gt;
NT AUTHORITY\SYSTEM&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 16:03:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417802#M169232</guid>
      <dc:creator>johnblakley</dc:creator>
      <dc:date>2018-05-24T16:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: Rex Field Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417803#M169233</link>
      <description>&lt;P&gt;Do you want to extract them as multi-value in the same field or separate fields?&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 16:06:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417803#M169233</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-05-24T16:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: Rex Field Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417804#M169234</link>
      <description>&lt;P&gt;&lt;STRONG&gt;[Updated Answer]&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Since &lt;CODE&gt;Security ID:&lt;/CODE&gt; is followed by &lt;CODE&gt;Account Name:&lt;/CODE&gt;, following regex extracts all characters between the two using &lt;CODE&gt;.+&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourBaseSearch&amp;gt; EventCode=4724 Message="*" "Subject:" "Target Account:" "Security ID:"
|  rex field=Message "Security ID:\s+(?&amp;lt;SecurityID&amp;gt;.+)\s+Account Name:" max_match=2
|  eval SubjectSecurityID=mvindex(SecurityID,0), TargetAccountSecurityID=mvindex(SecurityID,1)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please try out and confirm!&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;@johnblakley, please try the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourBaseSearch&amp;gt; EventCode=4724 Message="*" "Subject:" "Target Account:" "Security ID:"
|  rex field=Message "Security ID:\s+(?&amp;lt;SecurityID&amp;gt;[^\s]+)\s" max_match=2
|  eval SubjectSecurityID=mvindex(SecurityID,0), TargetAccountSecurityID=mvindex(SecurityID,1)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 May 2018 16:14:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417804#M169234</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-05-24T16:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: Rex Field Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417805#M169235</link>
      <description>&lt;P&gt;can you provide whole message where it won't work...&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 16:20:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417805#M169235</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-05-24T16:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: Rex Field Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417806#M169236</link>
      <description>&lt;P&gt;Added to original post. It's breaking on security IDs with spaces. This is just one example, so the \S+ is stopping at the space.&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 16:27:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417806#M169236</guid>
      <dc:creator>johnblakley</dc:creator>
      <dc:date>2018-05-24T16:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: Rex Field Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417807#M169237</link>
      <description>&lt;P&gt;This works, but it's also breaking at the space in the security ID.&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 16:28:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417807#M169237</guid>
      <dc:creator>johnblakley</dc:creator>
      <dc:date>2018-05-24T16:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: Rex Field Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417808#M169238</link>
      <description>&lt;P&gt;This seems to have worked...do you see any issues with it?&lt;/P&gt;

&lt;P&gt;(?\S+.\w+.\w+)&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 16:35:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417808#M169238</guid>
      <dc:creator>johnblakley</dc:creator>
      <dc:date>2018-05-24T16:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: Rex Field Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417809#M169239</link>
      <description>&lt;P&gt;please use &lt;CODE&gt;101010&lt;/CODE&gt; button for query so that no special characters get removed.&lt;BR /&gt;
it will work only for particular pattern.&lt;BR /&gt;
have you tried below...it seems to be working..&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| rex field=Message  "(?ms)Subject:\nSecurity ID:(?&amp;lt;SubjectSecurityID&amp;gt;.*)Account Name.*Target Account:\nSecurity ID:(?&amp;lt;TargetSecurityID&amp;gt;.*)Account Name"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 May 2018 16:44:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Question/m-p/417809#M169239</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-05-24T16:44:21Z</dc:date>
    </item>
  </channel>
</rss>

