<?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 field extraction in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-field-extraction/m-p/116813#M31030</link>
    <description>&lt;P&gt;&lt;STRONG&gt;Splunk Version 6.2.0&lt;BR /&gt;
Splunk Build 237341 (MacOSX Yosemite)&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;This is the line I'm looking to extract fields using regex:&lt;/P&gt;

&lt;P&gt;15:23:42.730 |LogMessage   UserID : jdoe  ClientAddress : 172.16.60.54  Severity : 3  EventType : UserLogging  ResourceAccessed: Cisco CallManager Administration  EventStatus : Failure  CompulsoryEvent : No  AuditCategory : AdministrativeEvent  ComponentID : Cisco CCM Application  AuditDetails : Failed to Log into Cisco CCM Webpages App ID: Cisco Tomcat Cluster ID:  Node ID: UCM-CLI-P&lt;/P&gt;

&lt;P&gt;I'm looking to extract:&lt;BR /&gt;
jdoe&lt;BR /&gt;
172.16.60.54&lt;/P&gt;

&lt;P&gt;I have tested my regex using:&lt;BR /&gt;
&lt;A href="http://www.regexr.com/39t8f"&gt;http://www.regexr.com/39t8f&lt;/A&gt;&lt;BR /&gt;
In regexr the information is :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/UserID\s:\s(.*)\s+ClientAddress\s:\s(\d+.\d+.\d+.\d+)\s+\s+(.*)/g
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It correctly maps &lt;CODE&gt;(.*) and (\d+.\d+.\d+.\d+)&lt;/CODE&gt; as group 1 and group 2.&lt;/P&gt;

&lt;P&gt;I tested it using Perl:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;if ($line
=~m/.*UserID\s:\s(.*)\s+ClientAddress\s:\s(.*)\s+Severity\s:\s+(\d).*/i) {
        print " Username: " . $1 . " ClientAddress: " . $2 .  "\n";         }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And I can correctly get my fields in $1 and $2.&lt;/P&gt;

&lt;P&gt;When I execute this search in Splunk:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Failed to Log into Cisco CCM Webpages | rex field=_raw "UserID\s:\s(?.*)\s+ClientAddress\s:\s(?\d+.\d+.\d+.\d+)\s+"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The USERIDINFORMATION and CLIENTADDRESS fields are not extracted. It can find the records because of the left part of the search, but not on my regex.&lt;BR /&gt;
Any ideas?&lt;/P&gt;</description>
    <pubDate>Thu, 13 Nov 2014 15:23:58 GMT</pubDate>
    <dc:creator>gonzalogasca</dc:creator>
    <dc:date>2014-11-13T15:23:58Z</dc:date>
    <item>
      <title>Regex field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-field-extraction/m-p/116813#M31030</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Splunk Version 6.2.0&lt;BR /&gt;
Splunk Build 237341 (MacOSX Yosemite)&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;This is the line I'm looking to extract fields using regex:&lt;/P&gt;

&lt;P&gt;15:23:42.730 |LogMessage   UserID : jdoe  ClientAddress : 172.16.60.54  Severity : 3  EventType : UserLogging  ResourceAccessed: Cisco CallManager Administration  EventStatus : Failure  CompulsoryEvent : No  AuditCategory : AdministrativeEvent  ComponentID : Cisco CCM Application  AuditDetails : Failed to Log into Cisco CCM Webpages App ID: Cisco Tomcat Cluster ID:  Node ID: UCM-CLI-P&lt;/P&gt;

&lt;P&gt;I'm looking to extract:&lt;BR /&gt;
jdoe&lt;BR /&gt;
172.16.60.54&lt;/P&gt;

&lt;P&gt;I have tested my regex using:&lt;BR /&gt;
&lt;A href="http://www.regexr.com/39t8f"&gt;http://www.regexr.com/39t8f&lt;/A&gt;&lt;BR /&gt;
In regexr the information is :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/UserID\s:\s(.*)\s+ClientAddress\s:\s(\d+.\d+.\d+.\d+)\s+\s+(.*)/g
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It correctly maps &lt;CODE&gt;(.*) and (\d+.\d+.\d+.\d+)&lt;/CODE&gt; as group 1 and group 2.&lt;/P&gt;

&lt;P&gt;I tested it using Perl:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;if ($line
=~m/.*UserID\s:\s(.*)\s+ClientAddress\s:\s(.*)\s+Severity\s:\s+(\d).*/i) {
        print " Username: " . $1 . " ClientAddress: " . $2 .  "\n";         }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And I can correctly get my fields in $1 and $2.&lt;/P&gt;

&lt;P&gt;When I execute this search in Splunk:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Failed to Log into Cisco CCM Webpages | rex field=_raw "UserID\s:\s(?.*)\s+ClientAddress\s:\s(?\d+.\d+.\d+.\d+)\s+"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The USERIDINFORMATION and CLIENTADDRESS fields are not extracted. It can find the records because of the left part of the search, but not on my regex.&lt;BR /&gt;
Any ideas?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Nov 2014 15:23:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-field-extraction/m-p/116813#M31030</guid>
      <dc:creator>gonzalogasca</dc:creator>
      <dc:date>2014-11-13T15:23:58Z</dc:date>
    </item>
    <item>
      <title>Re: Regex field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-field-extraction/m-p/116814#M31031</link>
      <description>&lt;P&gt;I don't see you actually giving your matching groups names? You need to give them names:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=_raw "UserID\s:\s(?&amp;lt;USERIDINFORMATION&amp;gt;.*)\s+ClientAddress\s:\s(?&amp;lt;CLIENTADDRESS&amp;gt;\d+.\d+.\d+.\d+)\s+"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Nov 2014 15:38:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-field-extraction/m-p/116814#M31031</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2014-11-13T15:38:23Z</dc:date>
    </item>
    <item>
      <title>Re: Regex field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-field-extraction/m-p/116815#M31032</link>
      <description>&lt;P&gt;For some reason the HTML Formatting was not adding my fields&lt;/P&gt;</description>
      <pubDate>Thu, 13 Nov 2014 19:25:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-field-extraction/m-p/116815#M31032</guid>
      <dc:creator>gonzalogasca</dc:creator>
      <dc:date>2014-11-13T19:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: Regex field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-field-extraction/m-p/116816#M31033</link>
      <description>&lt;P&gt;The capture fields do need names, but also the regex needs to be good.  Anything with ".*" is generally troublesome.  You should extract the fields with two seperate regexes for efficiency:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?i)UserID\s+:\s+(?P&amp;lt;user&amp;gt;\w+)
(?i)ClientAddress\s+:\s+(?P&amp;lt;src&amp;gt;[\.\d]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This can be pasted straight into the Field Extractions section of splunk or be set at the commandline:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "(?i)UserID\s+:\s+(?P&amp;lt;user&amp;gt;\w+)" | rex "(?i)ClientAddress\s+:\s+(?P&amp;lt;src&amp;gt;[\.\d]+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Jul 2015 12:33:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-field-extraction/m-p/116816#M31033</guid>
      <dc:creator>landen99</dc:creator>
      <dc:date>2015-07-17T12:33:09Z</dc:date>
    </item>
  </channel>
</rss>

