dashboard

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

README

Dashboard Extension

A production-ready health and metrics dashboard extension for Forge v2 with real-time monitoring, data export, and a modern web UI.

Features

  • Real-time Monitoring: WebSocket-based live updates of health checks and metrics
  • Health Checks: Monitor all registered services with detailed status information
  • Metrics Display: View system metrics with historical trends
  • Beautiful UI: Modern, responsive interface built with Tailwind CSS
  • Interactive Charts: Visualize data with ApexCharts
  • Data Export: Export dashboard data in JSON, CSV, and Prometheus formats
  • Dark Mode: Auto, light, and dark theme support
  • Time-series Data: Configurable data retention and history
  • Zero Build: No compilation needed - uses CDN for assets

Installation

The dashboard extension is included in Forge v2. Simply import it:

import "github.com/xraph/forge/extensions/dashboard"

Quick Start

package main

import (
    "context"
    "log"

    "github.com/xraph/forge"
    "github.com/xraph/forge/extensions/dashboard"
)

func main() {
    // Create Forge app
    app := forge.NewApp(forge.AppConfig{
        Name:        "my-app",
        Version:     "1.0.0",
        Environment: "production",
    })

    // Register dashboard extension
    app.RegisterExtension(dashboard.NewExtension(
        dashboard.WithPort(8080),
        dashboard.WithTitle("My App Dashboard"),
    ))

    // Start app
    ctx := context.Background()
    if err := app.Start(ctx); err != nil {
        log.Fatal(err)
    }

    // Dashboard available at http://localhost:8080/dashboard
    select {}
}

UI Features

Overview Tab
  • Summary Cards: Overall health, service count, metrics count, and system uptime
  • Interactive Charts: Historical health and service count trends
  • Health Checks Table: Detailed table of all health checks with status indicators
  • Services Grid: Clickable service cards for quick access to details
  • Export Options: One-click export in multiple formats
Service Detail Modal

Click any service card to open a modal with:

  • Service status and type
  • Last health check information
  • Service-specific metrics
  • Health details and messages
Metrics Report Tab
  • Statistics Overview: Total metrics, breakdown by type (counters, gauges, histograms, timers)
  • Type Distribution Chart: Pie chart showing metric type distribution
  • Active Collectors Table: All registered metrics collectors with status
  • Top Metrics List: Current values of top 20 metrics
Theme Support
  • Dark Mode: Full dark mode support for all UI elements
  • Theme Toggle: Persistent theme preference via localStorage
  • Auto Detection: Respects system preference if not explicitly set
  • Smooth Transitions: Animated color transitions between themes

Configuration

Programmatic Configuration
app.RegisterExtension(dashboard.NewExtension(
    dashboard.WithPort(8080),                          // Server port
    dashboard.WithBasePath("/dashboard"),              // Base URL path
    dashboard.WithTitle("My Dashboard"),               // Dashboard title
    dashboard.WithTheme("auto"),                       // Theme: auto, light, dark
    dashboard.WithRealtime(true),                      // Enable WebSocket updates
    dashboard.WithRefreshInterval(30*time.Second),     // Data refresh interval
    dashboard.WithExport(true),                        // Enable data export
    dashboard.WithHistoryDuration(1*time.Hour),        // Data retention period
    dashboard.WithMaxDataPoints(1000),                 // Max historical points
))
YAML Configuration

Create a config.yaml:

extensions:
  dashboard:
    port: 8080
    base_path: "/dashboard"
    
    # Features
    enable_auth: false
    enable_realtime: true
    enable_export: true
    export_formats:
      - json
      - csv
      - prometheus
    
    # Data collection
    refresh_interval: 30s
    history_duration: 1h
    max_data_points: 1000
    
    # UI settings
    theme: "auto"  # auto, light, dark
    title: "My Application Dashboard"
    
    # Server settings
    read_timeout: 30s
    write_timeout: 30s
    shutdown_timeout: 10s

Load configuration:

app.RegisterExtension(dashboard.NewExtension(
    dashboard.WithRequireConfig(true),
))

API Endpoints

Overview Data
GET /dashboard/api/overview

Returns overview of system health, services, metrics, and uptime.

Response:

