<?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: RegEx for variable message field extraction in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/RegEx-for-variable-message-field-extraction/m-p/104192#M26979</link>
    <description>&lt;P&gt;Perfect, thanks!&lt;/P&gt;</description>
    <pubDate>Fri, 26 Oct 2012 20:38:56 GMT</pubDate>
    <dc:creator>johnebgood</dc:creator>
    <dc:date>2012-10-26T20:38:56Z</dc:date>
    <item>
      <title>RegEx for variable message field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/RegEx-for-variable-message-field-extraction/m-p/104188#M26975</link>
      <description>&lt;P&gt;Hello, I have logs coming in that look like the following:&lt;/P&gt;

&lt;P&gt;(Tab between columns)&lt;/P&gt;

&lt;P&gt;server1.something.com   ApacheLog   0   10.0.0.1&lt;BR /&gt;&lt;BR /&gt;
server2.something.com   ApacheLog   0   10.0.0.2&lt;BR /&gt;&lt;BR /&gt;
server3.something.com   GenericLog  0   0   0   0&lt;BR /&gt;&lt;BR /&gt;
server4.something.com   GenericLog  0   0   0   0 &lt;/P&gt;

&lt;P&gt;Using the IPs to have splunk generate a pattern results in this regex:&lt;BR /&gt;&lt;BR /&gt;
(?i)^(?:[^\t]*\t){3}(?P&amp;lt;FIELDNAME&amp;gt;[^ ]+)&lt;/P&gt;

&lt;P&gt;The IP will be in the same place every time ApacheLog is present... so basically I want my RegEx to be something like the following which doesn't work:&lt;/P&gt;

&lt;P&gt;^*\t*&lt;EM&gt;ApacheLog&lt;/EM&gt;*\t*\t(?P&amp;lt;FIELDNAME&amp;gt;[^ ]+)&lt;/P&gt;

&lt;P&gt;Any assistance would be appreciated.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
John&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:42:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/RegEx-for-variable-message-field-extraction/m-p/104188#M26975</guid>
      <dc:creator>johnebgood</dc:creator>
      <dc:date>2020-09-28T12:42:06Z</dc:date>
    </item>
    <item>
      <title>Re: RegEx for variable message field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/RegEx-for-variable-message-field-extraction/m-p/104189#M26976</link>
      <description>&lt;P&gt;Hi John,&lt;/P&gt;

&lt;P&gt;Try the following regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\s+ApacheLog\s+\d\s+(?&amp;lt;MyFieldName&amp;gt;(?:\d{1,3}\.){3}\d{1,3})
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can test that by using the rex command on your events and seeing if the field contains what you expect. For example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|rex field=_raw "\s+ApacheLog\s+\d\s+(?&amp;lt;MyFieldName&amp;gt;(?:\d{1,3}\.){3}\d{1,3})"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Oct 2012 18:31:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/RegEx-for-variable-message-field-extraction/m-p/104189#M26976</guid>
      <dc:creator>Rob</dc:creator>
      <dc:date>2012-10-26T18:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: RegEx for variable message field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/RegEx-for-variable-message-field-extraction/m-p/104190#M26977</link>
      <description>&lt;P&gt;This works in the search field however when I attempt to edit the pattern in "Extract Fields" I get a "Invalid regex: syntax error". Any thoughts there?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 26 Oct 2012 18:56:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/RegEx-for-variable-message-field-extraction/m-p/104190#M26977</guid>
      <dc:creator>johnebgood</dc:creator>
      <dc:date>2012-10-26T18:56:05Z</dc:date>
    </item>
    <item>
      <title>Re: RegEx for variable message field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/RegEx-for-variable-message-field-extraction/m-p/104191#M26978</link>
      <description>&lt;P&gt;Using the interactive field extractor, the syntax its looking for will be slightly different. Try the following there:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.*\s+ApacheLog\s+\d\s+(?P&amp;lt;MyFieldName&amp;gt;(?:\d{1,3}\.){3}\d{1,3})
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Oct 2012 19:19:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/RegEx-for-variable-message-field-extraction/m-p/104191#M26978</guid>
      <dc:creator>Rob</dc:creator>
      <dc:date>2012-10-26T19:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: RegEx for variable message field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/RegEx-for-variable-message-field-extraction/m-p/104192#M26979</link>
      <description>&lt;P&gt;Perfect, thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 26 Oct 2012 20:38:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/RegEx-for-variable-message-field-extraction/m-p/104192#M26979</guid>
      <dc:creator>johnebgood</dc:creator>
      <dc:date>2012-10-26T20:38:56Z</dc:date>
    </item>
  </channel>
</rss>

