<?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 How to search a Multiline event using rex at searchtime? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-Multiline-event-using-rex-at-searchtime/m-p/41341#M9579</link>
    <description>&lt;P&gt;Hey Splunkers,&lt;/P&gt;

&lt;P&gt;I cannot get the following rex statement to match in Splunk. I read that using (?m) in the transforms.conf file will match multiline events however I am having trouble getting this to work at searchtime. Actually, I dont even know if this will work at search time.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=security EventCode=1234 OR EventCode=123 
| rex field=_raw 
    "(?m)Target\sAccount.*\r\n\tSecurity.*\r\n\tAccount\sName\:\t\t (?&amp;lt;Foobar&amp;gt;.*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please let me know if this would work...&lt;/P&gt;

&lt;P&gt;Regardless, we have events that have a field of "Account Name". After which, there is another "Account Name" that isn't being made into a field. The data after the second Account Name is what we are trying to grab. Example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Subject:
    Security ID:        xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    Account Name:       admin
    Account Domain:     dom
    Logon ID:       xxxxxxxxxx

Target Account:
    Security ID:        xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    Account Name:       bigadmin
    Account Domain:     dom
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any better ideas on how to do this? Thanks in advance!&lt;/P&gt;

&lt;P&gt;I-Man&lt;/P&gt;</description>
    <pubDate>Wed, 09 Feb 2011 06:04:01 GMT</pubDate>
    <dc:creator>I-Man</dc:creator>
    <dc:date>2011-02-09T06:04:01Z</dc:date>
    <item>
      <title>How to search a Multiline event using rex at searchtime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-Multiline-event-using-rex-at-searchtime/m-p/41341#M9579</link>
      <description>&lt;P&gt;Hey Splunkers,&lt;/P&gt;

&lt;P&gt;I cannot get the following rex statement to match in Splunk. I read that using (?m) in the transforms.conf file will match multiline events however I am having trouble getting this to work at searchtime. Actually, I dont even know if this will work at search time.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=security EventCode=1234 OR EventCode=123 
| rex field=_raw 
    "(?m)Target\sAccount.*\r\n\tSecurity.*\r\n\tAccount\sName\:\t\t (?&amp;lt;Foobar&amp;gt;.*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please let me know if this would work...&lt;/P&gt;

&lt;P&gt;Regardless, we have events that have a field of "Account Name". After which, there is another "Account Name" that isn't being made into a field. The data after the second Account Name is what we are trying to grab. Example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Subject:
    Security ID:        xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    Account Name:       admin
    Account Domain:     dom
    Logon ID:       xxxxxxxxxx

Target Account:
    Security ID:        xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    Account Name:       bigadmin
    Account Domain:     dom
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any better ideas on how to do this? Thanks in advance!&lt;/P&gt;

&lt;P&gt;I-Man&lt;/P&gt;</description>
      <pubDate>Wed, 09 Feb 2011 06:04:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-Multiline-event-using-rex-at-searchtime/m-p/41341#M9579</guid>
      <dc:creator>I-Man</dc:creator>
      <dc:date>2011-02-09T06:04:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to search a Multiline event using rex at searchtime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-Multiline-event-using-rex-at-searchtime/m-p/41342#M9580</link>
      <description>&lt;P&gt;If you have the Windows app installed, Splunk should automagically extract both account names from the log entries.  Select Account_Name in the "Pick Fields" and search for something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Account_Name=* EventCode="4624"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You'll notice that under each event that has multiple account names, you'll see both entries:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Account_Name=- | Account_Name=SYSTEM
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You don't need the (?m).  The RegEx was not correct prior to being edited, but you shouldn't need to use one.&lt;/P&gt;

&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Wed, 09 Feb 2011 06:29:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-Multiline-event-using-rex-at-searchtime/m-p/41342#M9580</guid>
      <dc:creator>Ron_Naken</dc:creator>
      <dc:date>2011-02-09T06:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to search a Multiline event using rex at searchtime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-Multiline-event-using-rex-at-searchtime/m-p/41343#M9581</link>
      <description>&lt;P&gt;Thanks much for the response ron. Is there anyway to only grab the second account name and ignore the first instance?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Feb 2011 21:09:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-Multiline-event-using-rex-at-searchtime/m-p/41343#M9581</guid>
      <dc:creator>I-Man</dc:creator>
      <dc:date>2011-02-09T21:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to search a Multiline event using rex at searchtime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-Multiline-event-using-rex-at-searchtime/m-p/41344#M9582</link>
      <description>&lt;P&gt;You can do exactly that with &lt;STRONG&gt;mvindex&lt;/STRONG&gt;.  This function allows you to pick which value of a multi-valued field you would like to take.  I'll show a search using &lt;STRONG&gt;-1&lt;/STRONG&gt; as the index value, since this will always pick the &lt;STRONG&gt;last&lt;/STRONG&gt; value.  Using the following search will take the last "Account_Name" and place it in a field called &lt;STRONG&gt;user&lt;/STRONG&gt; for each event:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Account_Name="*" EventCode="4624" | eval user=mvindex(Account_Name,-1)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Cheers,&lt;BR /&gt;
ron&lt;/P&gt;

&lt;P&gt;P.S.  If you want to verify that the &lt;STRONG&gt;user&lt;/STRONG&gt; field is picking up the correct values, try this search which will list the &lt;STRONG&gt;Account_Name&lt;/STRONG&gt;(s) and &lt;STRONG&gt;user&lt;/STRONG&gt; fields side-by-side:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Account_Name="*" EventCode="4624" | eval user=mvindex(Account_Name,-1) | table Account_Name user
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Feb 2011 15:49:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-Multiline-event-using-rex-at-searchtime/m-p/41344#M9582</guid>
      <dc:creator>Ron_Naken</dc:creator>
      <dc:date>2011-02-10T15:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to search a Multiline event using rex at searchtime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-Multiline-event-using-rex-at-searchtime/m-p/41345#M9583</link>
      <description>&lt;P&gt;Exactly what I was looking for. Thanks ron!!!&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2011 21:25:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-Multiline-event-using-rex-at-searchtime/m-p/41345#M9583</guid>
      <dc:creator>I-Man</dc:creator>
      <dc:date>2011-02-10T21:25:31Z</dc:date>
    </item>
  </channel>
</rss>

