Dev
Monitoring logs

Monitoring logs

Teleghosts utilizes structured JSON logging which is hard to read by humans in a raw form. To monitor logs effectively you need to install a third-party software that renders structured logs. There are a lot of different options available, we suggest to stick with something simple because teleghosts logs are quite short.

For example, we’re using the hl log viewer, below you will find a cheatsheet to work with it

Follow the logs of the active instance

tail -f ./logs/current.log | hl --theme neutral -L -P

where --theme selects the color theme, -L converts timestamps to local timezone and -P disables paging

Filter logs by level & hide uninteresting properties

hl -L --level WRN --hide target ./logs/current.log

--level WRN filters out log entries with level < WRN and --hide target hides properties like target=reqwest::connect.

Show only teleghosts logs, ignore logs from dependencies

hl -L -f "target~=teleghosts*" ./logs/current.log

Check hl filtering docs to learn more about log filtering

Count number of long-poll connections to telegram servers per day

hl -L -P --since yesterday --until today -f "target=reqwest::connect" ./logs/previous.log | wc -l