ยง2024-05-16

  1. I have a mongoDB replcation Server as follow:
  1. each member will have a log file in /opt/package/mongoDB/log/mongod.log in his own hard disk.

All the replication memebers has syslog-ng installed. I would like a hc4nas02.yushei.net machine installed with syslog-ng to be used to record all replcation memebers log into his /var/log/mongoDB-ys20220317.log using syslog-ng program.

@hc4nas02.yushei.net, /etc/syslog-ng/syslog-ng.conf is as,

@version: 3.25
@include "scl.conf"

# Sources
source s_net {
    network(ip(0.0.0.0) port(514) transport("udp"));
};

# Destinations
destination d_mongoDB {
    file("/var/log/mongoDB-ys20220317.log");
};

# Filters
filter f_redisMongo01 {
    host("redisMongo01.yushei.com.tw");
};

filter f_redisMongo02 {
    host("redisMongo02.yushei.com.tw");
};

filter f_redisMongo03 {
    host("redisMongo03.yushei.com.tw");
};

filter f_redisMongo04 {
    host("redisMongo04.yushei.com.tw");
};

# Bind Sources, Destinations, and Filters
log {
    source(s_net);
    filter(f_redisMongo01);
    destination(d_mongoDB);
};

log {
    source(s_net);
    filter(f_redisMongo02);
    destination(d_mongoDB);
};

log {
    source(s_net);
    filter(f_redisMongo03);
    destination(d_mongoDB);
};

log {
    source(s_net);
    filter(f_redisMongo04);
    destination(d_mongoDB);
};

in redismongo03.yushei.com.tw it had a /opt/package/mongoDB/log/mongod.log file that is mongoDB log file. We would like to send it to hc4nas02.yushei.net's syslog-ng, what will be the configuration file /etc/syslog-ng/syslog-ng.conf?

@version: 3.25
@include "scl.conf"

# Sources
source s_net {
    network(ip(0.0.0.0) port(514) transport("udp"));
};

source s_mongo_log {
    file("/opt/package/mongoDB/log/mongod.log" flags(no-parse));
};

# Destinations
destination d_hc4nas02 {
    syslog("hc4nas02.yushei.net" transport("udp") port(514));
};

# Filters
filter f_redisMongo03 {
    host("redisMongo03.yushei.com.tw");
};

# Bind Sources, Destinations, and Filters

# Send mongod.log from redismongo03.yushei.com.tw to hc4nas02.yushei.net
log {
    source(s_net);
    source(s_mongo_log);
    filter(f_redisMongo03);
    destination(d_hc4nas02);
};

@version: 3.25 @include "scl.conf"

Sources

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

Destinations

destination d_hc4nas02 { syslog("hc4nas02.yushei.net" transport("udp") port(514)); };

Bind the source and destination together

log { source(s_local); destination(d_hc4nas02); };