Dashboard

Configuration

Full config reference with all options, YAML example, validation rules, and functional options

YAML Configuration

config.yaml
extensions:
  dashboard:
    # Server
    base_path: "/dashboard"
    title: "Forge Dashboard"

    # Features
    enable_realtime: true
    enable_export: true
    enable_search: true
    enable_settings: true
    enable_discovery: false
    enable_bridge: true

    # Authentication
    enable_auth: false
    login_path: "/auth/login"
    logout_path: "/auth/logout"
    default_access: "public"     # "public", "protected", "partial"

    # Data collection
    refresh_interval: "30s"
    history_duration: "1h"
    max_data_points: 1000

    # Proxy / Remote contributors
    proxy_timeout: "10s"
    cache_max_size: 1000
    cache_ttl: "30s"

    # SSE
    sse_keep_alive: "15s"

    # Security
    enable_csp: true
    enable_csrf: true

    # Theming
    theme: "auto"            # "auto", "light", "dark"
    custom_css: ""

    # Discovery
    discovery_tag: "forge-dashboard-contributor"
    discovery_poll_interval: "60s"

    # Export
    export_formats:
      - "json"
      - "csv"
      - "prometheus"

The extension loads config from extensions.dashboard first, falling back to dashboard.

Programmatic Configuration

All options use the functional options pattern:

ext := dashboard.NewExtension(
    dashboard.WithBasePath("/admin/dashboard"),
    dashboard.WithTitle("Admin Panel"),
    dashboard.WithRealtime(true),
    dashboard.WithExport(true),
    dashboard.WithSearch(true),
    dashboard.WithSettings(true),
    dashboard.WithBridge(true),
    dashboard.WithEnableAuth(true),
    dashboard.WithDefaultAccess("protected"),
    dashboard.WithLoginPath("/auth/login"),
    dashboard.WithRefreshInterval(30 * time.Second),
    dashboard.WithHistoryDuration(2 * time.Hour),
    dashboard.WithMaxDataPoints(2000),
    dashboard.WithTheme("auto"),
    dashboard.WithCSP(true),
    dashboard.WithCSRF(true),
)

Config Reference

Server

FieldTypeDefaultOptionDescription
BasePathstring"/dashboard"WithBasePath()HTTP base path for all dashboard routes
Titlestring"Forge Dashboard"WithTitle()Page title shown in browser tab and header

Features

FieldTypeDefaultOptionDescription
EnableRealtimebooltrueWithRealtime()SSE real-time event stream
EnableExportbooltrueWithExport()Data export endpoints (JSON, CSV, Prometheus)
EnableSearchbooltrueWithSearch()Federated cross-contributor search
EnableSettingsbooltrueWithSettings()Aggregated settings page
EnableDiscoveryboolfalseWithDiscovery()Auto-discover remote contributors via service discovery
EnableBridgebooltrueWithBridge()Go-JS bridge function system

Authentication

FieldTypeDefaultOptionDescription
EnableAuthboolfalseWithEnableAuth()Enable authentication and page access control
LoginPathstring"/auth/login"WithLoginPath()Relative path to the login page
LogoutPathstring"/auth/logout"WithLogoutPath()Relative path to the logout page
DefaultAccessstring"public"WithDefaultAccess()Default access level for pages: public, protected, or partial

When EnableAuth is true, every page route is wrapped with authentication middleware. Pages default to the DefaultAccess level unless overridden per-page via the contributor manifest NavItem.Access field.

An AuthChecker must be set on the extension at runtime (SetAuthChecker(checker)) to perform actual authentication validation. Without a checker, auth is effectively a no-op.

Data Collection

FieldTypeDefaultOptionDescription
RefreshIntervaltime.Duration30sWithRefreshInterval()How often to collect metrics and health data
HistoryDurationtime.Duration1hWithHistoryDuration()How long to retain historical data points
MaxDataPointsint1000WithMaxDataPoints()Maximum number of data points in history

Proxy / Remote Contributors

FieldTypeDefaultOptionDescription
ProxyTimeouttime.Duration10sWithProxyTimeout()Timeout for requests to remote contributors
CacheMaxSizeint1000WithCacheMaxSize()Max entries in the fragment proxy LRU cache
CacheTTLtime.Duration30sWithCacheTTL()Time-to-live for cached remote fragments

SSE

FieldTypeDefaultOptionDescription
SSEKeepAlivetime.Duration15sWithSSEKeepAlive()Interval for SSE keep-alive pings

Security

FieldTypeDefaultOptionDescription
EnableCSPbooltrueWithCSP()Add Content-Security-Policy headers
EnableCSRFbooltrueWithCSRF()CSRF token protection for forms and bridge calls

Theming

FieldTypeDefaultOptionDescription
Themestring"auto"WithTheme()Theme mode: auto, light, or dark
CustomCSSstring""WithCustomCSS()Custom CSS injected into the dashboard

Discovery

FieldTypeDefaultOptionDescription
DiscoveryTagstring"forge-dashboard-contributor"WithDiscoveryTag()Service discovery tag to filter contributors
DiscoveryPollIntervaltime.Duration60sWithDiscoveryPollInterval()How often to poll for new remote contributors

Export

FieldTypeDefaultOptionDescription
ExportFormats[]string["json","csv","prometheus"]WithExportFormats()Supported export formats

Internal

FieldTypeDefaultOptionDescription
RequireConfigboolfalseWithRequireConfig()Require config from ConfigManager (fail if missing)

Functional Options

All options are available as ConfigOption functions:

// Server
dashboard.WithBasePath(path string)
dashboard.WithTitle(title string)

// Features
dashboard.WithRealtime(enabled bool)
dashboard.WithExport(enabled bool)
dashboard.WithSearch(enabled bool)
dashboard.WithSettings(enabled bool)
dashboard.WithDiscovery(enabled bool)
dashboard.WithBridge(enabled bool)

// Authentication
dashboard.WithEnableAuth(enabled bool)
dashboard.WithLoginPath(path string)
dashboard.WithLogoutPath(path string)
dashboard.WithDefaultAccess(access string)

// Data collection
dashboard.WithRefreshInterval(interval time.Duration)
dashboard.WithHistoryDuration(duration time.Duration)
dashboard.WithMaxDataPoints(maxPoints int)

// Proxy
dashboard.WithProxyTimeout(timeout time.Duration)
dashboard.WithCacheMaxSize(size int)
dashboard.WithCacheTTL(ttl time.Duration)

// SSE
dashboard.WithSSEKeepAlive(interval time.Duration)

// Security
dashboard.WithCSP(enabled bool)
dashboard.WithCSRF(enabled bool)

// Theming
dashboard.WithTheme(theme string)
dashboard.WithCustomCSS(css string)

// Discovery
dashboard.WithDiscoveryTag(tag string)
dashboard.WithDiscoveryPollInterval(interval time.Duration)

// Export
dashboard.WithExportFormats(formats []string)

// Advanced
dashboard.WithConfig(config Config)       // Set complete config
dashboard.WithRequireConfig(required bool) // Require config from ConfigManager

Validation Rules

The config is validated during Register(). The following constraints apply:

FieldRule
BasePathMust not be empty
RefreshIntervalMinimum 1 second
MaxDataPointsMinimum 10
ThemeMust be light, dark, or auto
ProxyTimeoutMinimum 1 second
CacheMaxSizeMust not be negative
DefaultAccessMust be public, protected, or partial (when EnableAuth is true)

If validation fails, Register() returns an error and the dashboard will not start.

How is this guide?

On this page