dashboard

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
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

type IPCount

type IPCount struct {
	IP    string `db:"ip"`
	Count int64  `db:"count"`
}

IPCount pairs an IP address with its request count.

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 *sqlx.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

func (r *Repository) RunRollup(ctx context.Context, from, to time.Time) error

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.

type TrafficBucket

type TrafficBucket struct {
	Timestamp  database.DBTime `db:"timestamp"`
	AllowCount int64           `db:"allow_count"`
	DenyCount  int64           `db:"deny_count"`
}

TrafficBucket holds allow/deny counts for a single time bucket.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL