[GH-ISSUE #6254] [Feature]: Separate statistics for blocked requests #4244

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

Originally created by @LORD07Sson on GitHub (Aug 18, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6254

Yes. Currently, there is no clear, separate statistic showing the total number of blocked requests. This makes it difficult to quickly determine how many requests were blocked and to monitor blocking activity over time.
A dedicated blocked-requests statistic would make the filtering results much easier to understand and monitor

Describe the solution you'd like

I would like the panel to provide a separate statistic for the number of blocked requests.
Add a "blocked requests" counter to the main statistics/dashboard section alongside the existing request statistics

For example:

Total Requests: ***
Blocked Requests: ***
Allowed Requests: ***

The blocked counter should be clearly distinguishable from the total request count and should support the same time ranges as the existing statistics (day, 7 days, 30 days).

Alternatives you've considered

I considered using the existing request statistics and checking the logs to determine how many requests were blocked.

However, this is not very convenient because it requires manually analyzing the data and does not provide a quick overview of blocking activity. A separate "blocked requests" statistic on the dashboard would be much clearer, more accurate, and easier to monitor over time

Concrete use case

No response

Mockups, screenshots, or examples

A simple example of the desired UI would be:

Statistics

  • Total Requests: 125,430
  • Blocked Requests: 18,742
  • Allowed Requests: 106,688

Ideally, "blocked requests" should be displayed as a separate statistic/card on the main dashboard and use the same time-range filters as the existing statistics.

No specific configuration changes are required from the user; the value should be calculated automatically from the panel's existing request/filtering data. Let's take an example, adguard home

Which parts of the panel would this affect?

Frontend (UI / panel pages), Statistics / traffic counters

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 @LORD07Sson on GitHub (Aug 18, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6254 ### Is your feature request related to a problem? Yes. Currently, there is no clear, separate statistic showing the total number of blocked requests. This makes it difficult to quickly determine how many requests were blocked and to monitor blocking activity over time. A dedicated blocked-requests statistic would make the filtering results much easier to understand and monitor ### Describe the solution you'd like I would like the panel to provide a separate statistic for the number of blocked requests. Add a "blocked requests" counter to the main statistics/dashboard section alongside the existing request statistics For example: Total Requests: *** Blocked Requests: *** Allowed Requests: *** The blocked counter should be clearly distinguishable from the total request count and should support the same time ranges as the existing statistics (day, 7 days, 30 days). ### Alternatives you've considered I considered using the existing request statistics and checking the logs to determine how many requests were blocked. However, this is not very convenient because it requires manually analyzing the data and does not provide a quick overview of blocking activity. A separate "blocked requests" statistic on the dashboard would be much clearer, more accurate, and easier to monitor over time ### Concrete use case _No response_ ### Mockups, screenshots, or examples A simple example of the desired UI would be: **Statistics** * Total Requests: 125,430 * Blocked Requests: 18,742 * Allowed Requests: 106,688 Ideally, "blocked requests" should be displayed as a separate statistic/card on the main dashboard and use the same time-range filters as the existing statistics. No specific configuration changes are required from the user; the value should be calculated automatically from the panel's existing request/filtering data. Let's take an example, adguard home ### Which parts of the panel would this affect? Frontend (UI / panel pages), Statistics / traffic counters ### 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.
bsakaguchi 2026-10-31 20:38:15 +07:00
Author
Owner

@github-actions[bot] commented on GitHub (Aug 18, 2026):

The panel does not count requests anywhere today, so this would be a new counting mechanism rather than a new card computed from existing data. Everything currently labelled "statistics" is either a byte counter or a live gauge:

  • Per-client and per-inbound totals come from Xray's stats API, and the panel only reads byte counters from it: the parsers in internal/xray/api.go:46-47 match inbound|outbound>>>tag>>>traffic>>>uplink|downlink and user>>>email>>>traffic>>>uplink|downlink, nothing else. Stored values are bytes (Up/Down in internal/xray/client_traffic.go:12-13).
  • The dashboard connections tile is the number of currently open TCP/UDP sockets on the host, not a cumulative request count (frontend/src/pages/index/ConnectionsCard.tsx:35).

What already exists closest to your request:

  1. Blocked-vs-allowed classification per request, in the Xray log viewer on the dashboard. GetXrayLogs in internal/web/service/server.go:1170 tags each access-log line Direct / Blocked / Proxied, marking it Blocked when the line's outbound tag matches a blackhole outbound (GetDefaultLogOutboundTags, internal/web/service/server.go:289, falling back to the tag blocked). The Direct/Blocked/Proxy checkboxes are in frontend/src/pages/index/XrayLogModal.tsx:181-189. It lists the entries; it never totals them.
    This requires the access log to be on — the shipped template sets "access": "none" (internal/web/service/config.json:21). Enable it in Xray Configs → Basics → Access log, where the only two options are none and ./access.log (frontend/src/pages/xray/basics/constants.ts:3).
  2. Blocked volume in bytes per outbound tag. statsOutboundUplink and statsOutboundDownlink ship disabled (internal/web/service/config.json:58-59) and can be turned on in the same Basics tab (frontend/src/pages/xray/basics/BasicsTab.tsx:280). With them on, the traffic job records per-outbound-tag totals (internal/web/service/outbound/outbound.go:41, model OutboundTraffics) and the Outbounds tab shows traffic for the blocked outbound. That gives blocked bytes, not a blocked request count.

Two constraints anyone implementing this would hit:

  • Counting from the access log is lossy by design: PruneXrayLogsJob truncates the access and error logs once either exceeds 64 MiB (internal/web/job/clear_logs_job.go:12), so totals derived from the file would drop history at each truncation.
  • The 30-day range would need new persistent storage and a DB migration. The in-panel metric history ladder tops out at 7 days (internal/web/service/metric_history.go:32-36).

One note on the AdGuard Home comparison: AdGuard counts DNS queries it filters, whereas 3x-ui proxies connections and takes its numbers from Xray, which exposes byte counters rather than request counters. Whether to add per-request counting is @MHSanaei's decision.

This reply was generated automatically. A maintainer may follow up.

<!-- gh-comment-id:5329654743 --> @github-actions[bot] commented on GitHub (Aug 18, 2026): The panel does not count requests anywhere today, so this would be a new counting mechanism rather than a new card computed from existing data. Everything currently labelled "statistics" is either a byte counter or a live gauge: - Per-client and per-inbound totals come from Xray's stats API, and the panel only reads byte counters from it: the parsers in `internal/xray/api.go:46-47` match `inbound|outbound>>>tag>>>traffic>>>uplink|downlink` and `user>>>email>>>traffic>>>uplink|downlink`, nothing else. Stored values are bytes (`Up`/`Down` in `internal/xray/client_traffic.go:12-13`). - The dashboard connections tile is the number of currently open TCP/UDP sockets on the host, not a cumulative request count (`frontend/src/pages/index/ConnectionsCard.tsx:35`). What already exists closest to your request: 1. Blocked-vs-allowed classification per request, in the Xray log viewer on the dashboard. `GetXrayLogs` in `internal/web/service/server.go:1170` tags each access-log line Direct / Blocked / Proxied, marking it Blocked when the line's outbound tag matches a `blackhole` outbound (`GetDefaultLogOutboundTags`, `internal/web/service/server.go:289`, falling back to the tag `blocked`). The Direct/Blocked/Proxy checkboxes are in `frontend/src/pages/index/XrayLogModal.tsx:181-189`. It lists the entries; it never totals them. This requires the access log to be on — the shipped template sets `"access": "none"` (`internal/web/service/config.json:21`). Enable it in Xray Configs → Basics → Access log, where the only two options are `none` and `./access.log` (`frontend/src/pages/xray/basics/constants.ts:3`). 2. Blocked volume in bytes per outbound tag. `statsOutboundUplink` and `statsOutboundDownlink` ship disabled (`internal/web/service/config.json:58-59`) and can be turned on in the same Basics tab (`frontend/src/pages/xray/basics/BasicsTab.tsx:280`). With them on, the traffic job records per-outbound-tag totals (`internal/web/service/outbound/outbound.go:41`, model `OutboundTraffics`) and the Outbounds tab shows traffic for the `blocked` outbound. That gives blocked bytes, not a blocked request count. Two constraints anyone implementing this would hit: - Counting from the access log is lossy by design: `PruneXrayLogsJob` truncates the access and error logs once either exceeds 64 MiB (`internal/web/job/clear_logs_job.go:12`), so totals derived from the file would drop history at each truncation. - The 30-day range would need new persistent storage and a DB migration. The in-panel metric history ladder tops out at 7 days (`internal/web/service/metric_history.go:32-36`). One note on the AdGuard Home comparison: AdGuard counts DNS queries it filters, whereas 3x-ui proxies connections and takes its numbers from Xray, which exposes byte counters rather than request counters. Whether to add per-request counting is @MHSanaei's decision. *This reply was generated automatically. A maintainer may follow up.*
Author
Owner

@LORD07Sson commented on GitHub (Aug 18, 2026):

Exactly, I didn't think about that. Thanks

<!-- gh-comment-id:5330319147 --> @LORD07Sson commented on GitHub (Aug 18, 2026): Exactly, I didn't think about that. Thanks
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#4244
No description provided.