Realtime log analyzer for NGinx with Telegram notifications
- Realtime critical error notification
- Daily reports (with cron-like scheduler for time customization)
- Log file export to Excel sheet
For build project you must install:
- Go compiler, ver >= 1.20 https://go.dev/doc/install
- Make https://www.gnu.org/software/make/
Among other things, you need create a Telegram bot through @botfather and set bot token to tgtoken parameter in your config file.
-
Clone repo, build and install project
git clone [email protected]:dbkv9/tglog.git cd tglog make build make install
-
Edit default config file in /usr/local/etc/tglog/config.yaml or create new config file with custom path.
If you want use custom config file path, you must pass it to tglog parameter:
./tglog --config /custom/path/to/config.yaml
Config for example:
projects: project1: log: "/path/to/project1/log/file" host: "https://project1.com/" reportschedule: "0 * * * *" tgchat: -000000000 webserver: "nginx" format: "$remote_addr - $remote_user [$time_local] \"$request\" $status $body_bytes_sent \"$http_referer\" \"$http_user_agent\"" tgtoken: "XXXXXXXXXXXXX:XXXXXXXXXXX-XXXX-XXXXXXXXXX-XXXX"
This file have next parameters:
- log - path to log file;
- host - full host to your website;
- reportschedule - cron-like scheduler;
- tgchat - id of your chat for send notification;
- webserver - now nginx by default;
- format - format of your log file (currently support only default NGinx access log file format).
-
Run
If you want startup tglog without systemd, just type:
./tglog ## or if you use custom config path ./tglog --config /path/to/config.yaml
If you want use systemd, run next commands from tglog directory:
sudo cp tglog.service /etc/systemd/system/ sudo systemctl enable tglog.service sudo systemctl start tglog.service
- move config file to linux system folder
- add systemd support
- add binaries to git release
- add Makefile for project building
- add geoip
- add robots DNS detector