[GH-ISSUE #5972] [Bug]: Xray Metrics not shown metrics for Outbounds with flag in their names #4138

Closed
opened 2026-10-31 20:37:28 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @nebulosa2007 on GitHub (Jul 15, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5972

Describe the bug

I see in Xray Metrics only warp outbound but in Observatory I have several outbounds

How to reproduce the problem

  1. Add several Outbound with flag in their names
  2. Make a Balancer with them
  3. In Xray Metrics, Observatory they will not appears for charts

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

Image Image

3x-ui version

3.5.0

Xray-core version

26.7.11

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 24.04

Which parts of the panel are affected?

Frontend (UI / panel pages)

Browser (only if it is a UI bug)

Chrome

Is the panel behind a reverse proxy or CDN?

Yes — Nginx

Before submitting

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
Originally created by @nebulosa2007 on GitHub (Jul 15, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5972 ### Describe the bug I see in Xray Metrics only `warp` outbound but in `Observatory` I have several outbounds ### How to reproduce the problem 1. Add several Outbound with flag in their names 2. Make a Balancer with them 3. In Xray Metrics, Observatory they will not appears for charts ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots <img width="895" height="436" alt="Image" src="https://github.com/user-attachments/assets/d55d26a6-3f6b-4e98-8297-1139ea8bcf25" /> <img width="1385" height="540" alt="Image" src="https://github.com/user-attachments/assets/1bf2cab0-0ac4-4c14-b6a0-c02480bb3286" /> ### 3x-ui version 3.5.0 ### Xray-core version 26.7.11 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 24.04 ### Which parts of the panel are affected? Frontend (UI / panel pages) ### Browser (only if it is a UI bug) Chrome ### Is the panel behind a reverse proxy or CDN? Yes — Nginx ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:37:28 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@github-actions[bot] commented on GitHub (Jul 15, 2026):

Title: Xray Metrics' Observatory tab silently drops outbound tags containing any character outside [a-zA-Z0-9._-]

Severity: Medium

Category: Correctness

Why this matters: The tag list shown in the panel's "Xray Metrics" → Observatory tab comes from XrayMetricsService.ObservatorySnapshot() (internal/web/service/xray_metrics.go:80-89), which only returns tags present in the in-memory obsByTag map. That map is populated in applyObservatory (internal/web/service/xray_metrics.go:195-215), and any tag that fails validObsTag.MatchString(tag) is skipped before it's ever added (line 202-204) — so it never reaches the GET /panel/api/server/xrayObservatory response the frontend dropdown is built from (frontend/src/pages/index/XrayMetricsModal.tsx, fetchObservatory). The same regex separately guards HasObservatoryTag and AggregateObservatory (lines 91-99, 101-106), so a direct history request for such a tag is also rejected by the controller as "invalid tag" (internal/web/controller/server.go:171-182).

The regex is:

var validObsTag = regexp.MustCompile(`^[a-zA-Z0-9._\-]+$`)

(internal/web/service/xray_metrics.go:51) — ASCII letters/digits/./_/- only. Any tag containing a space, emoji (including flag emoji used for country identification), or non-Latin text fails this and is silently dropped, even though:

  • Xray-core itself imposes no such restriction on outbound tags, so its own Observatory (read directly from Xray's /debug/vars) reports them correctly, consistent with your report that Observatory itself lists several outbounds.
  • The panel's own editors don't restrict tag characters either: OutboundTagSchema and BalancerFormSchema.tag (frontend/src/schemas/xray.ts:112-130) only require a non-empty tag that doesn't start with the reserved _bl_ prefix.
  • The metrics history store persists everything into a single shared file, system_metrics.gob (internal/web/service/metric_history.go:300), and only ever uses the tag as an in-memory map key / JSON field, never as a filename or path — so there's no filesystem-safety reason for an ASCII-only allowlist either.

This also explains why warp is the one tag still showing up: it is the literal, hardcoded tag that 3x-ui's built-in Cloudflare WARP integration matches on (tag == "warp", internal/web/service/xray_setting.go:84), which is plain ASCII and passes the filter, unlike your other, presumably flag-prefixed, balancer members.

Recommendation: Relax validObsTag to accept the same tag values the rest of the panel already allows (effectively any non-empty string), instead of an ASCII allowlist. The tag is only ever used as a map key / JSON value (never a filename), and the frontend already encodeURIComponents it before using it in the history URL (XrayMetricsModal.tsx:212), so a strict charset restriction doesn't appear to protect anything currently in use. A minimal check (non-empty, perhaps excluding control characters) in applyObservatory, HasObservatoryTag, and AggregateObservatory should be enough.

Confidence: high — traced end-to-end from the regex definition through both call sites and the controller wiring, and cross-checked that outbound tags are unrestricted everywhere else in the panel (frontend schema, Xray-core config, and the metrics persistence layer).

@MHSanaei

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:4981901677 --> @github-actions[bot] commented on GitHub (Jul 15, 2026): Title: Xray Metrics' Observatory tab silently drops outbound tags containing any character outside `[a-zA-Z0-9._-]` Severity: Medium Category: Correctness Why this matters: The tag list shown in the panel's "Xray Metrics" → Observatory tab comes from `XrayMetricsService.ObservatorySnapshot()` (`internal/web/service/xray_metrics.go:80-89`), which only returns tags present in the in-memory `obsByTag` map. That map is populated in `applyObservatory` (`internal/web/service/xray_metrics.go:195-215`), and any tag that fails `validObsTag.MatchString(tag)` is skipped before it's ever added (line 202-204) — so it never reaches the `GET /panel/api/server/xrayObservatory` response the frontend dropdown is built from (`frontend/src/pages/index/XrayMetricsModal.tsx`, `fetchObservatory`). The same regex separately guards `HasObservatoryTag` and `AggregateObservatory` (lines 91-99, 101-106), so a direct history request for such a tag is also rejected by the controller as "invalid tag" (`internal/web/controller/server.go:171-182`). The regex is: ```go var validObsTag = regexp.MustCompile(`^[a-zA-Z0-9._\-]+$`) ``` (`internal/web/service/xray_metrics.go:51`) — ASCII letters/digits/`.`/`_`/`-` only. Any tag containing a space, emoji (including flag emoji used for country identification), or non-Latin text fails this and is silently dropped, even though: - Xray-core itself imposes no such restriction on outbound tags, so its own Observatory (read directly from Xray's `/debug/vars`) reports them correctly, consistent with your report that Observatory itself lists several outbounds. - The panel's own editors don't restrict tag characters either: `OutboundTagSchema` and `BalancerFormSchema.tag` (`frontend/src/schemas/xray.ts:112-130`) only require a non-empty tag that doesn't start with the reserved `_bl_` prefix. - The metrics history store persists everything into a single shared file, `system_metrics.gob` (`internal/web/service/metric_history.go:300`), and only ever uses the tag as an in-memory map key / JSON field, never as a filename or path — so there's no filesystem-safety reason for an ASCII-only allowlist either. This also explains why `warp` is the one tag still showing up: it is the literal, hardcoded tag that 3x-ui's built-in Cloudflare WARP integration matches on (`tag == "warp"`, `internal/web/service/xray_setting.go:84`), which is plain ASCII and passes the filter, unlike your other, presumably flag-prefixed, balancer members. Recommendation: Relax `validObsTag` to accept the same tag values the rest of the panel already allows (effectively any non-empty string), instead of an ASCII allowlist. The tag is only ever used as a map key / JSON value (never a filename), and the frontend already `encodeURIComponent`s it before using it in the history URL (`XrayMetricsModal.tsx:212`), so a strict charset restriction doesn't appear to protect anything currently in use. A minimal check (non-empty, perhaps excluding control characters) in `applyObservatory`, `HasObservatoryTag`, and `AggregateObservatory` should be enough. Confidence: high — traced end-to-end from the regex definition through both call sites and the controller wiring, and cross-checked that outbound tags are unrestricted everywhere else in the panel (frontend schema, Xray-core config, and the metrics persistence layer). @MHSanaei *This reply was generated automatically; a maintainer may follow up.*
Author
Owner

@MHSanaei commented on GitHub (Jul 23, 2026):

Fixed in #6083. Validates observatory outbound tags as bounded, control-free UTF-8 instead of ASCII-only, so flag-emoji / non-ASCII tags appear in metrics and health notifications.

<!-- gh-comment-id:5059092964 --> @MHSanaei commented on GitHub (Jul 23, 2026): Fixed in #6083. Validates observatory outbound tags as bounded, control-free UTF-8 instead of ASCII-only, so flag-emoji / non-ASCII tags appear in metrics and health notifications.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#4138
No description provided.