<?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 Mystery in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Mystery/m-p/45093#M10648</link>
    <description>&lt;P&gt;In My case i use this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=source "basefolder\\\\(?&amp;lt;path&amp;gt;(\w+\\\\)+)(?&amp;lt;filename&amp;gt;.*).log" |  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Obtaining both the filepath and the filename. For your example I'd do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=source "helloworld\\\\(?&amp;lt;path&amp;gt;(\w+\\\\)+)TheWord-(?&amp;lt;filename&amp;gt;.*).log" |  
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 08 Sep 2010 00:03:36 GMT</pubDate>
    <dc:creator>hbazan</dc:creator>
    <dc:date>2010-09-08T00:03:36Z</dc:date>
    <item>
      <title>Field Extraction Mystery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Mystery/m-p/45090#M10645</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;

&lt;P&gt;I would like to use field extraction at search time to do the following:&lt;/P&gt;

&lt;P&gt;My source field in Splunk contains file paths. Each file path has a word that I want to extract from it and place into another field.&lt;/P&gt;

&lt;P&gt;E.g. Source field contains a file path \helloworld\welcome\TheWord-uvwxyz.1234.log
The word I want to extract is uvwxyz.&lt;/P&gt;

&lt;P&gt;How can I achieve this? Is there a way of doing this using props.conf and/or transforms.conf?&lt;/P&gt;

&lt;P&gt;N.B. I do not want to extract data from _raw but from the field named source.&lt;/P&gt;

&lt;P&gt;Thanks in advance for your help&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2010 23:35:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Mystery/m-p/45090#M10645</guid>
      <dc:creator>Ant1D</dc:creator>
      <dc:date>2010-09-07T23:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: Field Extraction Mystery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Mystery/m-p/45091#M10646</link>
      <description>&lt;P&gt;During your search, you can do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.. | eval extracted=ltrim(source,"\helloworld\welcome\TheWord-") | eval extracted=rtrim(extracted,".1234.log")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Sep 2010 23:42:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Mystery/m-p/45091#M10646</guid>
      <dc:creator>Brian_Osburn</dc:creator>
      <dc:date>2010-09-07T23:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: Field Extraction Mystery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Mystery/m-p/45092#M10647</link>
      <description>&lt;P&gt;Would this allow me to populate another field with the extracted words? If so, would I have to keep running this search each time I want to populate another field with this data?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2010 23:58:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Mystery/m-p/45092#M10647</guid>
      <dc:creator>Ant1D</dc:creator>
      <dc:date>2010-09-07T23:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: Field Extraction Mystery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Mystery/m-p/45093#M10648</link>
      <description>&lt;P&gt;In My case i use this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=source "basefolder\\\\(?&amp;lt;path&amp;gt;(\w+\\\\)+)(?&amp;lt;filename&amp;gt;.*).log" |  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Obtaining both the filepath and the filename. For your example I'd do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=source "helloworld\\\\(?&amp;lt;path&amp;gt;(\w+\\\\)+)TheWord-(?&amp;lt;filename&amp;gt;.*).log" |  
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Sep 2010 00:03:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Mystery/m-p/45093#M10648</guid>
      <dc:creator>hbazan</dc:creator>
      <dc:date>2010-09-08T00:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: Field Extraction Mystery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Mystery/m-p/45094#M10649</link>
      <description>&lt;P&gt;it would extract the field "extracted" with what ever it matched.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2010 00:24:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Mystery/m-p/45094#M10649</guid>
      <dc:creator>Brian_Osburn</dc:creator>
      <dc:date>2010-09-08T00:24:24Z</dc:date>
    </item>
    <item>
      <title>Re: Field Extraction Mystery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Mystery/m-p/45095#M10650</link>
      <description>&lt;P&gt;This will be easier to deal with if you define a permanent extraction.&lt;/P&gt;

&lt;P&gt;In &lt;B&gt;transforms.conf&lt;/B&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[extract-filename]
SOURCE_KEY = source
REGEX = TheWord-([^\.]+)
FORMAT = filename::$1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In &lt;B&gt;props.conf&lt;/B&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[yoursourcetype]
REPORT-filename = extract-filename
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Tweak the regex to your liking. Change the &lt;CODE&gt;[yoursourcetype]&lt;/CODE&gt; heading to &lt;CODE&gt;[host::yourhost]&lt;/CODE&gt; or &lt;CODE&gt;[source::yoursource]&lt;/CODE&gt; as needed.&lt;/P&gt;

&lt;P&gt;The fact that you are extracting from &lt;CODE&gt;source&lt;/CODE&gt; is something of a special case, since you can be sure of having that field already populated in the index. &lt;/P&gt;

&lt;P&gt;If your first field is not &lt;CODE&gt;host&lt;/CODE&gt;, &lt;CODE&gt;source&lt;/CODE&gt;, or &lt;CODE&gt;sourcetype&lt;/CODE&gt;, then you also need to make sure that your field extractions are called in the correct order -- naming becomes important. For example &lt;CODE&gt;REPORT-000-fullpath&lt;/CODE&gt; and &lt;CODE&gt;REPORT-999-filename&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2010 02:57:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Mystery/m-p/45095#M10650</guid>
      <dc:creator>southeringtonp</dc:creator>
      <dc:date>2010-10-20T02:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: Field Extraction Mystery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Mystery/m-p/45096#M10651</link>
      <description>&lt;P&gt;Thanks for the info southeringtonp. I will give this a test and let you know the results.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2010 15:41:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Mystery/m-p/45096#M10651</guid>
      <dc:creator>Ant1D</dc:creator>
      <dc:date>2010-10-20T15:41:39Z</dc:date>
    </item>
  </channel>
</rss>

