- Live job card widget (progress bar, in-widget cancel via widget_query) and live invoice widget (QR drawn from a bitmap, countdown, paid state), Bot API 10.4 sendWidget, private chats only - Automatic fallback to the ordinary message when sendWidget fails, with a breaker that pauses widgets after repeated failures or on servers without the method; TELEGRAM_WIDGETS - Prometheus metrics on the core (/metrics) and on every worker: queue depth and wait, slots, heartbeats, job outcomes, errors per site, deliveries, cache, invoices, Lightning, ledger check, widgets - Example Prometheus config and alert rules, Caddyfile, dashboard notes - Load test: cmd/loadtest and deploy/loadtest (make loadtest) - Browser check of the widgets' HTML, including decoding a drawn QR - docs/DEPLOY.md (production in under an hour) and docs/MONITORING.md Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
76 lines
2.8 KiB
YAML
76 lines
2.8 KiB
YAML
# Alert rules for the bot. Thresholds are starting points; tune them to
|
|
# your traffic. Written for Prometheus 2.x and 3.x rule files.
|
|
groups:
|
|
- name: dlbot
|
|
rules:
|
|
- alert: DlbotCoreDown
|
|
expr: up{job="dlbot-core"} == 0
|
|
for: 2m
|
|
labels: {severity: page}
|
|
annotations:
|
|
summary: The bot's core is not answering /metrics.
|
|
|
|
- alert: DlbotQueueStuck
|
|
# Jobs wait while no slot is busy: workers are gone or cannot claim.
|
|
expr: sum(dlbot_queue_jobs) > 0 and dlbot_jobs_running == 0
|
|
for: 5m
|
|
labels: {severity: page}
|
|
annotations:
|
|
summary: Jobs are queued but nothing is downloading.
|
|
|
|
- alert: DlbotQueueSlow
|
|
expr: dlbot_queue_oldest_wait_seconds > 900
|
|
for: 10m
|
|
labels: {severity: warn}
|
|
annotations:
|
|
summary: The oldest queued job has waited over 15 minutes. Add workers or slots.
|
|
|
|
- alert: DlbotBooksDisagree
|
|
expr: dlbot_wallets_mismatched > 0
|
|
labels: {severity: page}
|
|
annotations:
|
|
summary: A wallet balance disagrees with its ledger. Stop and investigate before paying anything out.
|
|
|
|
- alert: DlbotNoWorkers
|
|
expr: dlbot_worker_slots == 0
|
|
for: 5m
|
|
labels: {severity: page}
|
|
annotations:
|
|
summary: No download slots are connected.
|
|
|
|
- alert: DlbotWorkerSilent
|
|
expr: dlbot_worker_heartbeat_age_seconds{state="active"} > 120
|
|
for: 2m
|
|
labels: {severity: warn}
|
|
annotations:
|
|
summary: Worker {{ $labels.worker }} has not checked in for two minutes.
|
|
|
|
- alert: DlbotWorkerTokenRejected
|
|
expr: dlbot_worker_token_rejected == 1
|
|
for: 1m
|
|
labels: {severity: page}
|
|
annotations:
|
|
summary: The core rejects the token of {{ $labels.instance }}.
|
|
|
|
- alert: DlbotLightningDown
|
|
expr: dlbot_lightning_up == 0
|
|
for: 5m
|
|
labels: {severity: page}
|
|
annotations:
|
|
summary: The payment backend (LNbits) is unreachable. Invoices cannot be created or confirmed.
|
|
|
|
- alert: DlbotSiteFailing
|
|
# One site failing most downloads usually means yt-dlp needs an
|
|
# update or the site blocks the workers' network.
|
|
expr: sum by (site) (increase(dlbot_download_errors_total{code!~"private|login_required|not_found|too_large|too_long|cancelled"}[30m])) > 10
|
|
for: 10m
|
|
labels: {severity: warn}
|
|
annotations:
|
|
summary: Downloads from {{ $labels.site }} keep failing. Try /ytdlp update, or route the site to other workers.
|
|
|
|
- alert: DlbotWidgetsFallingBack
|
|
expr: sum(increase(dlbot_widgets_total{outcome="fallback"}[1h])) > 20
|
|
labels: {severity: info}
|
|
annotations:
|
|
summary: sendWidget keeps failing; the bot is using ordinary messages. Nothing breaks, but check the logs.
|