<?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 Field names from file, including source and host in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Field-names-from-file-including-source-and-host/m-p/21510#M3537</link>
    <description>&lt;P&gt;I've written an application that outputs data that I would like to index.  Of course, I have a series of requirements.&lt;/P&gt;

&lt;P&gt;First, I'd like to extract the host and the sourcetype from the file.&lt;BR /&gt;
I am reading &lt;A href="http://www.splunk.com/base/Documentation/4.1.8/Admin/Advancedsourcetypeoverrides"&gt;http://www.splunk.com/base/Documentation/4.1.8/Admin/Advancedsourcetypeoverrides&lt;/A&gt;&lt;BR /&gt;
on how to achieve this, but haven't succeeded.&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[source::Z:\ServerInput]
TRANSFORMS-changesrchost=SrvMonsource,SrvMonHost
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[SrvMonSource]
DEST_KEY = MetaData:Sourcetype
REGEX = Source: (.+)
FORMAT = sourcetype::$1

[SrvMonHost]
REGEX = Host: (.+)
FORMAT = host::$1
DEST_KEY = MetaData:Host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Secondly, I'd like to extract the field names from the fields in the file.  The file format looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Host: L-JGAUTHIER
Source: OSInfo
BootDevice: \Device\HarddiskVolume2
BuildNumber: 7600
BuildType: Multiprocessor Free
Caption: Microsoft Windows 7 Enterprise 
CodeSet: 1252
CountryCode: 1
CreationClassName: Win32_OperatingSystem
CSCreationClassName: Win32_ComputerSystem
CSDVersion: 
CSName: L-JGAUTHIER
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And lastly, I want to delete the file once it's indexed.  I can probably use the spool directory for this, but I'm not sure yet if that will work since I am not sure if I can make that a source or not in my application (in props.conf).&lt;/P&gt;

&lt;P&gt;Thanks for any pointers.&lt;/P&gt;</description>
    <pubDate>Thu, 02 Jun 2011 19:43:14 GMT</pubDate>
    <dc:creator>jgauthier</dc:creator>
    <dc:date>2011-06-02T19:43:14Z</dc:date>
    <item>
      <title>Field names from file, including source and host</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-names-from-file-including-source-and-host/m-p/21510#M3537</link>
      <description>&lt;P&gt;I've written an application that outputs data that I would like to index.  Of course, I have a series of requirements.&lt;/P&gt;

&lt;P&gt;First, I'd like to extract the host and the sourcetype from the file.&lt;BR /&gt;
I am reading &lt;A href="http://www.splunk.com/base/Documentation/4.1.8/Admin/Advancedsourcetypeoverrides"&gt;http://www.splunk.com/base/Documentation/4.1.8/Admin/Advancedsourcetypeoverrides&lt;/A&gt;&lt;BR /&gt;
on how to achieve this, but haven't succeeded.&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[source::Z:\ServerInput]
TRANSFORMS-changesrchost=SrvMonsource,SrvMonHost
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[SrvMonSource]
DEST_KEY = MetaData:Sourcetype
REGEX = Source: (.+)
FORMAT = sourcetype::$1

[SrvMonHost]
REGEX = Host: (.+)
FORMAT = host::$1
DEST_KEY = MetaData:Host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Secondly, I'd like to extract the field names from the fields in the file.  The file format looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Host: L-JGAUTHIER
Source: OSInfo
BootDevice: \Device\HarddiskVolume2
BuildNumber: 7600
BuildType: Multiprocessor Free
Caption: Microsoft Windows 7 Enterprise 
CodeSet: 1252
CountryCode: 1
CreationClassName: Win32_OperatingSystem
CSCreationClassName: Win32_ComputerSystem
CSDVersion: 
CSName: L-JGAUTHIER
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And lastly, I want to delete the file once it's indexed.  I can probably use the spool directory for this, but I'm not sure yet if that will work since I am not sure if I can make that a source or not in my application (in props.conf).&lt;/P&gt;

&lt;P&gt;Thanks for any pointers.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2011 19:43:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-names-from-file-including-source-and-host/m-p/21510#M3537</guid>
      <dc:creator>jgauthier</dc:creator>
      <dc:date>2011-06-02T19:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: Field names from file, including source and host</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-names-from-file-including-source-and-host/m-p/21511#M3538</link>
      <description>&lt;P&gt;jgauthier,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;1.  Having your inputs.conf would be helpful.  Is the source file "ServerInput" or "ServerInput\&amp;lt;somefile&amp;gt;"?
2.  Try:
## props.conf
[source::&amp;lt;source&amp;gt;]
KV_MODE = None
REPORT-auto_kv_for_my_source = auto_kv_for_my_source

## transforms.conf
[auto_kv_for_my_source]
REGEX = ^(\S+):(?:\s+)?(.+)
FORMAT = $1::$2
MV_ADD = True

3.  Use the batch input instead of the monitor input.
[batch://&amp;lt;path&amp;gt;]
* One time, destructive input of files in &amp;lt;path&amp;gt;.
* For continuous, non-destructive inputs of files, use monitor instead.

# Additional attributes:

move_policy = sinkhole
* IMPORTANT: This attribute/value pair is required. You *must* include "move_policy = sinkhole" when defining batch inputs.
* This loads the file destructively.  
* Do not use the batch input type for files you do not want to consume destructively.

host_regex = see MONITOR, above.
host_segment = see MONITOR, above.
crcSalt = see MONITOR, above.

# IMPORTANT: The following attribute is not used by batch:
# source = &amp;lt;string&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Jun 2011 21:44:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-names-from-file-including-source-and-host/m-p/21511#M3538</guid>
      <dc:creator>hazekamp</dc:creator>
      <dc:date>2011-06-02T21:44:21Z</dc:date>
    </item>
    <item>
      <title>Re: Field names from file, including source and host</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-names-from-file-including-source-and-host/m-p/21512#M3539</link>
      <description>&lt;P&gt;I was able to achieve all aspects of what I wanted.&lt;/P&gt;

&lt;P&gt;First, my inputs.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[batch://Z:\ServerInput]
disabled=0
recursive=false
sourcetype=SrvMon
move_policy = sinkhole
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This implemented the sinkhole I wanted.&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[SrvMon]
TRANSFORMS-metadata=SrvMonHost,SrvMonSource
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Transforms.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[SrvMonSource]
DEST_KEY = MetaData:Sourcetype
REGEX = Source=(.+)
FORMAT = sourcetype::$1

[SrvMonHost]
REGEX = Host=(.+)
FORMAT = host::$1
DEST_KEY = MetaData:Host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And lastly, I changed my field format to be "Field=Data" so splunk picked up the key/value pair automatically.&lt;/P&gt;

&lt;P&gt;Working great!&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2011 14:23:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-names-from-file-including-source-and-host/m-p/21512#M3539</guid>
      <dc:creator>jgauthier</dc:creator>
      <dc:date>2011-06-03T14:23:39Z</dc:date>
    </item>
  </channel>
</rss>

