mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6353] [Feature]: Traffic Usage History by Custom Date Range #4310
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#4310
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 @zulfiqar-shaloom on GitHub (Aug 28, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6353
Is your feature request related to a problem?
Currently, 3X-UI only shows the current/total traffic usage for clients. There is no easy way to check how much traffic a specific client, or all clients combined, used during a specific period such as the last 7 days, last 30 days, or between two custom dates.
Describe the solution you'd like
I would like 3X-UI to store historical traffic usage statistics for each client.
It would be useful to have a traffic statistics page where we can:
View upload, download, and total usage for each client.
View the combined traffic usage of all clients.
Select preset periods such as Today, Last 7 Days, and Last 30 Days.
Select a custom date range (From / To).
Optionally view daily traffic usage and sort clients by highest usage.
Ideally, these statistics should remain available even when the client's traffic counter is reset.
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 (Aug 28, 2026):
This is a valid feature request, and none of it exists at the tip (latest release
v3.7.0): the panel stores no traffic history at all today, so there is nothing that could be sliced by a date range yet.What the source says
Per-client usage is one row per client in
client_traffics, holding two cumulative counters and no time dimension —internal/xray/client_traffic.go:12-13:allModels()(internal/database/db.go:65-88) lists every table the panel creates, and there is no per-day/per-period traffic table among them.A reset overwrites those two counters in place; nothing is archived first —
internal/web/service/inbound_traffic.go:628-631:The only time series the panel keeps is whole-host system metrics (CPU / memory / network), in an in-memory rollup ladder capped at 7 days —
internal/web/service/metric_history.go:33-37:That series is host-wide and never per-client, so it cannot answer "how much did client X use last week".
What already works today
One item on your list is done: sorting clients by usage — but of the current counters, not of a date range. Route
internal/web/controller/client.go:49, sort key handled atinternal/web/service/client_paging.go:316:Per-client counters for a single client come from
GET /panel/api/clients/traffic/:email(internal/web/controller/client.go:52), andGET /panel/api/inbounds/listreturns each inbound'sclientStats. The token comes from Settings → Security → API Token (docs/content/docs/en/reference/api/authentication.mdx:5).Until the panel stores history, a date range has to be reconstructed outside it: poll one of those endpoints on a cron, store
(email, timestamp, up, down)yourself, and difference consecutive samples. One caveat that will otherwise corrupt your totals — because a reset zeroesup/downin place (the code above), a sample lower than the previous one means a new cycle started, so count the full new value as the delta instead of a negative.Prior discussion worth reading
The "statistics survive a reset" half of this request has history: in #4532 the repository owner answered "All time traffic? Yes, i removed it on purpose", and #4756, which asked for that column back, was closed as a duplicate of it. I am deliberately not closing this as a duplicate — those two ask for a single cumulative all-time number, while you are asking for a per-period store queryable by date, which is a different data model — but the survives-reset part does restate a decision that was already made once, so that piece is the maintainer's call rather than an oversight.
#4947 (labelled
backlog) overlaps from the other side: a per-client daily fair-usage limit needs the same per-day baseline you are asking to expose, so both would likely be served by one storage change.Verdict: Feature request
This reply was generated automatically; a maintainer may follow up.
@abolfazlakbarzadeh commented on GitHub (Oct 14, 2026):
I made a tool:
https://github.com/abolfazlakbarzadeh/3x-ui-traffic-monitor
@HamedSanaei commented on GitHub (Oct 26, 2026):
@MHSanaei I recommend closing this issue as not planned.
I've used 3x-ui for about five years, and in my experience, a built-in historical traffic dashboard would not add enough practical value to the core panel to justify its ongoing maintenance and resource costs. It introduces additional database writes, storage growth, index/backup overhead, query CPU, and some memory usage—especially on large deployments and multi-node setups. I would rather keep 3x-ui focused on reliable traffic accounting and enforcement than add an optional reporting subsystem that every installation must carry.
If this feature were ever accepted, I would strongly recommend a minimal, opt-in implementation instead of collecting and persisting snapshots at the existing 5-second traffic-poll interval:
Even with these safeguards, the added complexity and ongoing overhead remain real. The earlier decision to intentionally remove all-time traffic (#4532) is also worth considering, although this request is not exactly the same feature.
My recommendation is to close #6353 as not planned, unless there is clear maintainer demand and measured evidence that the benefits outweigh those costs. Anyone who specifically needs historical analytics could use an external monitoring/reporting tool instead.
@abolfazlakbarzadeh commented on GitHub (Oct 26, 2026):
If we have it as a optional feature that can be enabled/disabled based on user desire would be good, based on situation and infra, for example I'm using a paid traffic-based CDN for tunneling traffic to foreign server and for some users I wanna see how much traffic a user is consuming for example 1 day to 1 week, it can be upon to server admin to use this feature according to its DB/processing-load