@version: 3.19
@include "scl.conf"

# This is a custom syslog-ng configuration file, based in
# https://github.com/syslog-ng/syslog-ng/blob/master/packaging/debian/syslog-ng.conf
#
# It was added to the base:
#       Options: ts-format, time_zone
#       Added to the destination files:
# flags(syslog-protocol)                // follow template for RFC5424
# suppress(5)                           // if there are repeated messages only send oce the repeated message with the number of times repeated
# disk-buffer(                          // Memory Disk buffer to avoid loss of mesages when the destination is not ready
#         mem-buf-size(2097152)         // This option contains the size of the messages in bytes that is used in the memory part of the disk buffer
#         disk-buf-size(4194304)        // The maximum size of the disk-buffer in bytes
#         reliable(yes)                 // syslog-ng OSE cannot lose logs in case of reload/restart
#         dir("/tmp")                   // location of the Memory Disk buffer
#    )

# First, set some global options.
options {
    chain_hostnames(off);
    flush_lines(0);
    use_dns(no);
    use_fqdn(no);
    owner("root");
    group("adm");
    perm(0640);
    stats_freq(0);
    bad_hostname("^gconfd$");
    ts-format("iso");
    time_zone("UTC");
    mark-freq(0);
    frac-digits(3);
};

# common block end


source s_src {
    system();
    internal();
};

rewrite r_host { set("THANOS", value("HOST")); };
# console log: 
destination d_console_log {
    usertty("username");
};
filter f_console_log {
    level(crit .. emerg)};
log {
    source(s_src);
    filter(f_console_log);
    destination(d_console_log);
};
# end of console log


# localFile: sample
destination d_localfile_sample {
    file("/var/log/sample.log"
        flags(syslog-protocol)
        suppress(5)
        disk-buffer(
            mem-buf-size(2097152)
            disk-buf-size(4194304)
            reliable(yes)
            dir("/tmp")
        )
    );
};
filter f_localfile_sample {
    level(debug .. emerg);
};
log {
    source(s_src);
    filter(f_localfile_sample);
    destination(d_localfile_sample);
    flags(flow-control);
};
# end of localFile: sample

# remote: test
destination d_test_udp { 
    syslog("10.0.2.5" transport("udp") ip-protocol(4) port(514) keep-alive(no) localip("10.0.2.6")
        suppress(5)
        disk-buffer(
            mem-buf-size(2097152)
            disk-buf-size(4194304)
            reliable(yes)
            dir("/tmp")
        )
    );
};
filter f_remote_test_udp {
    level(debug .. emerg); 
};
log {
    source(s_src);
    rewrite(r_host);
    filter(f_remote_test_udp);
    destination(d_test_udp);
    flags(flow-control);
};
# end of remote server: test


