<?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: Syslog-ng, filter by ip in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Syslog-ng-filter-by-ip/m-p/87446#M18136</link>
    <description>&lt;P&gt;It's worth noting that if you want to override only a few special cases, you may wish to use a transform instead. Take a look at:
&lt;BR /&gt;    
&lt;A rel="nofollow" href="http://answers.splunk.com/questions/5544/override-source-tcpxxxx-of-a-tcp-input-using-transforms"&gt;http://answers.splunk.com/questions/5544/override-source-tcpxxxx-of-a-tcp-input-using-transforms&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you decide to keep Splunk as your listener, you may want to make sure that you have DNS resolution turned on, either through the Manager or by setting &lt;CODE&gt;connection_host = dns&lt;/CODE&gt; in the stanza for port 514 in &lt;CODE&gt;inputs.conf&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;That out of the way,  there are some other advantages to using syslog-ng, and many people consider that a best-practice. In particular, it gives you more freedom to restart Splunk without losing events. &lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;H3&gt;Configuring for use with syslog-ng&lt;/H3&gt;

&lt;P&gt;&lt;/P&gt;&lt;P&gt;What follows is a rough guide to setting it all up. Some options will vary depending on your OS and distribution.&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;P&gt;By default, Splunk will name each source to the path of the syslog-ng logfile on your Splunk server, e.g., source=&lt;CODE&gt;/inputs/syslog/myhost/messages&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;You'll also want to take a look at the syslog-ng Administrators Guide for more detail on the syslog-ng configuration:
&lt;BR /&gt;    
&lt;A rel="nofollow" href="http://www.balabit.com/support/documentation/"&gt;http://www.balabit.com/support/documentation/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;B&gt;Install syslog-ng&lt;/B&gt;&lt;/P&gt;

&lt;P&gt;First, you'll need to actually install syslog-ng using the normal procedure for your OS (&lt;CODE&gt;sudo yum install syslog-ng&lt;/CODE&gt;, or &lt;CODE&gt;sudo apt-get install syslog-ng&lt;/CODE&gt;, or whatever).&lt;/P&gt;

&lt;P&gt;You may need to uninstall or disable your existing syslog daemon before syslog-ng can be used.&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
&lt;B&gt;Configure syslog-ng&lt;/B&gt;&lt;/P&gt;

&lt;P&gt;Then, configure it to listen for incoming messages and save them to individual files based on where the message is coming from.&lt;/P&gt;

&lt;P&gt;Note that this is not a complete configuration - you'll need to merge it with your default config file. Some additional tweaks, like flattening each section to a single line, may be needed if your distribution uses syslog-ng version 3.x.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;# Misc options - use or leave out as desired.
options {
    # Resolve names from /etc/hosts, but don't do DNS lookups
    # Set to 'yes' if you want full DNS (slightly higher risk of DoS and delays)
    use_dns(persist-only);
    dns_cache_hosts(/etc/hosts);

    # Increase the maximum allowed length of an incoming message
    log_msg_size(8192);
}

# Start listening for messages on TCP and UDP ports
source s_remote {
    tcp(ip(0.0.0.0) port(514));
    udp(ip(0.0.0.0) port(514));
}


# Define a destination file or files
# Dumps all entries for that host into one file. Replace 'messages'
# with '$FACILITY' if you want to break out individual syslog facility.
destination d_split_by_host {
    file("/inputs/syslog/$HOST/messages"
        owner("root")
        group("splunk")
        perm(0640)
        dir_perm(0750)
        create_dirs(yes)
    );
}

# Route messages coming in via TCP or UDP sources to the right destination
log { source(s_remote); destination(d_split_by_host); flags(final); };
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;BR /&gt;
&lt;B&gt;Disable Splunk listening on port 514&lt;/B&gt;&lt;/P&gt;

&lt;P&gt;Turn off Splunk's listener on port 514, so that syslog-ng will be able to bind to the port.&lt;/P&gt;

