You've already forked telegram_loki
mirror of
https://github.com/ManyakRus/telegram_loki.git
synced 2025-09-16 08:56:28 +02:00
сделал Victoria metrics
This commit is contained in:
43
README.md
43
README.md
@@ -1,62 +1,61 @@
|
||||
Applications for sending logs with errors from the LOKI(GRAFANA) logger to the Telegram messenger
|
||||
Applications for sending error logs from the LOKI logger (or Victoria Metrics) to the Telegram messenger
|
||||
|
||||
The LOKI logger has an inconvenient interface for searching errors in application logs,
|
||||
Grafana has an inconvenient web interface for searching for errors in application logs,
|
||||
and no one will look there every 5 minutes -
|
||||
Therefore, it is necessary to automate the process of searching for errors in logs and notifying developers.
|
||||
so we need to automate the process of searching for errors in logs and notifying developers.
|
||||
|
||||
The application does:
|
||||
Search for errors in the LOKI logger
|
||||
1. Log in to grafana
|
||||
Search for errors in the LOKI logger (or in Victoria Metrics)
|
||||
1. Logs into the LOKI (Victoria) api
|
||||
2. Takes a list of services from the services.txt file,
|
||||
including the name of the service and the name of the person responsible
|
||||
3. For each service, searches for LOKI logs with the text: error:, panic:, ERROR:, PANIC:
|
||||
including the service name and the name of the person responsible
|
||||
3. For each service, searches for logs with the text: error:, panic:, ERROR:, PANIC:
|
||||
4. Sends the found logs with errors to the Telegram messenger
|
||||
5. Repeats the search every 10 minutes
|
||||
|
||||
Search for errors in the database:
|
||||
1. Log in to the PostgreSQL database
|
||||
1. Logs into the PostgreSQL database
|
||||
2. Finds .sql files in the sql folder, and executes a script in the database,
|
||||
if the script returns a value, a message about this will come to the Telegram messenger,
|
||||
if the script does not return lines, then everything is fine.
|
||||
if the script does not return a single line, then everything is fine.
|
||||
3. Repeats requests every 60 minutes
|
||||
4. If you fill in the scripts.txt file (scripts_add.txt),
|
||||
including the .sql file name and the name of the person responsible,
|
||||
then the name of the person responsible will also be added.
|
||||
then it will also add the name of the person responsible.
|
||||
|
||||
The bot sends error logs to Telegram groups:
|
||||
1. General group with all errors, all programmers.
|
||||
Group ID is filled in settings.txt, TELEGRAM_CHAT_NAME=
|
||||
The group ID is filled in settings.txt, TELEGRAM_CHAT_NAME=
|
||||
In the Telegram group settings, you need to set the rights Group type = "Public"
|
||||
2. Each programmer separately, only logs that apply to him.
|
||||
2. Each programmer separately, only the logs that apply to him.
|
||||
Filled in the files services.txt, scripts.txt
|
||||
Each programmer must add this telegram bot to his Telegram
|
||||
Each programmer must add this telegram bot to Telegram
|
||||
|
||||
Installation procedure:
|
||||
1. Compile this repository
|
||||
>make build
|
||||
the telegram_loki file will appear in the bin folder
|
||||
|
||||
2. fill parametes in settings.txt file (or .env file)
|
||||
with Grafana LOKI URL, login, password, etc.
|
||||
2. fill in the settings.txt (or .env) file
|
||||
with the LOKI URL settings, login, password, etc.,
|
||||
as well as the database connection settings (optional).
|
||||
|
||||
3. Fill in the settings/services.txt file
|
||||
In json format write the service name in LOKI
|
||||
In json format, write the service name in LOKI
|
||||
and the name (login) of the programmer (optional)
|
||||
sample:
|
||||
{
|
||||
"test-service1": "@DeveloperTelegramName"
|
||||
"test-service1": "@DeveloperTelegramName"
|
||||
}
|
||||
|
||||
|
||||
3. Run the telegram_loki file
|
||||
|
||||
|
||||
Source code in Golang language.
|
||||
Source code in Golang.
|
||||
Tested on Linux Ubuntu
|
||||
Readme from 10/13/2023
|
||||
Readme from 08/19/2025
|
||||
|
||||
License:
|
||||
Save information about the author and the site.
|
||||
GPL 2, save information about the author and the site.
|
||||
|
||||
Made by Alexander Nikitin
|
||||
https://github.com/ManyakRus/telegram_loki
|
14
readme.rus
14
readme.rus
@@ -1,15 +1,15 @@
|
||||
Приложения для отправки логов с ошибками из логгера LOKI(GRAFANA) в мессенджер Telegram
|
||||
Приложения для отправки логов с ошибками из логгера LOKI(или Victoria Metrics) в мессенджер Telegram
|
||||
|
||||
В логгере LOKI неудобный интерфейс для поиска ошибок в логах приложений,
|
||||
В Grafana неудобный web интерфейс для поиска ошибок в логах приложений,
|
||||
и никто не будет туда смотреть каждые 5 минут -
|
||||
поэтому надо автоматизировать процесс поиска ошибок в логах и уведомление разработчикам.
|
||||
|
||||
Приложение делает:
|
||||
Поиск ошибок в логгере LOKI
|
||||
1. Логинится в grafana
|
||||
Поиск ошибок в логгере LOKI (или в Victoria Metrics)
|
||||
1. Логинится в api LOKI(Victoria)
|
||||
2. Берёт список сервисов из файла services.txt,
|
||||
в том числе имя сервиса и имя ответственного
|
||||
3. По каждому сервису ищет логи LOKI с текстом: error:,panic:,ERROR:,PANIC:
|
||||
3. По каждому сервису ищет логи с текстом: error:,panic:,ERROR:,PANIC:
|
||||
4. Найденные логи с ошибками присылает в Telegram мессенджер
|
||||
5. Повторяет поиск каждые 10 минут
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
2. заполнить файл settings.txt (или .env)
|
||||
с настройками LOKI URL, логин, пароль и др.,
|
||||
а также настройки подключения в базу данных.
|
||||
а также настройки подключения в базу данных (необязательно).
|
||||
|
||||
3. Заполнить файл settings/services.txt
|
||||
В формате json написать имя сервиса в LOKI
|
||||
@@ -55,7 +55,7 @@
|
||||
|
||||
Исходный код на языке Golang.
|
||||
Тестировал на Linux Ubuntu
|
||||
Реадми от 13.10.2023
|
||||
Реадми от 19.08.2025
|
||||
|
||||
Лицензия:
|
||||
GPL 2, сохранять информацию об авторе и сайте.
|
||||
|
Reference in New Issue
Block a user