<?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: Field extraction from information in field=source in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Field-extraction-from-information-in-field-source/m-p/27527#M4630</link>
    <description>&lt;P&gt;Fantastic Ayn,  Thank you for the detailed response!&lt;/P&gt;</description>
    <pubDate>Wed, 07 Aug 2013 19:09:16 GMT</pubDate>
    <dc:creator>zindain24</dc:creator>
    <dc:date>2013-08-07T19:09:16Z</dc:date>
    <item>
      <title>Field extraction from information in field=source</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Field-extraction-from-information-in-field-source/m-p/27525#M4628</link>
      <description>&lt;P&gt;My webserver logs are sent to my indexers through a Universal Forwarder.&lt;/P&gt;

&lt;P&gt;*Snippet from inputs.conf on the Universal Forwarder&lt;/P&gt;

&lt;P&gt;[monitor:///path/to/apache/2.2/web/.../logs/*access_log]&lt;/P&gt;

&lt;P&gt;disabled = false&lt;/P&gt;

&lt;P&gt;sourcetype = access_combined&lt;/P&gt;

&lt;P&gt;index = internet&lt;/P&gt;

&lt;P&gt;followTail=0&lt;/P&gt;

&lt;P&gt;With this configuration, we properly set the following fields&lt;BR /&gt;
index = internet,&lt;BR /&gt;
host = unixservername,&lt;BR /&gt;
sourcetype = access_combined&lt;/P&gt;

&lt;P&gt;The problem is, we need a field with the webserver name in segment 6 of the source:&lt;BR /&gt;
/path/to/apache/2.2/web/&lt;STRONG&gt;...&lt;/STRONG&gt;/logs/*access_log&lt;/P&gt;

&lt;P&gt;We tried adding host_segment = 6 to the forwarder stanzas, but then we lose our true "host = unixservername" which is also necessary.  Unfortunately, this information is NOT available anywhere but the source field.&lt;/P&gt;

&lt;P&gt;So....&lt;/P&gt;

&lt;P&gt;We can easily create a search time |rex for Splunk to process to pull the information:&lt;BR /&gt;
|rex field=source "\/path\/to\/apache\/[0-9].[0-9]\/\w+\/(?&lt;WEBSERVER&gt;.*?)\/"&lt;/WEBSERVER&gt;&lt;/P&gt;

&lt;P&gt;This works well...  however, I don't want my users to have to run this every time they search. &lt;/P&gt;

&lt;P&gt;I would like the ability to add this as a Index time or Search time extraction through props and transforms -- preferably at the forwarder or indexer level.  Any suggestions?  Thanks for your help, ideas, and input!  I'm stuck...&lt;/P&gt;

&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2013 14:39:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Field-extraction-from-information-in-field-source/m-p/27525#M4628</guid>
      <dc:creator>zindain24</dc:creator>
      <dc:date>2013-08-07T14:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: Field extraction from information in field=source</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Field-extraction-from-information-in-field-source/m-p/27526#M4629</link>
      <description>&lt;P&gt;Just set up a field extraction as usual - are you familiar with how to do this in props.conf / transforms.conf? If so, it's just like a regular field extraction but you specify &lt;CODE&gt;SOURCE_KEY = (yourfieldhere)&lt;/CODE&gt; (for REPORT style extractions that reference a transforms.conf entry) or &lt;CODE&gt;EXTRACT = &amp;lt;yourregex&amp;gt; in &amp;lt;yourfieldhere&amp;gt;&lt;/CODE&gt; (for EXTRACT style extractions directly in props.conf).&lt;/P&gt;

&lt;P&gt;So for the first case it'd be something like...props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[yoursourcetype]
REPORT-getfieldfromsource = getfieldfromsource
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[getfieldfromsource]
SOURCE_KEY = source
REGEX = /path/to/apache/[0-9]\.[0-9]/\w+/(.*?)/
FORMAT = webserver::$1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or, in the second case, just throw your &lt;CODE&gt;rex&lt;/CODE&gt; statement in almost unaltered into an EXTRACT extraction in props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[yoursourcetype]
EXTRACT-getfieldfromsource = /path/to/apache/[0-9]\.[0-9]/\w+/(?&amp;lt;webserver&amp;gt;.*?)/ in source
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Aug 2013 16:45:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Field-extraction-from-information-in-field-source/m-p/27526#M4629</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-08-07T16:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: Field extraction from information in field=source</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Field-extraction-from-information-in-field-source/m-p/27527#M4630</link>
      <description>&lt;P&gt;Fantastic Ayn,  Thank you for the detailed response!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2013 19:09:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Field-extraction-from-information-in-field-source/m-p/27527#M4630</guid>
      <dc:creator>zindain24</dc:creator>
      <dc:date>2013-08-07T19:09:16Z</dc:date>
    </item>
  </channel>
</rss>

