<?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 Extracting field from source for indexing in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extracting-field-from-source-for-indexing/m-p/48684#M11618</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have to add a field which has to be indexed along with the default fields. I can pick up the value from the Source directory name in the monitored path.&lt;/P&gt;

&lt;P&gt;For e.g.:
inputs.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[monitor://c:\splunk-data\...\*]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want the new field 'project_number' value from the directory replacing ... (There are a lot of values for 'project' and all the queries will use the 'project' as a filter, so its better indexed)&lt;/P&gt;

&lt;P&gt;The problem is I'm not able to extract the field name from the Source. Following is teh configuration files in my app.&lt;/P&gt;

&lt;P&gt;fields.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[project_number]
INDEX = True
INDEXED_VALUE = False
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[mysourcetype]
EXTRACT-...
TRANSFORM-FIELDS = get_project_num
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SOURCE_KEY = Metadata:Source
REGEX = C:\\splunk\-data\\([0-9\-]*)\\([0-9\-]*)
FORMAT = project_number::"$1"
WRITE_META=true 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The monitor is picking up the new files as I add to test, but the project_number field is never populated.&lt;/P&gt;

&lt;P&gt;Please let me know if I'm missing something.&lt;/P&gt;

&lt;P&gt;Thank you,
Krishna&lt;/P&gt;</description>
    <pubDate>Sun, 12 Sep 2010 19:29:48 GMT</pubDate>
    <dc:creator>Krishna_R</dc:creator>
    <dc:date>2010-09-12T19:29:48Z</dc:date>
    <item>
      <title>Extracting field from source for indexing</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-field-from-source-for-indexing/m-p/48684#M11618</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have to add a field which has to be indexed along with the default fields. I can pick up the value from the Source directory name in the monitored path.&lt;/P&gt;

&lt;P&gt;For e.g.:
inputs.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[monitor://c:\splunk-data\...\*]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want the new field 'project_number' value from the directory replacing ... (There are a lot of values for 'project' and all the queries will use the 'project' as a filter, so its better indexed)&lt;/P&gt;

&lt;P&gt;The problem is I'm not able to extract the field name from the Source. Following is teh configuration files in my app.&lt;/P&gt;

&lt;P&gt;fields.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[project_number]
INDEX = True
INDEXED_VALUE = False
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[mysourcetype]
EXTRACT-...
TRANSFORM-FIELDS = get_project_num
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SOURCE_KEY = Metadata:Source
REGEX = C:\\splunk\-data\\([0-9\-]*)\\([0-9\-]*)
FORMAT = project_number::"$1"
WRITE_META=true 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The monitor is picking up the new files as I add to test, but the project_number field is never populated.&lt;/P&gt;

&lt;P&gt;Please let me know if I'm missing something.&lt;/P&gt;

&lt;P&gt;Thank you,
Krishna&lt;/P&gt;</description>
      <pubDate>Sun, 12 Sep 2010 19:29:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-field-from-source-for-indexing/m-p/48684#M11618</guid>
      <dc:creator>Krishna_R</dc:creator>
      <dc:date>2010-09-12T19:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting field from source for indexing</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-field-from-source-for-indexing/m-p/48685#M11619</link>
      <description>&lt;P&gt;I think you need to include the [get_project_num] stanza in your transforms.conf. Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[get_project_num]
SOURCE_KEY = MetaData:Source
REGEX = C:\splunk-data\([0-9-])\([0-9-])
FORMAT = project_number::"$1"
WRITE_META = true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I think your regex may be off too. In your inputs.conf, you're monitoring "c:\splunk-data...*". But your transforms.conf regex includes a slash after c:\splunk-data. That may be correct, but it looks inconsistent with what you typed as your inputs.conf example.&lt;/P&gt;

&lt;P&gt;Anyways, I hope this helped. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Sep 2010 21:08:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-field-from-source-for-indexing/m-p/48685#M11619</guid>
      <dc:creator>Branden</dc:creator>
      <dc:date>2010-09-12T21:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting field from source for indexing</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-field-from-source-for-indexing/m-p/48686#M11620</link>
      <description>&lt;P&gt;Hey Branden, thanks for your reply, missed to reply yesterday. I have to use the extra slash for escaping the slash - as with standard regex. Otherwise there are varying error messages...&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2010 11:01:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-field-from-source-for-indexing/m-p/48686#M11620</guid>
      <dc:creator>Krishna_R</dc:creator>
      <dc:date>2010-09-14T11:01:54Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting field from source for indexing</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-field-from-source-for-indexing/m-p/48687#M11621</link>
      <description>&lt;P&gt;[project_number]&lt;BR /&gt;
INDEX = True&lt;BR /&gt;
INDEXED_VALUE = False&lt;/P&gt;

&lt;P&gt;this should be sufficient: &lt;/P&gt;

&lt;P&gt;[project_number]&lt;BR /&gt;
INDEXED = True&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 10:22:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-field-from-source-for-indexing/m-p/48687#M11621</guid>
      <dc:creator>drrushi_splunk</dc:creator>
      <dc:date>2020-09-28T10:22:47Z</dc:date>
    </item>
  </channel>
</rss>

