Feature Request: Add Statistics to API
Stale
## Summary
The blocky API currently doesn't expose runtime statistics. To build dashboards on [blocky-ui](https://github.com/GabeDuarteM/blocky-ui), I'm currently parsing the Prometheus `/metrics` endpoint directly, which requires implementing a custom parser for the Prometheus text format.
It would be helpful to have this data available via a REST API endpoint.
## Data Currently Missing from the API
The following information is only available via Prometheus metrics:
### Query Statistics
- **Total queries** (`blocky_query_total`) - total DNS queries processed
- **Blocked queries** (`blocky_response_total{response_type="BLOCKED"}`) - queries that were blocked
### Cache Statistics
- **Cache hits** (`blocky_cache_hits_total`)
- **Cache misses** (`blocky_cache_misses_total`)
### List Statistics
- **Denylist entries per group** (`blocky_denylist_cache_entries{group="..."}`) - number of blocked domains per group
> **Nice to have:** For query/cache stats, it would be useful to have these scoped to the last 24h instead of cumulative since startup - this makes dashboard stats more meaningful for day-to-day usage.
## Context
This data is already being tracked internally for Prometheus. Having it available as JSON would make it easier to build dashboards without requiring Prometheus text format parsing.
### Current Approach in blocky-ui
We display the following header:
<img width="1041" height="244" alt="Image" src="https://github.com/user-attachments/assets/fdaa42a2-1499-47a8-b69a-18d2e9283356" />
**Data sources:**
- **Total queries & blocked**: Query logs (from last 24h), falls back to Prometheus runtime totals if Query logs are disabled
- **Cache & list stats**: Prometheus metrics
**Current limitations:**
- If Prometheus is disabled (the default), we hide this entire panel
- Runtime totals are less useful than time-scoped stats for day-to-day monitoring
### Proposed Improvement
Having these stats in the API would allow us to always show this panel, regardless of Prometheus configuration.
---
I'm also familiar with Go and happy to contribute if that's helpful 😄
3 条评论