[GH-ISSUE #5649] [Feature]: Per-Inbound Traffic Statistics for Each Client #3935

Open
opened 2026-10-31 20:36:00 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @mldfiroozeh-droid on GitHub (Jun 29, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5649

Currently, when a client is assigned to multiple inbound configurations, X-UI only displays the client's total traffic usage. There is no way to determine how much traffic the client has consumed through each individual inbound.

This makes it difficult to:

Analyze traffic distribution across different inbounds.
Troubleshoot routing or performance issues.
Identify which inbound is being used the most.
Generate accurate usage reports for users with multiple inbounds.

Describe the solution you'd like

Add per-inbound traffic tracking for each client.

For example, if a client is assigned to three different inbounds:

Inbound A → 12.3 GB
Inbound B → 4.8 GB
Inbound C → 0.9 GB
Total → 18.0 GB

The total traffic can remain as it is today, but the UI should also provide a breakdown of traffic usage by inbound.

Benefits

Better monitoring and troubleshooting.
More accurate traffic analytics.
Easier management of users assigned to multiple inbounds.
Improved visibility into how each inbound is being utilized.

This feature would be especially useful for administrators who use multiple inbounds for different protocols, locations, routing strategies, or load balancing.

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?

  • I'd like to implement this feature myself and open a PR.
  • I can help test once a PR is open.

Before submitting

  • I searched existing issues and this feature has not been requested.
  • This feature request is written in English.
Originally created by @mldfiroozeh-droid on GitHub (Jun 29, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5649 ### Is your feature request related to a problem? Currently, when a client is assigned to multiple inbound configurations, X-UI only displays the client's total traffic usage. There is no way to determine how much traffic the client has consumed through each individual inbound. This makes it difficult to: Analyze traffic distribution across different inbounds. Troubleshoot routing or performance issues. Identify which inbound is being used the most. Generate accurate usage reports for users with multiple inbounds. ### Describe the solution you'd like Add per-inbound traffic tracking for each client. For example, if a client is assigned to three different inbounds: Inbound A → 12.3 GB Inbound B → 4.8 GB Inbound C → 0.9 GB Total → 18.0 GB The total traffic can remain as it is today, but the UI should also provide a breakdown of traffic usage by inbound. Benefits Better monitoring and troubleshooting. More accurate traffic analytics. Easier management of users assigned to multiple inbounds. Improved visibility into how each inbound is being utilized. This feature would be especially useful for administrators who use multiple inbounds for different protocols, locations, routing strategies, or load balancing. ### 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? - [ ] I'd like to implement this feature myself and open a PR. - [ ] I can help test once a PR is open. ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this feature has not been requested. - [x] This feature request is written in English.
Author
Owner

@github-actions[bot] commented on GitHub (Jun 29, 2026):

This is a valid request. A closely related issue was filed as #4583 and subsequently closed without an implementation landing, so the underlying gap still exists.

Current implementation

Traffic accounting in 3x-ui works as follows (verified against the source):

  • internal/xray/client_traffic.go — the ClientTraffic struct has a gorm:"unique" constraint on Email, meaning there is exactly one row per client email in the client_traffics table, regardless of how many inbounds that client is attached to. The InboundId field on that struct is stale once a client is linked to more than one inbound and is not used for traffic matching.
  • internal/xray/api.go — the Xray gRPC stats service is polled on a regular interval. Two regex patterns extract the raw counters:
    inbound>>>TAG>>>traffic>>>(downlink|uplink)   ← per-inbound total
    user>>>EMAIL>>>traffic>>>(downlink|uplink)     ← per-user total (all inbounds combined)
    
  • internal/web/service/inbound_traffic.go — AddTraffic() accumulates these into inbounds.up/inbounds.down (per inbound total) and client_traffics.up/client_traffics.down (per client total), keyed only by email.

Root constraint

Xray-core's stats gRPC service does not emit a combined per-inbound per-user counter. The two series above are independent: knowing that user>>>alice used 18 GB and that inbound>>>vless-tls served 30 GB total does not tell you how much of alice's 18 GB came through vless-tls. There is no inbound>>>TAG>>>user>>>EMAIL>>>traffic stat in the Xray stats API today.

Without that upstream data point, any per-inbound per-client breakdown in the 3x-ui UI would require either:

  1. A new stat counter added to Xray-core's stats service (upstream change), or
  2. Out-of-band packet accounting (e.g. eBPF or iptables per-user per-port counters), which is platform-specific and significantly more complex.

This explains why #4583 was not implemented despite being accepted as a reasonable request.

This issue has been labeled as a backlog feature. Contributions toward an upstream Xray-core stat or an alternative accounting mechanism are welcome; a PR that addresses this would be considered.


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

<!-- gh-comment-id:4829431451 --> @github-actions[bot] commented on GitHub (Jun 29, 2026): This is a valid request. A closely related issue was filed as #4583 and subsequently closed without an implementation landing, so the underlying gap still exists. **Current implementation** Traffic accounting in 3x-ui works as follows (verified against the source): - `internal/xray/client_traffic.go` — the `ClientTraffic` struct has a `gorm:"unique"` constraint on `Email`, meaning there is exactly **one row per client email** in the `client_traffics` table, regardless of how many inbounds that client is attached to. The `InboundId` field on that struct is stale once a client is linked to more than one inbound and is not used for traffic matching. - `internal/xray/api.go` — the Xray gRPC stats service is polled on a regular interval. Two regex patterns extract the raw counters: ``` inbound>>>TAG>>>traffic>>>(downlink|uplink) ← per-inbound total user>>>EMAIL>>>traffic>>>(downlink|uplink) ← per-user total (all inbounds combined) ``` - `internal/web/service/inbound_traffic.go` — `AddTraffic()` accumulates these into `inbounds.up`/`inbounds.down` (per inbound total) and `client_traffics.up`/`client_traffics.down` (per client total), keyed only by email. **Root constraint** Xray-core's stats gRPC service does not emit a combined per-inbound per-user counter. The two series above are independent: knowing that `user>>>alice` used 18 GB and that `inbound>>>vless-tls` served 30 GB total does not tell you how much of `alice`'s 18 GB came through `vless-tls`. There is no `inbound>>>TAG>>>user>>>EMAIL>>>traffic` stat in the Xray stats API today. Without that upstream data point, any per-inbound per-client breakdown in the 3x-ui UI would require either: 1. A new stat counter added to Xray-core's stats service (upstream change), or 2. Out-of-band packet accounting (e.g. eBPF or iptables per-user per-port counters), which is platform-specific and significantly more complex. This explains why #4583 was not implemented despite being accepted as a reasonable request. This issue has been labeled as a backlog feature. Contributions toward an upstream Xray-core stat or an alternative accounting mechanism are welcome; a PR that addresses this would be considered. --- *This reply was generated automatically; a maintainer may follow up.*
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#3935
No description provided.