§2024-05-17
How to install syslog-ng and configure?
¶ Using hc4nas02.yushei.net to record the following replicationSet's /opt/package/mongoDB/log/mongod.log
- redisMongo01.yushei.com.tw 192.168.2.153
- redisMongo02.yushei.com.tw 192.168.2.232
- redisMongo03.yushei.com.tw 192.168.2.250
- redisMongo04.yushei.com.tw 192.168.2.231
- redisMongo??.yushei.com.tw 192.168.2.235
-
installation
sudo apt install syslog-ng
-
/etc/syslog-ng/syslog-ng.conf
- hc4nas02.yushei.net
@version: 3.25
@include "scl.conf"
options {
keep-hostname(yes);
};
# Sources
source s_net {
network(ip(0.0.0.0) port(514) transport("udp"));
};
# Destination
destination d_mongoDB {
file("/var/log/mongoDB-ys20220317.log");
};
# Filters
# filter f_redisMongo {
# host("redisMongo[0-9]+\.yushei\.com\.tw");
# };
# Log Statements
log {
source(s_net);
# filter(f_redisMongo);
destination(d_mongoDB);
};
- all replication members /etc/syslog-ng/syslog-ng.conf is as
@version: 3.25
@include "scl.conf"
options {
keep-hostname(yes);
};
# Sources
source s_mongo_log {
file("/opt/package/mongoDB/log/mongod.log" flags(no-parse));
};
# Destination
destination d_mongoDB {
syslog("hc4nas02.yushei.net" transport("udp") port(514));
};
# Log Statements
log {
source(s_mongo_log);
# parser {
# json-parser(prefix("json."));
# };
destination(d_mongoDB);
};
-
do
sudo systemctl restart syslog-ng
-
monitoring from
ssh -p 1765 alexlai@hc4nas02.yushei.net
# tail -f /var/log/mongoDB-ys20220317.log
# tail -f /var/log/mongoDB-ys20220317.log |grep -iE 'Slow|error'