<?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 Forwarding based on both host and sourcetype in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Forwarding-based-on-both-host-and-sourcetype/m-p/64097#M12883</link>
    <description>&lt;P&gt;We would like to forward some data from our Splunk indexer to various third party destinations based on the host and sourcetype of the data. The Splunk documentation explains how to configure forwarding for a particular host, sourcetype, or source, but not for a combination such as host and source. How can it be done?&lt;/P&gt;

&lt;P&gt;For example, suppose we want to forward logs from two hosts, &lt;EM&gt;host1&lt;/EM&gt; and &lt;EM&gt;host2.&lt;/EM&gt; We only want to forward sourcetypes &lt;EM&gt;log4j&lt;/EM&gt; and &lt;EM&gt;syslog.&lt;/EM&gt; This table shows the desired host:port destinations for various combinations of log host and sourcetype:&lt;/P&gt;

&lt;TABLE&gt;
&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD align="center"&gt;&lt;B&gt;log4j&lt;/B&gt;&lt;/TD&gt;&lt;TD align="center"&gt;&lt;B&gt;syslog&lt;/B&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;&lt;TD&gt;&lt;B&gt;host1&lt;/B&gt;&lt;/TD&gt;&lt;TD&gt;dest1:4001&lt;/TD&gt;&lt;TD&gt;dest2:4002&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;&lt;TD&gt;&lt;B&gt;host2&lt;/B&gt;&lt;/TD&gt;&lt;TD&gt;dest3:5001&lt;/TD&gt;&lt;TD&gt;dest4:5002&lt;/TD&gt;&lt;/TR&gt;
&lt;/TBODY&gt;&lt;/TABLE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;The documentation for &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Deploy/Routeandfilterdatad"&gt;routing and filtering data&lt;/A&gt; explains how the props.conf stanza names specify the filtering:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;&lt;EM&gt;sourcetype&lt;/EM&gt; — the source type of an event&lt;/LI&gt;
&lt;LI&gt;host::&lt;EM&gt;host&lt;/EM&gt; — where &lt;EM&gt;host&lt;/EM&gt; is the host for an event&lt;/LI&gt;
&lt;LI&gt;source::&lt;EM&gt;source&lt;/EM&gt; — where &lt;EM&gt;source&lt;/EM&gt; is the source for an event &lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;How can a props.conf stanza name combine the notation for sourcetype and host?&lt;/P&gt;</description>
    <pubDate>Wed, 30 May 2012 19:02:55 GMT</pubDate>
    <dc:creator>joelshprentz</dc:creator>
    <dc:date>2012-05-30T19:02:55Z</dc:date>
    <item>
      <title>Forwarding based on both host and sourcetype</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Forwarding-based-on-both-host-and-sourcetype/m-p/64097#M12883</link>
      <description>&lt;P&gt;We would like to forward some data from our Splunk indexer to various third party destinations based on the host and sourcetype of the data. The Splunk documentation explains how to configure forwarding for a particular host, sourcetype, or source, but not for a combination such as host and source. How can it be done?&lt;/P&gt;

&lt;P&gt;For example, suppose we want to forward logs from two hosts, &lt;EM&gt;host1&lt;/EM&gt; and &lt;EM&gt;host2.&lt;/EM&gt; We only want to forward sourcetypes &lt;EM&gt;log4j&lt;/EM&gt; and &lt;EM&gt;syslog.&lt;/EM&gt; This table shows the desired host:port destinations for various combinations of log host and sourcetype:&lt;/P&gt;

&lt;TABLE&gt;
&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD align="center"&gt;&lt;B&gt;log4j&lt;/B&gt;&lt;/TD&gt;&lt;TD align="center"&gt;&lt;B&gt;syslog&lt;/B&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;&lt;TD&gt;&lt;B&gt;host1&lt;/B&gt;&lt;/TD&gt;&lt;TD&gt;dest1:4001&lt;/TD&gt;&lt;TD&gt;dest2:4002&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;&lt;TD&gt;&lt;B&gt;host2&lt;/B&gt;&lt;/TD&gt;&lt;TD&gt;dest3:5001&lt;/TD&gt;&lt;TD&gt;dest4:5002&lt;/TD&gt;&lt;/TR&gt;
&lt;/TBODY&gt;&lt;/TABLE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;The documentation for &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Deploy/Routeandfilterdatad"&gt;routing and filtering data&lt;/A&gt; explains how the props.conf stanza names specify the filtering:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;&lt;EM&gt;sourcetype&lt;/EM&gt; — the source type of an event&lt;/LI&gt;
&lt;LI&gt;host::&lt;EM&gt;host&lt;/EM&gt; — where &lt;EM&gt;host&lt;/EM&gt; is the host for an event&lt;/LI&gt;
&lt;LI&gt;source::&lt;EM&gt;source&lt;/EM&gt; — where &lt;EM&gt;source&lt;/EM&gt; is the source for an event &lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;How can a props.conf stanza name combine the notation for sourcetype and host?&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2012 19:02:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Forwarding-based-on-both-host-and-sourcetype/m-p/64097#M12883</guid>
      <dc:creator>joelshprentz</dc:creator>
      <dc:date>2012-05-30T19:02:55Z</dc:date>
    </item>
    <item>
      <title>Re: Forwarding based on both host and sourcetype</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Forwarding-based-on-both-host-and-sourcetype/m-p/64098#M12884</link>
      <description>&lt;P&gt;It can't. The only way I can think is to do multiple transforms.&lt;/P&gt;

