<?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 Regex for multiline in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-multiline/m-p/347999#M103038</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have the following event:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;017/09/25 10:58:57 Client logging in as robertE on DB1...
Connect to Oracle failed: 
ORA-01017: invalid username/password; logon denied
ERROR:User login failed!
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am ok to extract the username via regex:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;... | rex field=_raw "Client logging in as "(?&amp;lt;usernameFail&amp;gt;\w+)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;but how do I also match the "failed" word in the 2nd line in order to differentiate successful &amp;amp; failed logons?&lt;/P&gt;

&lt;P&gt;Thanks!  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 25 Sep 2017 12:10:07 GMT</pubDate>
    <dc:creator>robettinger</dc:creator>
    <dc:date>2017-09-25T12:10:07Z</dc:date>
    <item>
      <title>Regex for multiline</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-multiline/m-p/347999#M103038</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have the following event:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;017/09/25 10:58:57 Client logging in as robertE on DB1...
Connect to Oracle failed: 
ORA-01017: invalid username/password; logon denied
ERROR:User login failed!
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am ok to extract the username via regex:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;... | rex field=_raw "Client logging in as "(?&amp;lt;usernameFail&amp;gt;\w+)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;but how do I also match the "failed" word in the 2nd line in order to differentiate successful &amp;amp; failed logons?&lt;/P&gt;

&lt;P&gt;Thanks!  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2017 12:10:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-multiline/m-p/347999#M103038</guid>
      <dc:creator>robettinger</dc:creator>
      <dc:date>2017-09-25T12:10:07Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for multiline</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-multiline/m-p/348000#M103039</link>
      <description>&lt;P&gt;Try this!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=_raw ".*Client logging in as (?&amp;lt;usernameFail&amp;gt;\w+) on DB1.*login failed!$"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Sep 2017 12:22:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-multiline/m-p/348000#M103039</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2017-09-25T12:22:31Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for multiline</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-multiline/m-p/348001#M103040</link>
      <description>&lt;P&gt;Nope. Dunno why but the original event has the "failed" string in the second line. Basically I am trying to create a field called AccessFail with the username when the regex matches AND the words "ERROR" or "failed" are present and another field called AccessOK when the regex matches but the words are not present. Does this make sense?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2017 12:39:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-multiline/m-p/348001#M103040</guid>
      <dc:creator>robettinger</dc:creator>
      <dc:date>2017-09-25T12:39:00Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for multiline</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-multiline/m-p/348002#M103041</link>
      <description>&lt;P&gt;Hi robettinger&lt;BR /&gt;
try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "(?ms)Client logging in as (?&amp;lt;user_failed_login&amp;gt;[^ ]*).*failed"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;you can test it at &lt;A href="https://regex101.com/r/qWg6Tz/1"&gt;https://regex101.com/r/qWg6Tz/1&lt;/A&gt;&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2017 12:51:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-multiline/m-p/348002#M103041</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-09-25T12:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for multiline</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-multiline/m-p/348003#M103042</link>
      <description>&lt;P&gt;Hi. That works, cool! What about the second use case, when the regex matches but the words "ERROR" or "failed" are not in the text??&lt;/P&gt;

&lt;P&gt;Thank you!!!!&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2017 13:04:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-multiline/m-p/348003#M103042</guid>
      <dc:creator>robettinger</dc:creator>
      <dc:date>2017-09-25T13:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for multiline</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-multiline/m-p/348004#M103043</link>
      <description>&lt;P&gt;This is only acquired on failure.&lt;BR /&gt;
Please show me the log at the time of success.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2017 13:09:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-multiline/m-p/348004#M103043</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2017-09-25T13:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for multiline</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-multiline/m-p/348005#M103044</link>
      <description>&lt;P&gt;Hi robettinger&lt;BR /&gt;
regex is all, also failed or ERROR, so if you haven't failed or ERROR field isn't extracted.&lt;/P&gt;

&lt;P&gt;Modify the regex to manage also "ERROR" in addition to "failed"&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?ms)Client logging in as (?&amp;lt;user_failed_login&amp;gt;[^ ]*).*(failed|ERROR)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See updated example &lt;A href="https://regex101.com/r/qWg6Tz/2"&gt;https://regex101.com/r/qWg6Tz/2&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2017 14:13:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-multiline/m-p/348005#M103044</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-09-25T14:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for multiline</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-multiline/m-p/348006#M103045</link>
      <description>&lt;P&gt;Hi Giuseppe,&lt;/P&gt;

&lt;P&gt;that's what I would like: The Events:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2017/09/26 09:44:05 Client logging in as robertE on DB1...
2017/09/26 09:45:54 Client logging in as  on DB1...
ERROR:Missing login information
2017/09/26 08:58:02 Client logging in as jamesH on DB1...
Connect to Oracle failed: 
ORA-01017: invalid username/password; logon denied
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;These 3 events should match these 2 fields:&lt;/P&gt;

&lt;P&gt;usernameOK: robertE&lt;BR /&gt;
usernameFail: jamesH and ""&lt;/P&gt;

&lt;P&gt;I can manage the usernameFail regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "(?ms)Client logging in as (?&amp;lt;usernameFail&amp;gt;[^ ]*).*(?i)(ERROR |failed|ERROR:)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but I am struggling to get the usernameOK because if I use:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "(?ms)Client logging in as (?&amp;lt;usernameFail&amp;gt;[^ ]*).*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;it will also match the failed ones ....&lt;/P&gt;

&lt;P&gt;The question is how can I match only the events where there is no ERROR or FAIL in the body?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 07:50:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-multiline/m-p/348006#M103045</guid>
      <dc:creator>robettinger</dc:creator>
      <dc:date>2017-09-26T07:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for multiline</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-multiline/m-p/348007#M103046</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;but I am struggling to get the usernameOK because if I use:

     rex "(?ms)Client logging in as (?&amp;lt;usernameFail&amp;gt;[^ ]*).*

it will also match the failed ones ....

The question is how can I match only the events where there is no ERROR or FAIL in the body?
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please check - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "(?ms)Client logging in as (?&amp;lt;usernameOK&amp;gt;[^ ]*).*(\d+)" 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Sep 2017 08:29:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-multiline/m-p/348007#M103046</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2017-09-26T08:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for multiline</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-multiline/m-p/348008#M103047</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;
for user_login use&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "Client logging in as (?&amp;lt;user_login&amp;gt;[^ ]*)(?!.*failed)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;test it at &lt;A href="https://regex101.com/r/mKCWJs/1"&gt;https://regex101.com/r/mKCWJs/1&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 08:38:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-multiline/m-p/348008#M103047</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-09-26T08:38:53Z</dc:date>
    </item>
  </channel>
</rss>

