<?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: Searching on fields extracted from Source field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Searching-on-fields-extracted-from-Source-field/m-p/103770#M26818</link>
    <description>&lt;P&gt;The reason this happens is that a query for &lt;CODE&gt;fname="val"&lt;/CODE&gt; on an search-time extracted field &lt;CODE&gt;fname&lt;/CODE&gt; is internally converted to a search for &lt;CODE&gt;("val" AND fname="val")&lt;/CODE&gt; which first searches only for events containing the token &lt;CODE&gt;val&lt;/CODE&gt; in the raw data. Unfortunately, your extracted field is not in the raw data, so the desired events don't come back.&lt;/P&gt;</description>
    <pubDate>Mon, 13 Dec 2010 10:10:02 GMT</pubDate>
    <dc:creator>gkanapathy</dc:creator>
    <dc:date>2010-12-13T10:10:02Z</dc:date>
    <item>
      <title>Searching on fields extracted from Source field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-on-fields-extracted-from-Source-field/m-p/103768#M26816</link>
      <description>&lt;P&gt;I have multiple application environments on one host, and need to identify the environment based on the directory path in the source log file.&lt;/P&gt;

&lt;P&gt;Using a regex in the search works fine, like so&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="gfstats" | rex field=source "[\w\W/]+/gf-(?&amp;lt;env&amp;gt;[^\.]+)\.log" | search env="app1"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But I would like to define the environment as a field I can use in other searches.&lt;/P&gt;

&lt;P&gt;I added a line to props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EXTRACT-sourcefields = (?&amp;lt;logdir&amp;gt;[\w\W/]+)/gf-(?&amp;lt;environment&amp;gt;[^\.]+)\.log in source
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But although I can now see the content of the environment field when I perform searches, I cannot use that field in searches.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="gfstats" environment="app1"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;returns no results.  Why?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Dec 2010 08:49:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-on-fields-extracted-from-Source-field/m-p/103768#M26816</guid>
      <dc:creator>oliverw</dc:creator>
      <dc:date>2010-12-13T08:49:58Z</dc:date>
    </item>
    <item>
      <title>Re: Searching on fields extracted from Source field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-on-fields-extracted-from-Source-field/m-p/103769#M26817</link>
      <description>&lt;P&gt;We do practically the same thing for some of our apps.  For this to work via props.conf / transforms.conf you have to set up "environment" as an indexed field. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(props.conf)
[mysourcetype]
TRANSFORMS-env=environment

(transforms.conf)
[environment]
SOURCE_KEY=MetaData:Source
REGEX=/path/to/app/([^/]+)/log/.*\.log
FORMAT=environment::$1
WRITE_META=true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This works, but all of the usual caveats related to indexed fields apply.  Something just as good might be achievable with eventtypes, but I've not tried it to see.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Dec 2010 09:56:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-on-fields-extracted-from-Source-field/m-p/103769#M26817</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2010-12-13T09:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: Searching on fields extracted from Source field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-on-fields-extracted-from-Source-field/m-p/103770#M26818</link>
      <description>&lt;P&gt;The reason this happens is that a query for &lt;CODE&gt;fname="val"&lt;/CODE&gt; on an search-time extracted field &lt;CODE&gt;fname&lt;/CODE&gt; is internally converted to a search for &lt;CODE&gt;("val" AND fname="val")&lt;/CODE&gt; which first searches only for events containing the token &lt;CODE&gt;val&lt;/CODE&gt; in the raw data. Unfortunately, your extracted field is not in the raw data, so the desired events don't come back.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Dec 2010 10:10:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-on-fields-extracted-from-Source-field/m-p/103770#M26818</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2010-12-13T10:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: Searching on fields extracted from Source field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-on-fields-extracted-from-Source-field/m-p/103771#M26819</link>
      <description>&lt;P&gt;You can add the field in fields.conf&lt;/P&gt;

&lt;P&gt;[environment]
INDEXED = false
INDEX_VALUE = false&lt;/P&gt;

&lt;P&gt;Settings INDEX_VALUE to false should prevent the search to be expanded to "val" AND fname="val"&lt;/P&gt;</description>
      <pubDate>Mon, 07 Feb 2011 22:19:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-on-fields-extracted-from-Source-field/m-p/103771#M26819</guid>
      <dc:creator>wollinet</dc:creator>
      <dc:date>2011-02-07T22:19:02Z</dc:date>
    </item>
  </channel>
</rss>

