With most of the functional setup complete for nextcloud (as documented on my previous blog entries) It's time to move on to centralised log management and application monitoring. Im going to choose EFK as my logging stack, which I believe is one of the most popular log management stacks in the world.
However instead of hosting and maintaining my own EFK stack, I'm going to rely on a 3rd party such as logz.io or sematext for hosting the stack for me. both these providers seems to have good coverage in functionality and comes with a free tier for trying out the full feature set. This leaves me with having to install and configure fluent.d on my server.
Heres the steps I followed:
- Download and install fluent.d
- check pre installation checkpoints https://docs.fluentd.org/installation/before-install
- I didn't end up changing anything on my server for now.
- Follow the installation guide
- curl -L https://toolbelt.treasuredata.com/sh/install-ubuntu-bionic-td-agent4.sh | sh
- remove all config at /etc/td-agent/td-agent.conf
- systemctl restart td-agent
- Setup input source for syslog
- https://docs.fluentd.org/input/syslog
- update /etc/td-agent/td-agent.conf
- update /etc/rsyslogd.conf
- restart both services
- Setup input source apache
- https://docs.fluentd.org/v/0.12/articles/recipe-apache-logs-to-elasticsearch
- Setup sources for
access anderror logs - Setup input source MySQL
- MYSQL error log is now managed via syslog, nothing to do on td-agent.conf
- Setup input source Nextcloud
- setup tail source for nextcloud log at /var/log/nextcloud.log
- Setup output source for elastic (logz.io)
sudo /usr/sbin/td-agent-gem install fluent-plugin-elasticsearch- sudo /usr/sbin/td-agent-gem install fluentd fluent-plugin-logzio
- Add relevant match clause to /etc/td-config/td-agent.conf
Give read access to <user> on var/logsudo chmod -R o+r /var/log/sudo chmod og+rx /var/log/apache2sudo chmod og+rx /var/log/mysqlGive td-agent user access to log filessudo usermod -a -G adm td-agent- Give td-agent user access to apache2 log files
- sudo setfacl -m u:td-agent:rx /var/log/apache2
- sudo vi /etc/logrotate.d/apache2
- add the config to update ACL to error and other-vhosts-access files
- Setup logrotate for nextcloud log and give td-agent user access
- sudo setfacl -m u:td-agent:rx /var/log/nextcloud.log
- sudo vi /etc/logrotate.d/nextcloud
- add logrotate config (https://help.nextcloud.com/t/logfile-does-not-rotate/29342/7)
- add the config to update ACL to nextcloud.log file
- TODO: Add backup/archive logic for logs
- Finalise how to archive the logs to a preferred cloud storage
Additional reading:
No comments:
Post a Comment