@version: 3.19

# 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
#    )
# References: THANOS-3103, THANOS-3352, THANOS-3555

# First, set some global options.
options {
    chain_hostnames(off);
    flush_lines(0);
    use_dns(no);
    use_fqdn(no);
    owner("root");
    group("root");
    perm(0644);
    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();
    syslog(ip(127.1.1.1) transport("udp") port(514) keep-alive(no));
};

rewrite r_host { set("GX", value("HOST")); };
# console log:
destination d_console_log {
    usertty(*);
};
filter f_console_log_local7 {
    facility(local7) and level(info .. emerg)};
filter f_console_log {
    filter(f_console_log_local7); };
log {
    source(s_src);
    filter(f_console_log);
    destination(d_console_log);
};
# end of console log


# localFile: apps
destination d_localfile_apps {
    program("/opt/infinera/thanos/local/bin/write_with_rotation.sh /var/log/apps.log 10 10"
        flags(syslog-protocol)
        suppress(5)
        disk-buffer(
            mem-buf-size(2097152)
            disk-buf-size(4194304)
            reliable(yes)
            dir("/tmp")
        )
    );
};
filter f_localfile_apps_local7 {
    facility(local7) and level(info .. emerg);
};
filter f_localfile_apps {
    filter(f_localfile_apps_local7); };
log {
    source(s_src);
    filter(f_localfile_apps);
    destination(d_localfile_apps);
    flags(flow-control);
};
# end of localFile: apps