&lt;P&gt;In &lt;CODE&gt;inputs.conf&lt;/CODE&gt; set:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[splunkudp://514]
disabled = true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or just delete the stanza for port 514 altogether.&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
&lt;B&gt;Restart syslog-ng&lt;/B&gt;&lt;/P&gt;

&lt;P&gt;Restart syslog-ng with &lt;CODE&gt;/etc/init.d/syslog-ng restart&lt;/CODE&gt; or equivalent.&lt;/P&gt;

&lt;P&gt;Verify that the syslog daemon is now listening on port 514 (&lt;CODE&gt;sudo netstat -anp | grep 514&lt;/CODE&gt; is one way).&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
&lt;B&gt;Configure Splunk&lt;/B&gt;&lt;/P&gt;

&lt;P&gt;Now, configure Splunk to monitor each directory. In inputs.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[monitor:///inputs/syslog]
disabled = false
host_segment = 3
_blacklist = (.*\.gz$)|(lost+found)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;By using &lt;CODE&gt;host_segment&lt;/CODE&gt;, Splunk will automatically assign the &lt;CODE&gt;host&lt;/CODE&gt; value based on the directory name, which syslog-ng will have created to match the IP address or hostname.&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
&lt;B&gt;Override sourcetypes as needed&lt;/B&gt;&lt;/P&gt;

&lt;P&gt;One of the disadvantages of this approach comes when Splunk fails to automatically recognize the sourcetype of log entries, especially for small files. You can override those as needed in &lt;CODE&gt;props.conf&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[source::.../myfirewall/messages]
sourcetype=cisco_firewall
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;BR /&gt;
&lt;B&gt;Set up Log Rotation&lt;/B&gt;&lt;/P&gt;

&lt;P&gt;At this point, you should be able to start getting data into Splunk, but your log files will grow indefinitely. To prune them, if you are running logrotate, you can create a new file at &lt;CODE&gt;/etc/logrotate.d/inputs-syslog&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/inputs/syslog/*/messages {
    daily
    minsize 10M
    rotate 1
    missingok
    sharedscripts
    postrotate
        /etc/rc.d/init.d/syslog-ng reload 2&amp;amp;gt;/dev/null
    endscript
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You'll need to add additional filenames (not just 'messages') for each syslog facility if you decide to use &lt;CODE&gt;$FACILITY&lt;/CODE&gt; in syslog-ng's configuration.&lt;/P&gt;</description>
    <pubDate>Thu, 11 Nov 2010 05:29:54 GMT</pubDate>
    <dc:creator>southeringtonp</dc:creator>
    <dc:date>2010-11-11T05:29:54Z</dc:date>
    <item>
      <title>Syslog-ng, filter by ip</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Syslog-ng-filter-by-ip/m-p/87445#M18135</link>
      <description>&lt;P&gt;I have some firewalls and stuff like that send logs to my Splunk server (using normal syslog at the moment). For now in "search" there are only one source "udp:514". I would like to filter so it lists all the different source (by ip, or by name i define for the source) I heard that you use syslog-ng for it. I have searched a bit but havt found any real good guides. Can someone push me in the right direction?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Nov 2010 04:06:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Syslog-ng-filter-by-ip/m-p/87445#M18135</guid>
      <dc:creator>fisk12</dc:creator>
      <dc:date>2010-11-11T04:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: Syslog-ng, filter by ip</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Syslog-ng-filter-by-ip/m-p/87446#M18136</link>
      <description>&lt;P&gt;It's worth noting that if you want to override only a few special cases, you may wish to use a transform instead. Take a look at:
&lt;BR /&gt;    
&lt;A rel="nofollow" href="http://answers.splunk.com/questions/5544/override-source-tcpxxxx-of-a-tcp-input-using-transforms"&gt;http://answers.splunk.com/questions/5544/override-source-tcpxxxx-of-a-tcp-input-using-transforms&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you decide to keep Splunk as your listener, you may want to make sure that you have DNS resolution turned on, either through the Manager or by setting &lt;CODE&gt;connection_host = dns&lt;/CODE&gt; in the stanza for port 514 in &lt;CODE&gt;inputs.conf&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;That out of the way,  there are some other advantages to using syslog-ng, and many people consider that a best-practice. In particular, it gives you more freedom to restart Splunk without losing events. &lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;H3&gt;Configuring for use with syslog-ng&lt;/H3&gt;

&lt;P&gt;&lt;/P&gt;&lt;P&gt;What follows is a rough guide to setting it all up. Some options will vary depending on your OS and distribution.&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;P&gt;By default, Splunk will name each source to the path of the syslog-ng logfile on your Splunk server, e.g., source=&lt;CODE&gt;/inputs/syslog/myhost/messages&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;You'll also want to take a look at the syslog-ng Administrators Guide for more detail on the syslog-ng configuration:
&lt;BR /&gt;    
&lt;A rel="nofollow" href="http://www.balabit.com/support/documentation/"&gt;http://www.balabit.com/support/documentation/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;B&gt;Install syslog-ng&lt;/B&gt;&lt;/P&gt;

&lt;P&gt;First, you'll need to actually install syslog-ng using the normal procedure for your OS (&lt;CODE&gt;sudo yum install syslog-ng&lt;/CODE&gt;, or &lt;CODE&gt;sudo apt-get install syslog-ng&lt;/CODE&gt;, or whatever).&lt;/P&gt;

&lt;P&gt;You may need to uninstall or disable your existing syslog daemon before syslog-ng can be used.&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
&lt;B&gt;Configure syslog-ng&lt;/B&gt;&lt;/P&gt;

&lt;P&gt;Then, configure it to listen for incoming messages and save them to individual files based on where the message is coming from.&lt;/P&gt;

&lt;P&gt;Note that this is not a complete configuration - you'll need to merge it with your default config file. Some additional tweaks, like flattening each section to a single line, may be needed if your distribution uses syslog-ng version 3.x.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;# Misc options - use or leave out as desired.
options {
    # Resolve names from /etc/hosts, but don't do DNS lookups
    # Set to 'yes' if you want full DNS (slightly higher risk of DoS and delays)
    use_dns(persist-only);
    dns_cache_hosts(/etc/hosts);

    # Increase the maximum allowed length of an incoming message
    log_msg_size(8192);
}

# Start listening for messages on TCP and UDP ports
source s_remote {
    tcp(ip(0.0.0.0) port(514));
    udp(ip(0.0.0.0) port(514));
}


# Define a destination file or files
# Dumps all entries for that host into one file. Replace 'messages'
# with '$FACILITY' if you want to break out individual syslog facility.
destination d_split_by_host {
    file("/inputs/syslog/$HOST/messages"
        owner("root")
        group("splunk")
        perm(0640)
        dir_perm(0750)
        create_dirs(yes)
    );
}

# Route messages coming in via TCP or UDP sources to the right destination
log { source(s_remote); destination(d_split_by_host); flags(final); };
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;BR /&gt;
&lt;B&gt;Disable Splunk listening on port 514&lt;/B&gt;&lt;/P&gt;

&lt;P&gt;Turn off Splunk's listener on port 514, so that syslog-ng will be able to bind to the port.&lt;/P&gt;

&lt;P&gt;In &lt;CODE&gt;inputs.conf&lt;/CODE&gt; set:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[splunkudp://514]
disabled = true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or just delete the stanza for port 514 altogether.&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
&lt;B&gt;Restart syslog-ng&lt;/B&gt;&lt;/P&gt;

&lt;P&gt;Restart syslog-ng with &lt;CODE&gt;/etc/init.d/syslog-ng restart&lt;/CODE&gt; or equivalent.&lt;/P&gt;

&lt;P&gt;Verify that the syslog daemon is now listening on port 514 (&lt;CODE&gt;sudo netstat -anp | grep 514&lt;/CODE&gt; is one way).&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
&lt;B&gt;Configure Splunk&lt;/B&gt;&lt;/P&gt;

&lt;P&gt;Now, configure Splunk to monitor each directory. In inputs.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[monitor:///inputs/syslog]
disabled = false
host_segment = 3
_blacklist = (.*\.gz$)|(lost+found)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;By using &lt;CODE&gt;host_segment&lt;/CODE&gt;, Splunk will automatically assign the &lt;CODE&gt;host&lt;/CODE&gt; value based on the directory name, which syslog-ng will have created to match the IP address or hostname.&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
&lt;B&gt;Override sourcetypes as needed&lt;/B&gt;&lt;/P&gt;

&lt;P&gt;One of the disadvantages of this approach comes when Splunk fails to automatically recognize the sourcetype of log entries, especially for small files. You can override those as needed in &lt;CODE&gt;props.conf&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[source::.../myfirewall/messages]
sourcetype=cisco_firewall
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;BR /&gt;
&lt;B&gt;Set up Log Rotation&lt;/B&gt;&lt;/P&gt;

&lt;P&gt;At this point, you should be able to start getting data into Splunk, but your log files will grow indefinitely. To prune them, if you are running logrotate, you can create a new file at &lt;CODE&gt;/etc/logrotate.d/inputs-syslog&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/inputs/syslog/*/messages {
    daily
    minsize 10M
    rotate 1
    missingok
    sharedscripts
    postrotate
        /etc/rc.d/init.d/syslog-ng reload 2&amp;amp;gt;/dev/null
    endscript
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You'll need to add additional filenames (not just 'messages') for each syslog facility if you decide to use &lt;CODE&gt;$FACILITY&lt;/CODE&gt; in syslog-ng's configuration.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Nov 2010 05:29:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Syslog-ng-filter-by-ip/m-p/87446#M18136</guid>
      <dc:creator>southeringtonp</dc:creator>
      <dc:date>2010-11-11T05:29:54Z</dc:date>
    </item>
    <item>
      <title>Re: Syslog-ng, filter by ip</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Syslog-ng-filter-by-ip/m-p/87447#M18137</link>
      <description>&lt;P&gt;Thanks very much, much more detail in the answer then i excpected! Works like a charm.&lt;/P&gt;</description>
      <pubDate>Sat, 13 Nov 2010 23:51:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Syslog-ng-filter-by-ip/m-p/87447#M18137</guid>
      <dc:creator>fisk12</dc:creator>
      <dc:date>2010-11-13T23:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: Syslog-ng, filter by ip</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Syslog-ng-filter-by-ip/m-p/87448#M18138</link>
      <description>&lt;P&gt;is it possible to check those configs on ng version 3?&lt;BR /&gt;
Those are really different it seems!&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2011 03:33:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Syslog-ng-filter-by-ip/m-p/87448#M18138</guid>
      <dc:creator>Starlette</dc:creator>
      <dc:date>2011-03-03T03:33:55Z</dc:date>
    </item>
  </channel>
</rss>

