Documentation
¶
Index ¶
- Constants
- type HTTPHandler
- func (h *HTTPHandler) GetDashboardServices(ctx context.Context, request httpapi.GetDashboardServicesRequestObject) (httpapi.GetDashboardServicesResponseObject, error)
- func (h *HTTPHandler) GetDashboardStats(ctx context.Context, request httpapi.GetDashboardStatsRequestObject) (httpapi.GetDashboardStatsResponseObject, error)
- func (h *HTTPHandler) GetDashboardTopDeniedIps(ctx context.Context, request httpapi.GetDashboardTopDeniedIpsRequestObject) (httpapi.GetDashboardTopDeniedIpsResponseObject, error)
- func (h *HTTPHandler) GetDashboardTraffic(ctx context.Context, request httpapi.GetDashboardTrafficRequestObject) (httpapi.GetDashboardTrafficResponseObject, error)
- type IPCount
- type Repository
- func (r *Repository) GetServiceSplit(ctx context.Context, from, to time.Time) ([]ServiceCount, error)
- func (r *Repository) GetSummaryStats(ctx context.Context, from, to time.Time) (SummaryStats, error)
- func (r *Repository) GetTopDeniedIPs(ctx context.Context, from, to time.Time, limit int) ([]IPCount, error)
- func (r *Repository) GetTrafficSeries(ctx context.Context, from, to time.Time, granularity timebucket.Granularity) ([]TrafficBucket, error)
- func (r *Repository) RunRollup(ctx context.Context, from, to time.Time) error
- type ServiceCount
- type SummaryStats
- type TrafficBucket
Constants ¶
const ( AttrKeyComponent = logging.AttrKeyComponent AttrKeyError = logging.AttrKeyError )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPHandler ¶
type HTTPHandler struct {
// contains filtered or unexported fields
}
func NewHTTPHandler ¶
func NewHTTPHandler(repo readRepo, logger *slog.Logger) *HTTPHandler
func (*HTTPHandler) GetDashboardServices ¶
func (h *HTTPHandler) GetDashboardServices( ctx context.Context, request httpapi.GetDashboardServicesRequestObject, ) (httpapi.GetDashboardServicesResponseObject, error)
func (*HTTPHandler) GetDashboardStats ¶
func (h *HTTPHandler) GetDashboardStats( ctx context.Context, request httpapi.GetDashboardStatsRequestObject, ) (httpapi.GetDashboardStatsResponseObject, error)
func (*HTTPHandler) GetDashboardTopDeniedIps ¶
func (h *HTTPHandler) GetDashboardTopDeniedIps( ctx context.Context, request httpapi.GetDashboardTopDeniedIpsRequestObject, ) (httpapi.GetDashboardTopDeniedIpsResponseObject, error)
func (*HTTPHandler) GetDashboardTraffic ¶
func (h *HTTPHandler) GetDashboardTraffic( ctx context.Context, request httpapi.GetDashboardTrafficRequestObject, ) (httpapi.GetDashboardTrafficResponseObject, error)
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository provides both read and write access to traffic aggregates.
func NewRepository ¶
func NewRepository(db *database.DB) *Repository
func (*Repository) GetServiceSplit ¶
func (r *Repository) GetServiceSplit(ctx context.Context, from, to time.Time) ([]ServiceCount, error)
GetServiceSplit returns per-host allow/deny counts.
func (*Repository) GetSummaryStats ¶
func (r *Repository) GetSummaryStats(ctx context.Context, from, to time.Time) (SummaryStats, error)
GetSummaryStats returns aggregate counts over the given time window.
func (*Repository) GetTopDeniedIPs ¶
func (r *Repository) GetTopDeniedIPs(ctx context.Context, from, to time.Time, limit int) ([]IPCount, error)
GetTopDeniedIPs returns the top denied IPs by total denied request count.
func (*Repository) GetTrafficSeries ¶
func (r *Repository) GetTrafficSeries(ctx context.Context, from, to time.Time, granularity timebucket.Granularity) ([]TrafficBucket, error)
GetTrafficSeries returns time-bucketed allow/deny counts. granularity must be "hour" or "day".
func (*Repository) RunRollup ¶
RunRollup aggregates access_log rows in [from, to) into hourly_traffic_aggregates. Idempotent via INSERT OR REPLACE on the unique index.
The strftime output is concatenated with '+00:00' so that bucket_at stores values in the same format the driver produces for time.Time parameters ("2006-01-02 15:04:05+00:00"), keeping WHERE comparisons consistent.
type ServiceCount ¶
type ServiceCount struct {
Host string `db:"host"`
AllowCount int64 `db:"allow_count"`
DenyCount int64 `db:"deny_count"`
}
ServiceCount holds per-host allow/deny counts.
type SummaryStats ¶
type SummaryStats struct {
TotalRequests int64 `db:"total_requests"`
AllowedCount int64 `db:"allowed_count"`
DeniedCount int64 `db:"denied_count"`
UniqueIPs int64 `db:"unique_ips"`
AvgDurationUs int64 `db:"avg_duration_us"`
}
SummaryStats holds aggregate counts for the stat cards.