mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6425] [Feature]: Add a Telegram/email notification event when the outbound changes in the Balancer Observatory #4351
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#4351
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @shlima on GitHub (Sep 5, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6425
Is your feature request related to a problem?
Notification when the outbound changes in the load balancer can help troubleshoot a flaky server without the need to deploy a more complex monitoring infrastructure.
Describe the solution you'd like
Send a notification when the load balancer switches a server in the pool to the fallback server, with debounce/rate limiting to prevent notification spam.
Alternatives you've considered
No response
Concrete use case
No response
Mockups, screenshots, or examples
No response
Which parts of the panel would this affect?
No response
Are you willing to help?
Before submitting
@github-actions[bot] commented on GitHub (Sep 5, 2026):
This already exists — the panel has observatory-driven
outbound.down/outbound.upevents with both a Telegram and an email subscriber, plus the debounce and rate limiting you asked for. It is just off by default.How to turn it on
tgEnabledEvents/smtpEnabledEvents, whose defaults arelogin.attempt,cpu.high, i.e. outbound events off (internal/web/service/setting.go:159-160).outboundDownThreshold, default3, accepted range 1–100 —internal/web/entity/entity.go:65,frontend/src/components/ui/notifications/TelegramNotifications.tsx:20-33).metricsblock — the sampler readshttp://<metrics.listen>/debug/varsand gives up with"metrics block not configured in xray template"if it is missing (internal/web/service/xray_metrics.go:147-174). The shipped default already has it:Only outbound tags that your balancer's
observatory/burstObservatoryactually probes appear in that map, so the events follow exactly the same health signal the balancer uses to pick a target.The debounce/anti-spam you asked for is already there, in two layers:
applyObservatoryignores a sample whoselastTryhas not advanced —if cur.LastTryTime == 0 || cur.LastTryTime == h.lastTry { continue }(internal/web/service/xray_metrics.go:259-261) — then requiresh.failStreak >= threshold && !h.notifiedbefore publishingoutbound.down(:275), and only sendsoutbound.upif a down was actually notified (:264). The comment on theoutboundHealthtype spells out why (:53-58): "Xray flips an outbound's alive flag on a single failed probe, so raw transitions produce a storm of down/up notifications on a flaky link."eventbus.NewRateLimiter(1 * time.Minute)atinternal/web/service/tgbot/tgbot_event.go:28(applied at:37) andinternal/web/service/email/subscriber.go:28(applied at:41).The message bodies are at
internal/web/service/tgbot/tgbot_event.go:65-87(Telegram, includes tag, error and delay) andinternal/web/service/email/subscriber.go:92-113(HTML email). Docs: Telegram bot → events listsoutbound.down/outbound.upandtgEnabledEvents.What genuinely does not exist, and is the only part of your request left open: there is no balancer-level event. The panel notifies per outbound tag, so on a failover you get "Outbound X is DOWN" — nothing names the balancer, and nothing says which
fallbackTagtook over.fallbackTagis stored and rendered (frontend/src/schemas/xray.ts:137) but never fed to the event bus; the only publishers of outbound events areinternal/web/service/xray_metrics.go:265and:281. For flaky-server troubleshooting the per-tag down/up alert is usually the signal you want, but if a "balancer B switched to fallback F" message is specifically what you need, that part is a real gap and this issue is a reasonable place to track it. I have left it open with theenhancementlabel for that.Verdict: Already fixed (shipped for the per-outbound case; the balancer-level event is the remaining gap)
The events landed in
eec030f8feat(notifications): event bus architecture with Telegram and SMTP subscribers (#5326), first released in v3.4.0; the configurable failure threshold in2b1308cafeat(notifications): add a consecutive-failure threshold for outbound.down alerts (#5968), first released in v3.6.0. Both are in v3.7.0. Related, not duplicates: #6387, #6355, #6305.This reply was generated automatically; a maintainer may follow up.
@shlima commented on GitHub (Sep 6, 2026):
The solution described above does not work when the load balancer contains reverse VLESS connections.