{
  "timestamp": "2025-10-22T10:30:00Z",
  "overall_health": "healthy",
  "total_services": 5,
  "healthy_services": 5,
  "total_metrics": 42,
  "uptime": 3600000000000,
  "version": "1.0.0",
  "environment": "production"
}
Health Checks
GET /dashboard/api/health

Returns detailed health check results for all services.

Metrics
GET /dashboard/api/metrics

Returns all current metrics.

Services
GET /dashboard/api/services

Returns list of registered services.

Historical Data
GET /dashboard/api/history

Returns time-series historical data.

Data Export

JSON Export
GET /dashboard/export/json

Exports complete dashboard snapshot as JSON.

CSV Export
GET /dashboard/export/csv

Exports dashboard data as CSV file.

Prometheus Metrics
GET /dashboard/export/prometheus

Exports metrics in Prometheus text format for scraping.

WebSocket API

Connect to real-time updates:

const ws = new WebSocket('ws://localhost:8080/dashboard/ws');

ws.onmessage = (event) => {
  const message = JSON.parse(event.data);
  
  switch (message.type) {
    case 'overview':
      console.log('Overview update:', message.data);
      break;
    case 'health':
      console.log('Health update:', message.data);
      break;
  }
};

// Send ping
ws.send(JSON.stringify({ type: 'ping' }));

Advanced Usage

Custom Dashboard Server

Access the dashboard server for advanced operations:

dashboard := dashboard.NewExtension()
app.RegisterExtension(dashboard)

// After app starts
server := dashboard.Server()

// Access collector
collector := server.GetCollector()
overview := collector.CollectOverview(ctx)

// Access history
history := server.GetHistory()
data := history.GetAll()
Integration with DI Container

The dashboard server is registered in the DI container:

// Resolve dashboard from container
dashboardServer, err := forge.Resolve[*dashboard.DashboardServer](app.Container(), "dashboard")
if err != nil {
    log.Fatal(err)
}

// Use dashboard server
collector := dashboardServer.GetCollector()

UI Features

Overview Cards
  • Overall system health status
  • Service counts (healthy/total)
  • Total metrics tracked
  • System uptime
Charts
  • Service health history
  • Service count trends
  • Interactive with zoom/pan
  • Auto-updating with WebSocket
Health Checks Table
  • Real-time service status
  • Health check messages
  • Check duration
  • Last checked timestamp
Services List
  • All registered services
  • Service types
  • Current status
Export Buttons
  • Quick access to JSON export
  • CSV download
  • Prometheus metrics
Theme Toggle
  • Auto (system preference)
  • Light mode
  • Dark mode
  • Persistent per session

Performance

  • Efficient Data Collection: Configurable refresh intervals
  • Memory-Efficient: Ring buffer for historical data
  • Concurrent Operations: Thread-safe data access
  • WebSocket Optimizations: Client-side reconnection, heartbeats
  • Minimal Overhead: ~5MB memory, <1% CPU when idle

Production Considerations

Security
  1. Enable Authentication: Use WithAuth(true) and implement auth middleware
  2. HTTPS: Always use TLS in production
  3. CORS: Configure proper CORS policies
  4. Rate Limiting: Add rate limiting for API endpoints
Monitoring

The dashboard monitors itself:

  • Health check for server status
  • Metrics for request counts
  • WebSocket connection counts
  • Export operation tracking
Scalability
  • WebSocket supports 100+ concurrent connections
  • Historical data auto-trimmed based on retention policy
  • Efficient memory usage with ring buffers
  • Graceful degradation if WebSocket fails

Troubleshooting

Dashboard Won't Start

Check logs for:

  • Port conflicts (default 8080)
  • Permission issues
  • Configuration errors
