logram - push logs updates to Telegram
Use
- Install Rust via Rustup
- Install logram:
cargo install logram
- Create bot
- Run logram in echoID mode:
logram echoID <bot token>
and get needed chat ids:- For regular chat: send any message to bot
- For group chat: add bot to group
- For channel: forward any message from channel to bot (dont forget add bot to channel admins)
- Write config from example
- Run in normal mode
logram <path to config>
Config example
telegram:
# bot token
token: 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
# default chat (for updates from files without custom chat and errors)
chat: 12345678
watcher:
# watching files (logs)
files:
# path to file
- path: /var/log/awesome.log
# custom chat for this file (optional)
chat: 12345678
# push updates only which matches that regex (optional)
# (more info: doc.rust-lang.org/regex)
regex: critical
Systemd service
- Create link:
sudo ln -s /home/<user>/.cargo/bin/logram /usr/bin/logram
- Copy config to
/etc/logram.yaml
- Copy
logram.service
to/etc/systemd/system
- Reload services:
sudo systemctl daemon-reload
- Enable service:
sudo systemctl enable logram
- Run service:
sudo systemctl start logram
Use logram as slog drain
Logram implements slog::Drain
, example usage:
- Import logram as library
[]
= "2.0"
= "0.2"
- Use logram as drain
extern crate slog;
extern crate slog_logram;
use Drain;
use ;