<?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: Create a field from a string in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Create-a-field-from-a-string/m-p/169643#M48487</link>
    <description>&lt;P&gt;The rex didn't work for me with sample data from evang_26. Updated rex which worked : "The user\s+(?&lt;USER&gt;\S+)\s+connected\s+from\s+(?&lt;IP&gt;\S+)\s+"&lt;/IP&gt;&lt;/USER&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 06 Dec 2013 14:11:05 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2013-12-06T14:11:05Z</dc:date>
    <item>
      <title>Create a field from a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-a-field-from-a-string/m-p/169641#M48485</link>
      <description>&lt;P&gt;Hi users,&lt;/P&gt;

&lt;P&gt;I have a big string in one field from which I want to extract specific values such as user and IP address and count based by that. As a reference of my logs take a look below.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Message: The user julie connected from 127.0.0.1 but failed an authentication attempt due to the following reason: The remote connection was denied because the user name and password combination you provided is not recognized, or the selected authentication protocol is not permitted on the remote access server.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The query that I created by without success is the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="WinEventLog" *remote access* *failed* | rex field=Message "The user : (?&amp;lt;user&amp;gt;[a-z].*) connected from (?&amp;lt;ip&amp;gt;[1-9].*) but.*$"  | table user, ip
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Do you have any suggestions??&lt;BR /&gt;
Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2013 13:39:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-a-field-from-a-string/m-p/169641#M48485</guid>
      <dc:creator>evang_26</dc:creator>
      <dc:date>2013-12-06T13:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: Create a field from a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-a-field-from-a-string/m-p/169642#M48486</link>
      <description>&lt;P&gt;The regex needs to look something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;^\w+\s+user\s+(?&amp;lt;user&amp;gt;\S+)\s+connected\s+from\s+(?&amp;lt;ip&amp;gt;\S+)\s+
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So the search will be:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="WinEventLog" remote access failed | rex field=Message "^\w+\s+user\s+(?&amp;lt;user&amp;gt;\S+)\s+connected\s+from\s+(?&amp;lt;ip&amp;gt;\S+)\s+"  | table user, ip
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The capital "\S+" tells regex to grab everything that is not a space. You user names might have numbers in them for instance and you ip address has periods. &lt;/P&gt;

&lt;P&gt;Hope that helps. &lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2013 13:58:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-a-field-from-a-string/m-p/169642#M48486</guid>
      <dc:creator>tgow</dc:creator>
      <dc:date>2013-12-06T13:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: Create a field from a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-a-field-from-a-string/m-p/169643#M48487</link>
      <description>&lt;P&gt;The rex didn't work for me with sample data from evang_26. Updated rex which worked : "The user\s+(?&lt;USER&gt;\S+)\s+connected\s+from\s+(?&lt;IP&gt;\S+)\s+"&lt;/IP&gt;&lt;/USER&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2013 14:11:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-a-field-from-a-string/m-p/169643#M48487</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2013-12-06T14:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: Create a field from a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-a-field-from-a-string/m-p/169644#M48488</link>
      <description>&lt;P&gt;Yep, the colon after &lt;CODE&gt;Message&lt;/CODE&gt; is not a word character &lt;CODE&gt;(\w)&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2013 14:26:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-a-field-from-a-string/m-p/169644#M48488</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-12-06T14:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Create a field from a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-a-field-from-a-string/m-p/169645#M48489</link>
      <description>&lt;P&gt;You guys are GREAT! Fantastic! I was quite close then. However, give me a little more insight here. &lt;/P&gt;

&lt;P&gt;Breaking down the expression "(?&lt;USER&gt;\S+)" to smaller pieces, why we use the "?" ? I know that this is used so as to define an optional previous character. However this is not the case here. &lt;/USER&gt;&lt;/P&gt;

&lt;P&gt;As for the "&lt;USER&gt;" obviously that's the way to create the field, so that's fine!&lt;/USER&gt;&lt;/P&gt;

&lt;P&gt;I appreciate your answear, again!&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2013 14:43:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-a-field-from-a-string/m-p/169645#M48489</guid>
      <dc:creator>evang_26</dc:creator>
      <dc:date>2013-12-06T14:43:29Z</dc:date>
    </item>
    <item>
      <title>Re: Create a field from a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-a-field-from-a-string/m-p/169646#M48490</link>
      <description>&lt;P&gt;You guys are GREAT! Fantastic! I was quite close then. However, give me a little more insight here. &lt;/P&gt;

&lt;P&gt;Breaking down the expression "(?&lt;USER&gt;\S+)" to smaller pieces, why we use the "?" ? I know that this is used so as to define an optional previous character. However this is not the case here. &lt;/USER&gt;&lt;/P&gt;

&lt;P&gt;As for the "&lt;USER&gt;" obviously that's the way to create the field, so that's fine!&lt;/USER&gt;&lt;/P&gt;

&lt;P&gt;I appreciate your answear, again!&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2013 14:43:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-a-field-from-a-string/m-p/169646#M48490</guid>
      <dc:creator>evang_26</dc:creator>
      <dc:date>2013-12-06T14:43:54Z</dc:date>
    </item>
  </channel>
</rss>