WebSocket Not Connecting
  1. Check browser console for errors
  2. Verify firewall allows WebSocket
  3. Ensure enable_realtime: true in config
  4. Check WebSocket URL (ws:// for HTTP, wss:// for HTTPS)
No Data Showing
  1. Verify other extensions are registered before dashboard
  2. Check that services implement health checks
  3. Ensure metrics are being collected
  4. Check API endpoint responses in browser network tab
High Memory Usage
  1. Reduce max_data_points in config
  2. Shorten history_duration
  3. Decrease refresh_interval

Examples

See examples/basic/ for a complete working example.

Dependencies

  • gorilla/websocket: WebSocket support
  • Tailwind CSS: Styling (via CDN)
  • ApexCharts: Data visualization (via CDN)

License

Part of the Forge framework. See main repository for license information.

Contributing

Contributions welcome! Please see the main Forge repository for contribution guidelines.

Support

  • GitHub Issues: Report bugs and request features
  • Documentation: Full Forge documentation
  • Examples: See examples/ directory

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewExtension

func NewExtension(opts ...ConfigOption) forge.Extension

NewExtension creates a new dashboard extension.

Types

type Client

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

Client is a middleman between the websocket connection and the hub.

func NewClient

func NewClient(hub *Hub, conn *websocket.Conn) *Client

NewClient creates a new WebSocket client.

func (*Client) Start

func (c *Client) Start()

Start starts the client's read and write pumps.

type CollectorInfo

type CollectorInfo struct {
	Name           string    `json:"name"`
	Type           string    `json:"type"`
	MetricsCount   int       `json:"metrics_count"`
	LastCollection time.Time `json:"last_collection"`
	Status         string    `json:"status"`
}

CollectorInfo contains information about a metrics collector.

type Config

type Config struct {
	// Server settings
	Port            int           `json:"port"             yaml:"port"`
	BasePath        string        `json:"base_path"        yaml:"base_path"`
	ReadTimeout     time.Duration `json:"read_timeout"     yaml:"read_timeout"`
	WriteTimeout    time.Duration `json:"write_timeout"    yaml:"write_timeout"`
	ShutdownTimeout time.Duration `json:"shutdown_timeout" yaml:"shutdown_timeout"`

	// Features
	EnableAuth     bool     `json:"enable_auth"     yaml:"enable_auth"`
	EnableRealtime bool     `json:"enable_realtime" yaml:"enable_realtime"`
	EnableExport   bool     `json:"enable_export"   yaml:"enable_export"`
	ExportFormats  []string `json:"export_formats"  yaml:"export_formats"`

	// Data collection
	RefreshInterval time.Duration `json:"refresh_interval" yaml:"refresh_interval"`
	HistoryDuration time.Duration `json:"history_duration" yaml:"history_duration"`
	MaxDataPoints   int           `json:"max_data_points"  yaml:"max_data_points"`

	// UI settings
	Theme     string            `json:"theme"      yaml:"theme"` // light, dark, auto
	Title     string            `json:"title"      yaml:"title"`
	CustomCSS string            `json:"custom_css" yaml:"custom_css"`
	CustomJS  string            `json:"custom_js"  yaml:"custom_js"`
	MetaTags  map[string]string `json:"meta_tags"  yaml:"meta_tags"`

	// Internal
	RequireConfig bool `json:"-" yaml:"-"`
}

Config contains dashboard configuration.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns default dashboard configuration.

func (Config) Validate

func (c Config) Validate() error

Validate validates the configuration.

type ConfigOption

type ConfigOption func(*Config)

ConfigOption is a functional option for Config.

func WithAuth

func WithAuth(enabled bool) ConfigOption

WithAuth enables authentication.

func WithBasePath

func WithBasePath(path string) ConfigOption

WithBasePath sets the base URL path.

func WithConfig

func WithConfig(config Config) ConfigOption

WithConfig sets the complete config.

func WithExport

func WithExport(enabled bool) ConfigOption

WithExport enables/disables export functionality.

func WithHistoryDuration

func WithHistoryDuration(duration time.Duration) ConfigOption

WithHistoryDuration sets the data retention duration.

func WithMaxDataPoints

func WithMaxDataPoints(max int) ConfigOption

WithMaxDataPoints sets the maximum number of data points to retain.

func WithPort

func WithPort(port int) ConfigOption

WithPort sets the server port.

func WithRealtime

func WithRealtime(enabled bool) ConfigOption

WithRealtime enables real-time updates.

func WithRefreshInterval

func WithRefreshInterval(interval time.Duration) ConfigOption

WithRefreshInterval sets the refresh interval.

func WithRequireConfig

func WithRequireConfig(required bool) ConfigOption

WithRequireConfig requires config from ConfigManager.

func WithTheme

func WithTheme(theme string) ConfigOption

WithTheme sets the UI theme.

func WithTitle

func WithTitle(title string) ConfigOption

WithTitle sets the dashboard title.

type DashboardServer

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

DashboardServer serves the dashboard HTTP interface.

func NewDashboardServer

func NewDashboardServer(
	config Config,
	healthManager forge.HealthManager,
	metrics forge.Metrics,
	logger forge.Logger,
	container shared.Container,
) *DashboardServer

NewDashboardServer creates a new dashboard server.

func (*DashboardServer) GetCollector

func (ds *DashboardServer) GetCollector() *DataCollector

GetCollector returns the data collector.

func (*DashboardServer) GetHistory

func (ds *DashboardServer) GetHistory() *DataHistory

GetHistory returns the data history.

func (*DashboardServer) IsRunning

func (ds *DashboardServer) IsRunning() bool

IsRunning returns true if the server is running.

func (*DashboardServer) Start

func (ds *DashboardServer) Start(ctx context.Context) error

Start starts the dashboard server.

func (*DashboardServer) Stop

func (ds *DashboardServer) Stop(ctx context.Context) error

Stop stops the dashboard server.

type DashboardSnapshot

type DashboardSnapshot struct {
	Timestamp   time.Time     `json:"timestamp"`
	Overview    OverviewData  `json:"overview"`
	Health      HealthData    `json:"health"`
	Metrics     MetricsData   `json:"metrics"`
	Services    []ServiceInfo `json:"services"`
	GeneratedBy string        `json:"generated_by"`
}

DashboardSnapshot contains complete dashboard state for export.

type DataCollector

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

DataCollector collects dashboard data periodically.

func NewDataCollector

func NewDataCollector(
	healthManager forge.HealthManager,
	metrics forge.Metrics,
	container shared.Container,
	logger forge.Logger,
	history *DataHistory,
) *DataCollector

NewDataCollector creates a new data collector.

func (*DataCollector) CollectHealth

func (dc *DataCollector) CollectHealth(ctx context.Context) *HealthData

CollectHealth collects health check data.

func (*DataCollector) CollectMetrics

func (dc *DataCollector) CollectMetrics(ctx context.Context) *MetricsData

CollectMetrics collects current metrics.

func (*DataCollector) CollectMetricsReport

func (dc *DataCollector) CollectMetricsReport(ctx context.Context) *MetricsReport

CollectMetricsReport collects comprehensive metrics report.

func (*DataCollector) CollectOverview

func (dc *DataCollector) CollectOverview(ctx context.Context) *OverviewData

CollectOverview collects overview data.

func (*DataCollector) CollectServiceDetail

func (dc *DataCollector) CollectServiceDetail(ctx context.Context, serviceName string) *ServiceDetail

CollectServiceDetail collects detailed information about a specific service.

func (*DataCollector) CollectServices

func (dc *DataCollector) CollectServices(ctx context.Context) []ServiceInfo

CollectServices collects service information with health status.

func (*DataCollector) Start

func (dc *DataCollector) Start(ctx context.Context, interval time.Duration)

Start starts periodic data collection.

func (*DataCollector) Stop

func (dc *DataCollector) Stop()

Stop stops data collection.

type DataHistory

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

DataHistory manages historical time-series data with a ring buffer.

func NewDataHistory

func NewDataHistory(maxPoints int, retentionPeriod time.Duration) *DataHistory

NewDataHistory creates a new data history manager.

func (*DataHistory) AddHealth

func (dh *DataHistory) AddHealth(snapshot HealthSnapshot)

AddHealth adds a health snapshot.

func (*DataHistory) AddMetrics

func (dh *DataHistory) AddMetrics(snapshot MetricsSnapshot)

AddMetrics adds a metrics snapshot.

func (*DataHistory) AddOverview

func (dh *DataHistory) AddOverview(snapshot OverviewSnapshot)

AddOverview adds an overview snapshot.

func (*DataHistory) Clear

func (dh *DataHistory) Clear()

Clear clears all historical data.

func (*DataHistory) GetAll

func (dh *DataHistory) GetAll() HistoryData

GetAll returns all historical data.

func (*DataHistory) GetHealth

func (dh *DataHistory) GetHealth() []HealthSnapshot

GetHealth returns all health snapshots.

func (*DataHistory) GetMetrics

func (dh *DataHistory) GetMetrics() []MetricsSnapshot

GetMetrics returns all metrics snapshots.

func (*DataHistory) GetOverview

func (dh *DataHistory) GetOverview() []OverviewSnapshot

GetOverview returns all overview snapshots.

type DataPoint

type DataPoint struct {
	Timestamp time.Time              `json:"timestamp"`
	Value     float64                `json:"value"`
	Labels    map[string]string      `json:"labels,omitempty"`
	Metadata  map[string]interface{} `json:"metadata,omitempty"`
}

DataPoint represents a time-series data point.

type ExportFormat

type ExportFormat string

ExportFormat represents data export format.

const (
	ExportFormatJSON       ExportFormat = "json"
	ExportFormatCSV        ExportFormat = "csv"
	ExportFormatPrometheus ExportFormat = "prometheus"
)

type Extension

type Extension struct {
	*forge.BaseExtension
	// contains filtered or unexported fields
}

Extension implements a simple health and metrics dashboard.

func (*Extension) Dependencies

func (e *Extension) Dependencies() []string

Dependencies returns extension dependencies.

func (*Extension) Health

func (e *Extension) Health(ctx context.Context) error

Health checks if the dashboard is healthy.

func (*Extension) Register

func (e *Extension) Register(app forge.App) error

Register registers the dashboard extension.

func (*Extension) Server

func (e *Extension) Server() *DashboardServer

Server returns the dashboard server instance (for advanced usage).

func (*Extension) Start

func (e *Extension) Start(ctx context.Context) error

Start starts the dashboard extension.

func (*Extension) Stop

func (e *Extension) Stop(ctx context.Context) error

Stop stops the dashboard extension.

type HealthData

type HealthData struct {
	OverallStatus string                   `json:"overall_status"`
	Services      map[string]ServiceHealth `json:"services"`
	CheckedAt     time.Time                `json:"checked_at"`
	Duration      time.Duration            `json:"duration"`
	Summary       HealthSummary            `json:"summary"`
}

HealthData contains health check results.

type HealthSnapshot

type HealthSnapshot struct {
	Timestamp      time.Time `json:"timestamp"`
	OverallStatus  string    `json:"overall_status"`
	HealthyCount   int       `json:"healthy_count"`
	DegradedCount  int       `json:"degraded_count"`
	UnhealthyCount int       `json:"unhealthy_count"`
}

HealthSnapshot is a timestamped health snapshot.

type HealthSummary

type HealthSummary struct {
	Healthy   int `json:"healthy"`
	Degraded  int `json:"degraded"`
	Unhealthy int `json:"unhealthy"`
	Unknown   int `json:"unknown"`
	Total     int `json:"total"`
}

HealthSummary provides count of services by status.

type HistoryData

type HistoryData struct {
	StartTime time.Time        `json:"start_time"`
	EndTime   time.Time        `json:"end_time"`
	Series    []TimeSeriesData `json:"series"`
}

HistoryData contains historical dashboard data.

type Hub

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

Hub maintains the set of active clients and broadcasts messages to them.

func NewHub

func NewHub(logger forge.Logger) *Hub

NewHub creates a new WebSocket hub.

func (*Hub) Broadcast

func (h *Hub) Broadcast(data any) error

Broadcast sends a message to all connected clients.

func (*Hub) ClientCount

func (h *Hub) ClientCount() int

ClientCount returns the number of connected clients.

func (*Hub) Run

func (h *Hub) Run()

Run starts the hub's main loop.

type MetricActivity

type MetricActivity struct {
	Metric    string    `json:"metric"`
	Action    string    `json:"action"`
	Value     float64   `json:"value"`
	Timestamp time.Time `json:"timestamp"`
}

MetricActivity represents recent metric activity.

type MetricEntry

type MetricEntry struct {
	Name      string      `json:"name"`
	Type      string      `json:"type"`
	Value     interface{} `json:"value"`
	Tags      []string    `json:"tags,omitempty"`
	Timestamp time.Time   `json:"timestamp"`
}

MetricEntry represents a single metric entry.

type MetricsData

type MetricsData struct {
	Timestamp time.Time              `json:"timestamp"`
	Metrics   map[string]interface{} `json:"metrics"`
	Stats     MetricsStats           `json:"stats"`
}

MetricsData contains current metrics information.

type MetricsReport

type MetricsReport struct {
	Timestamp      time.Time          `json:"timestamp"`
	TotalMetrics   int                `json:"total_metrics"`
	MetricsByType  map[string]int     `json:"metrics_by_type"`
	Collectors     []CollectorInfo    `json:"collectors"`
	Stats          MetricsReportStats `json:"stats"`
	TopMetrics     []MetricEntry      `json:"top_metrics"`
	RecentActivity []MetricActivity   `json:"recent_activity"`
}

MetricsReport contains comprehensive metrics information.

type MetricsReportStats

type MetricsReportStats struct {
	CollectionInterval time.Duration `json:"collection_interval"`
	LastCollection     time.Time     `json:"last_collection"`
	TotalCollections   int64         `json:"total_collections"`
	ErrorCount         int           `json:"error_count"`
	Uptime             time.Duration `json:"uptime"`
}

MetricsReportStats contains statistics about metrics.

type MetricsSnapshot

type MetricsSnapshot struct {
	Timestamp    time.Time      `json:"timestamp"`
	TotalMetrics int            `json:"total_metrics"`
	Values       map[string]any `json:"values"`
}

MetricsSnapshot is a timestamped metrics snapshot.

type MetricsStats

type MetricsStats struct {
	TotalMetrics int       `json:"total_metrics"`
	Counters     int       `json:"counters"`
	Gauges       int       `json:"gauges"`
	Histograms   int       `json:"histograms"`
	LastUpdate   time.Time `json:"last_update"`
}

MetricsStats contains metrics statistics.

type OverviewData

type OverviewData struct {
	Timestamp       time.Time              `json:"timestamp"`
	OverallHealth   string                 `json:"overall_health"`
	TotalServices   int                    `json:"total_services"`
	HealthyServices int                    `json:"healthy_services"`
	TotalMetrics    int                    `json:"total_metrics"`
	Uptime          time.Duration          `json:"uptime"`
	Version         string                 `json:"version"`
	Environment     string                 `json:"environment"`
	Summary         map[string]interface{} `json:"summary"`
}

OverviewData contains dashboard overview information.

type OverviewSnapshot

type OverviewSnapshot struct {
	Timestamp    time.Time `json:"timestamp"`
	HealthStatus string    `json:"health_status"`
	ServiceCount int       `json:"service_count"`
	HealthyCount int       `json:"healthy_count"`
	MetricsCount int       `json:"metrics_count"`
}

OverviewSnapshot is a timestamped overview snapshot.

type ServiceDetail

type ServiceDetail struct {
	Name            string                 `json:"name"`
	Type            string                 `json:"type"`
	Status          string                 `json:"status"`
	Health          *ServiceHealth         `json:"health,omitempty"`
	Metrics         map[string]interface{} `json:"metrics"`
	Dependencies    []string               `json:"dependencies"`
	Configuration   map[string]interface{} `json:"configuration,omitempty"`
	LastHealthCheck time.Time              `json:"last_health_check"`
	Uptime          time.Duration          `json:"uptime,omitempty"`
}

ServiceDetail contains detailed information about a specific service.

type ServiceHealth

type ServiceHealth struct {
	Name      string                 `json:"name"`
	Status    string                 `json:"status"`
	Message   string                 `json:"message"`
	Duration  time.Duration          `json:"duration"`
	Critical  bool                   `json:"critical"`
	Timestamp time.Time              `json:"timestamp"`
	Details   map[string]interface{} `json:"details,omitempty"`
}

ServiceHealth contains individual service health information.

type ServiceInfo

type ServiceInfo struct {
	Name         string    `json:"name"`
	Type         string    `json:"type"`
	Status       string    `json:"status"`
	RegisteredAt time.Time `json:"registered_at,omitempty"`
}

ServiceInfo contains information about a registered service.

type TimeSeriesData

type TimeSeriesData struct {
	Name        string      `json:"name"`
	Points      []DataPoint `json:"points"`
	Unit        string      `json:"unit,omitempty"`
	Aggregation string      `json:"aggregation,omitempty"`
}

TimeSeriesData contains time-series data.

type WSMessage

type WSMessage struct {
	Type      string    `json:"type"`
	Timestamp time.Time `json:"timestamp"`
	Data      any       `json:"data"`
}

WSMessage represents a WebSocket message.

func NewWSMessage

func NewWSMessage(msgType string, data any) WSMessage

NewWSMessage creates a new WebSocket message.

Directories

Path Synopsis
examples
basic command

Jump to

Keyboard shortcuts

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