Getting Data In

Re: Syslog-NG Configuration: Review & Advise

0xAli
Path Finder

Hi All,

I want to share with you the Syslog-NG configuration, you can review and advise.

[+] Syslog-ng Preparation
============================================
Check SELinux status
getenforce

sudo mkdir -p /var/log/syslog
sudo chown -R splunk:splunk /var/log/syslog
sudo chmod 750 /var/log/syslog

sudo tee /etc/sysctl.d/99-syslog-ng.conf > /dev/null << 'EOF'
# Syslog-ng UDP receive buffer tuning
net.core.rmem_max = 33554432
net.core.rmem_default = 16777216
net.core.netdev_max_backlog = 5000

# TCP keepalive - fast dead-peer detection after keepalived VIP failover
net.ipv4.tcp_keepalive_time = 120
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_keepalive_probes = 5
EOF


sudo sysctl --system
sudo sysctl net.core.rmem_max net.core.rmem_default net.core.netdev_max_backlog net.ipv4.tcp_keepalive_time

============================================
[+] Syslog-NG Configuration
===========================

sudo tee /etc/syslog-ng/conf.d/data_sources.conf > /dev/null << 'EOF'
###############################################################################
# GLOBAL OPTIONS
###############################################################################

options {
    log-fifo-size(200000);
    threaded(yes);
    use-dns(no);
    dns-cache(no);
	keep-hostname(no);
    chain-hostname(no);
    log-msg-size(65536);
};

###############################################################################
# RAW MESSAGE TEMPLATE
###############################################################################

template t_raw {
    template("$MSG\n");
    template_escape(no);
};

###############################################################################
# TCP SOURCES
###############################################################################
# FortiGate - TCP 1515
source s_fortigate {
    network(
        ip(0.0.0.0)
        transport(tcp)
        port(1515)
        flags(no-parse, flow-control)
        max-connections(100)
        log-iw-size(10000)
        so-keepalive(yes)
        so-rcvbuf(1048576)
    );
};

###############################################################################
# UDP SOURCES
###############################################################################
# F5 WAF - UDP 2514
source s_f5waf {
    network(
        ip(0.0.0.0)
        transport(udp)
        port(2514)
        flags(no-parse)
        so-rcvbuf(4194304)
    );
};

###############################################################################
# TCP DESTINATIONS
###############################################################################
# FortiGate
destination d_fortigate {
    file(
        "/var/log/syslog/fortigate/${SOURCEIP}/${SOURCEIP}-$YEAR-$MONTH-$DAY-$HOUR.log"
        create_dirs(yes)
        dir-owner("splunk")
        dir-group("splunk")
        dir-perm(0750)
        owner("splunk")
        group("splunk")
        perm(0640)
        template(t_raw)
        fsync(no)
    );
};

###############################################################################
# UDP DESTINATIONS
###############################################################################
# F5 WAF
destination d_f5waf {
    file(
        "/var/log/syslog/f5waf/${SOURCEIP}/${SOURCEIP}-$YEAR-$MONTH-$DAY-$HOUR.log"
        create_dirs(yes)
        dir-owner("splunk")
        dir-group("splunk")
        dir-perm(0750)
        owner("splunk")
        group("splunk")
        perm(0640)
        template(t_raw)
        fsync(no)
    );
};

###############################################################################
# LOG PATHS
###############################################################################
log {
    source(s_fortigate);
    destination(d_fortigate);
    flags(final);
};

log {
    source(s_f5waf);
    destination(d_f5waf);
    flags(final);
};
###############################################################################
# END
###############################################################################
EOF

============================================
[+] Validate & Start
============================================
sudo syslog-ng -s
sudo systemctl restart syslog-ng
sudo systemctl status syslog-ng --no-pager

sudo ss -lntup | grep 1514
ss -ulm sport = :2514
============================================
[+] Testing
============================================
loggen --size 500 --rate 1000 --interval 600 10.0.0.1 514

logger --server 127.0.0.1 --port 1514 --tcp "PALOALTO_TCP_TEST"

logger --server 127.0.0.1 --port 2514 --udp "PALOALTO_UDP_TEST"

echo '<134>date=2026-08-11 time=13:00:00 devname=PA01 type=TRAFFIC action=allow srcip=10.1.1.1 dstip=10.2.2.2' | nc -w1 10.0.4.160 1514
============================================
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Rethinking Zero Trust: From Product Purchases to Logical Control Evidence

Implementing Zero Trust (ZT) across complex environments often falters at the very beginning due to a ...

Preparing your Splunk Environment for OpenSSL3

The Splunk platform will transition to OpenSSL version 3 in a future release. Actions are required to prepare ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...