Warning
|
This is an experimental prototype, a proof of concept. Don’t use in production. A lot of things don’t work as expected, and extensive testing is still needed. |
Note
|
The webhook endpoint doesn’t support auth and encryption. If you need HTTPS and auth, use a reverse proxy. |
Prerequisites
Note
|
If you are planning to run it in Docker containers, ignore this list. See Dockerfile and compose.yml. |
-
Node.js latest
-
Redis-compatible in-memory database (I prefer Valkey)
-
pnpm
-
Access control based on Telegram UIDs
-
Multiple chats can be subscribed simultaneously
-
Both private chats and group chats can be subscribed to alerts
NoteThe user interacting with the bot in a group chat must be added to the ACL, but not the group chat itself. -
Unauthorized users are ignored
-
Arbitrary messages and unrecognized commands are ignored
-
Unauthorized access to valid bot commands is logged
-
Grafana interacts with the bot via a webhook endpoint
-
Style messages with Telegram-supported HTML tags (the bot doesn’t support Markdown)
Suppose, you use ClickHouse as a data warehouse for your logs, and it’s connected to your Grafana instance as a data source.
You have created an alert rule with the following SQL query:
And annotations look like the following:
When the alert rule is triggered, all subscribed Telegram chats will get messages similar to this:
Example Video
-
Copy the example configuration file botconfig.toml to a new directory ./config.
-
Edit config.