All tutorials

Integracja bota alertów Telegram

Konfiguracja natychmiastowych powiadomień Telegram o rozłączeniach minerów i anomaliach.

HashRelay does not talk to the Telegram Bot API itself. Alerts are written to the database, logged, and — if you enable it — POSTed as JSON to a webhook URL. Telegram, DingTalk, and Feishu are all just something on the other end of that URL.

Turn the detectors on

Sniffing must be enabled on the pool, otherwise there are no share or hashrate events to judge. Then enable the global alert switch.

toml
[sniffing.alerts]
enabled = true
reject_rate_threshold = 0.10      # 10% over the last N shares
reject_rate_window = 50
offline_threshold = 300           # seconds
hashrate_drop_threshold = 0.50    # vs the 15-minute average
hashrate_zero_periods = 3
consecutive_stale_threshold = 5
high_latency_threshold_ms = 5000
reconnect_window = 300
reconnect_threshold = 3
alert_cooldown = 600              # seconds, same type + pool + worker

[sniffing.alerts.webhook]
enabled = true
url = "https://your-bridge.example/hashrelay"
timeout = 10
# [sniffing.alerts.webhook.headers]
# Authorization = "Bearer xxx"

What gets POSTed

The webhook sink sends Content-Type: application/json. Severity is the debug name, so it is "Warning" or "Critical", not a number. A non-2xx response is logged and does not stop other alerts.

json
{
  "alert_type": "high_reject_rate",
  "severity": "Warning",
  "pool_name": "F2Pool-BTC",
  "worker": "user.worker01",
  "message": "...",
  "context": { "reject_rate": 0.18 },
  "timestamp": "2026-11-04T10:00:00Z"
}

alert_type values produced by the detectors include high_reject_rate, difficulty_spike, hashrate_drop, hashrate_zero, auth_failure, high_latency, and high_avg_latency. The same triple (type, pool, worker) is cooled down for alert_cooldown seconds, default 600.

Landing in Telegram

Point url at a small bridge you run: receive this JSON, then call Telegram sendMessage with your bot token. Do not put the bot token in server.toml except as a header on a bridge you control. You can also read the same events later with GET /api/v1/alerts and mark one resolved with POST /api/v1/alerts/:id/resolve.