<?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: Can I define the sourcetype in the log itself? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Can-I-define-the-sourcetype-in-the-log-itself/m-p/253162#M48639</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;

&lt;P&gt;Actually you can do this, by adding this code into your logs:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;***SPLUNK*** sourcetype=mysourcetype
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then the forwarder will set the sourcetype dinamically, but as Richard said, you still need (or should) define the way the indexer parses that sourcetype, so you will need to have defined in advance all possible sourcetypes you would want to define dinamically in the log itself.&lt;/P&gt;

&lt;P&gt;Regards&lt;/P&gt;</description>
    <pubDate>Tue, 01 Dec 2015 08:04:21 GMT</pubDate>
    <dc:creator>gfuente</dc:creator>
    <dc:date>2015-12-01T08:04:21Z</dc:date>
    <item>
      <title>Can I define the sourcetype in the log itself?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Can-I-define-the-sourcetype-in-the-log-itself/m-p/253159#M48636</link>
      <description>&lt;P&gt;I happen to have some control over our java logs. Rather than use transforms.conf/props.conf to create various sourcetypes based on the app that is running. Could I simply log out sourcetype in my logs? I believe Splunk will respect it as a KVP. But I don't know if it will really treat it like a sourcetype? &lt;/P&gt;

&lt;P&gt;thanks, &lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2015 18:43:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Can-I-define-the-sourcetype-in-the-log-itself/m-p/253159#M48636</guid>
      <dc:creator>daniel333</dc:creator>
      <dc:date>2015-11-30T18:43:01Z</dc:date>
    </item>
    <item>
      <title>Re: Can I define the sourcetype in the log itself?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Can-I-define-the-sourcetype-in-the-log-itself/m-p/253160#M48637</link>
      <description>&lt;P&gt;Splunk uses sourcetypes to know how to parse logs.  Without a sourcetype, how will Splunk know how to parse your log to find the sourcetype?  Why needlessly index and store another KVP in your events? I'm not saying it can't be done, just that you're probably not saving yourself anything.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2015 19:21:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Can-I-define-the-sourcetype-in-the-log-itself/m-p/253160#M48637</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-11-30T19:21:14Z</dc:date>
    </item>
    <item>
      <title>Re: Can I define the sourcetype in the log itself?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Can-I-define-the-sourcetype-in-the-log-itself/m-p/253161#M48638</link>
      <description>&lt;P&gt;I agree with @richgalloway that you gain little by doing this. If you want to take control of your logs, it would be better to implement a naming convention for the log files and directories.  Then you could easily assign the sourcetype at input time.&lt;/P&gt;

&lt;P&gt;In particular, if you group log files of the same sourcetype into the same directory, you can make entries in the &lt;CODE&gt;inputs.conf&lt;/CODE&gt; like this example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[monitor:///var/log/access_combined/]
sourcetype=access_combined
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Assigning the sourcetype in &lt;CODE&gt;inputs.conf&lt;/CODE&gt; is the most efficient way to set the sourcetype. Another alternative (about as efficient) is to include the sourcetype name in the file name. For example: if you had an Apache log named xyz, you could instead name it &lt;CODE&gt;xyz_access_combined.log&lt;/CODE&gt;&lt;BR /&gt;
Then you could make the following entry in &lt;CODE&gt;props.conf&lt;/CODE&gt; for each sourcetype&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[source::*access_combined.log]
sourcetype=access_combined
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can certainly add something to your log files. You could even use &lt;CODE&gt;transforms.conf&lt;/CODE&gt; to create a transform that assigns the sourcetype to each event based on that value - but this is &lt;EM&gt;very inefficient&lt;/EM&gt;! It will significantly slow the indexing of the data as the sourcetype will have to be extracted and assigned to each event, rather than to the entire file at once.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2015 07:36:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Can-I-define-the-sourcetype-in-the-log-itself/m-p/253161#M48638</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2015-12-01T07:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: Can I define the sourcetype in the log itself?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Can-I-define-the-sourcetype-in-the-log-itself/m-p/253162#M48639</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;

&lt;P&gt;Actually you can do this, by adding this code into your logs:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;***SPLUNK*** sourcetype=mysourcetype
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then the forwarder will set the sourcetype dinamically, but as Richard said, you still need (or should) define the way the indexer parses that sourcetype, so you will need to have defined in advance all possible sourcetypes you would want to define dinamically in the log itself.&lt;/P&gt;

&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2015 08:04:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Can-I-define-the-sourcetype-in-the-log-itself/m-p/253162#M48639</guid>
      <dc:creator>gfuente</dc:creator>
      <dc:date>2015-12-01T08:04:21Z</dc:date>
    </item>
  </channel>
</rss>

