<?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: Need help forming regex to extract username from log in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Need-help-forming-regex-to-extract-username-from-log/m-p/345634#M102399</link>
    <description>&lt;P&gt;Hi jcorkey,&lt;BR /&gt;
if the format of your logs is the one you described in your question, Splunk already extracts acct field.&lt;BR /&gt;
otherwise you have to use a regex like the following&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "acct\=\"(?&amp;lt;user&amp;gt;[^\"]*)\""
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;if it doesn'r run, please share an example of your logs.&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe &lt;/P&gt;</description>
    <pubDate>Wed, 02 Aug 2017 15:14:52 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2017-08-02T15:14:52Z</dc:date>
    <item>
      <title>Need help forming regex to extract username from log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-forming-regex-to-extract-username-from-log/m-p/345633#M102398</link>
      <description>&lt;P&gt;trying to search for when sudo user1 adds user2 to a group and I want to extract the name of the user2 that was added to a group.&lt;BR /&gt;
I am searching the audit.log file from my universal forwarder that's running on a Linux box. I am having trouble using regex to grab the name from acct="NAME" field because of the double quotes.&lt;/P&gt;

&lt;P&gt;Below is my search string and log results:&lt;/P&gt;

&lt;P&gt;search string:&lt;BR /&gt;
index=* host=* sourcetype="*" "usermod" OR "visudo" AND "type=USER_MGMT"&lt;/P&gt;

&lt;P&gt;log results:&lt;BR /&gt;
    type=USER_MGMT msg=audit(1501611744.115:10994): pid=24473 uid=0 auid=1002 ses=1236 msg='op=add-user-to-shadow-group grp="wheel" acct="addbyjoe" exe="/usr/sbin/usermod" hostname=? addr=? terminal=pts/1 res=success'&lt;/P&gt;

&lt;P&gt;How to I extract the name(addbyjoe) from acct="addbyjoe" in the log results above?&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2017 15:05:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-forming-regex-to-extract-username-from-log/m-p/345633#M102398</guid>
      <dc:creator>jcorkey</dc:creator>
      <dc:date>2017-08-02T15:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: Need help forming regex to extract username from log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-forming-regex-to-extract-username-from-log/m-p/345634#M102399</link>
      <description>&lt;P&gt;Hi jcorkey,&lt;BR /&gt;
if the format of your logs is the one you described in your question, Splunk already extracts acct field.&lt;BR /&gt;
otherwise you have to use a regex like the following&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "acct\=\"(?&amp;lt;user&amp;gt;[^\"]*)\""
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;if it doesn'r run, please share an example of your logs.&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe &lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2017 15:14:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-forming-regex-to-extract-username-from-log/m-p/345634#M102399</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-08-02T15:14:52Z</dc:date>
    </item>
  </channel>
</rss>

