Skip to content
/ tglog Public

Realtime log analyzer for NGinx with Telegram notifications

License

Notifications You must be signed in to change notification settings

dbkv9/tglog

Repository files navigation

tglog

tglog

Realtime log analyzer for NGinx with Telegram notifications

License: MIT Codacy Badge tglog workflow tglog go

General features:

  1. Realtime critical error notification

image

  1. Daily reports (with cron-like scheduler for time customization)

image

  1. Log file export to Excel sheet

image

image

Prerequisites

For build project you must install:

Among other things, you need create a Telegram bot through @botfather and set bot token to tgtoken parameter in your config file.

Quick start

  1. Clone repo, build and install project

    git clone [email protected]:dbkv9/tglog.git
    cd tglog
    make build
    make install
    
  2. 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).
  3. 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
    

TODO

  • 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