&lt;P&gt;outputs.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[syslog:dest1]
server = dest1:4001
[syslog:dest3]
server = dest3:5001
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[log4j]
TRANSFORMS-route-host1 = rt-log4j-host1
TRANSFORMS-route-host2 = rt-log4j-host2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[rt-log4j-host1]
SOURCE_KEY = host
DEST_KEY = _SYSLOG_ROUTING
REGEX = host1
FORMAT = dest1

[rt-log4j-host2]
SOURCE_KEY = host
DEST_KEY = _SYSLOG_ROUTING
REGEX = host2
FORMAT = dest3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And similar for the &lt;CODE&gt;syslog&lt;/CODE&gt; sourcetype.&lt;/P&gt;</description>
      <pubDate>Thu, 31 May 2012 06:12:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Forwarding-based-on-both-host-and-sourcetype/m-p/64098#M12884</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2012-05-31T06:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: Forwarding based on both host and sourcetype</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Forwarding-based-on-both-host-and-sourcetype/m-p/64099#M12885</link>
      <description>&lt;P&gt;The excellent response from gkanapathy needed a few changes to work in our Splunk 4.3.1 installation. The hardest part was discovering the SOURCE_KEY for hosts; it is &lt;STRONG&gt;&lt;CODE&gt;MetaData:Host&lt;/CODE&gt;&lt;/STRONG&gt;. &lt;/P&gt;

&lt;P&gt;Here are the resulting configuration stanzas ...&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;outputs.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[tcpout]
indexAndForward = true
defaultGroup = nothing

[tcpout:nothing]
disabled = false
server = falsefoo.bar.com:9998
dropEventsOnQueueFull = 1

[tcpout:dest-host1-log4j]
server = dest1:6001
sendCookedData = false

[tcpout:dest-host1-syslog]
server = dest1:6002
sendCookedData = false

[tcpout:dest-host2-log4j]
server = dest1:6003
sendCookedData = false

[tcpout:dest-host2-syslog]
server = dest1:6004
sendCookedData = false
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Changes:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;Send logs via TCP instead of syslog.&lt;/LI&gt;
&lt;LI&gt;Force raw format for our third-party destination.&lt;/LI&gt;
&lt;LI&gt;Index locally in addition to forwarding.&lt;/LI&gt;
&lt;LI&gt;Forward only logs for the designated hosts and source types.&lt;/LI&gt;
&lt;LI&gt;Worked around for bug SPL-50576 in Splunk 4.3.1 and 4.3.2. See &lt;A href="http://splunk-base.splunk.com/answers/46760/documented-recipe-for-replicating-subsets-of-data-to-3rd-party-system-throws-errors-in-431-and-432"&gt;this answer&lt;/A&gt;.&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;&lt;STRONG&gt;props.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[log4j]
TRANSFORMS-transform-host1-log4j = route-host1-log4j
TRANSFORMS-transform-host2-log4j = route-host2-log4j

[syslog]
TRANSFORMS-transform-host1-syslog = route-host1-syslog
TRANSFORMS-transform-host2-syslog = route-host2-syslog
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Unchanged.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;transforms.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[route-host1-log4j]
SOURCE_KEY = MetaData:Host
REGEX = host1
DEST_KEY = _TCP_ROUTING
FORMAT = dest-host1-log4j

[route-host1-syslog]
SOURCE_KEY = MetaData:Host
REGEX = host1
DEST_KEY = _TCP_ROUTING
FORMAT = dest-host1-syslog

[route-host2-log4j]
SOURCE_KEY = MetaData:Host
REGEX = host2
DEST_KEY = _TCP_ROUTING
FORMAT = dest-host2-log4j

[route-host2-syslog]
SOURCE_KEY = MetaData:Host
REGEX = host2
DEST_KEY = _TCP_ROUTING
FORMAT = dest-host2-syslog
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Changes:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;Send logs via TCP instead of syslog.&lt;/LI&gt;
&lt;LI&gt;Use the documented SOURCE_KEY for the host.&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Fri, 08 Jun 2012 15:49:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Forwarding-based-on-both-host-and-sourcetype/m-p/64099#M12885</guid>
      <dc:creator>joelshprentz</dc:creator>
      <dc:date>2012-06-08T15:49:09Z</dc:date>
    </item>
  </channel>
</rss>

