dashboard

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package dashboard provides the web UI and HTTP API server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IndexHandler

func IndexHandler(_ time.Duration) http.Handler

IndexHandler serves the embedded dashboard HTML/JS/CSS.

func Run

func Run(ctx context.Context, cfg Config) error

Run starts the dashboard HTTP server with the provided configuration.

Types

type Config

type Config struct {
	Addr         string  // ":8081"
	APIKey       string  // required for POST /api/v1/logs
	LogLevel     string  // "INFO"
	BufferSize   int     // optional (default 5000)
	ReadLimit    int     // optional (default 500)
	SERetryMs    int     // optional (default 2000) - SSE client retry hint
	RateRPS      float64 // optional (default 50)
	RateBurst    float64 // optional (default 100)
	WriteTimeout int     // optional (default 0 = no timeout) - HTTP write timeout in seconds
	Version      string  // optional - dashboard version for logging
}

Config holds the dashboard server configuration.

type EventBroadcaster added in v0.2.8

type EventBroadcaster interface {
	Add() chan []byte
	Remove(ch chan []byte)
	Send(p []byte)
}

EventBroadcaster defines the interface for broadcasting events to connected clients. Allows swapping SSE implementation or adding WebSocket support.

type LogEntry

type LogEntry struct {
	ID       int64           `json:"id,omitempty"`
	Time     time.Time       `json:"time"`
	Message  string          `json:"msg"`
	Fields   json.RawMessage `json:"fields,omitempty"`
	RemoteIP string          `json:"remote_ip,omitempty"`

	// Flattened (derived from Fields for API / SSE convenience)
	Action          string `json:"action,omitempty"`
	SourceIP        string `json:"source_ip,omitempty"`
	SourcePort      int    `json:"source_port,omitempty"`
	DestinationIP   string `json:"destination_ip,omitempty"`
	DestinationPort int    `json:"destination_port,omitempty"`
	Protocol        string `json:"protocol,omitempty"`
	PolicyHit       string `json:"policy_hit,omitempty"`
	PayloadLen      int    `json:"payload_len,omitempty"`
	HTTPS           string `json:"https,omitempty"`
	HTTPHost        string `json:"http_host,omitempty"`
	TenantID        string `json:"tenant_id,omitempty"`
	FlowID          string `json:"flow_id,omitempty"`
	Hostname        string `json:"hostname,omitempty"`
	Src             string `json:"src,omitempty"`
	Dst             string `json:"dst,omitempty"`
	Version         string `json:"version,omitempty"`
}

LogEntry represents a single ingested or synthetic log event.

type LogStore added in v0.2.8

type LogStore interface {
	Insert(ctx context.Context, e *LogEntry) (int64, error)
	Query(ctx context.Context, q string, sinceID int64, limit int) ([]LogEntry, error)
	Clear(ctx context.Context) error
}

LogStore defines the interface for log storage backends. Allows swapping between in-memory, database, or other implementations.

type RateLimiter added in v0.2.8

type RateLimiter interface {
	Allow(key string) bool
}

RateLimiter defines the interface for rate limiting strategies. Allows swapping between token bucket, sliding window, or external services.

type Server added in v0.2.8

type Server struct {
	// contains filtered or unexported fields
}

Server holds all dependencies for HTTP handlers.

Jump to

Keyboard shortcuts

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