dashboard

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package dashboard provides cost intelligence dashboard components

Package dashboard provides cost intelligence dashboard components

Package dashboard provides chart data endpoints for cost projections and visualization.

Index

Constants

This section is empty.

Variables

View Source
var (
	Port   int
	Open   bool
	Bind   string
	APIKey string
)

Functions

func Cmd

func Cmd() *cobra.Command

Cmd returns the dashboard cobra command for registration.

Types

type AlertConfig

type AlertConfig struct {
	DailyTokenLimit     int64   `json:"daily_token_limit"`
	WeeklyTokenLimit    int64   `json:"weekly_token_limit"`
	UsageSpikeThreshold float64 `json:"usage_spike_threshold"` // multiplier for spike detection
	Enabled             bool    `json:"enabled"`
}

AlertConfig holds alert threshold configuration

type AllocationTagsWidget

type AllocationTagsWidget struct {
	Tags      map[string]TagCost
	TotalCost float64
	TimeRange string
}

AllocationTagsWidget displays cost allocation by tags

func NewAllocationTagsWidget

func NewAllocationTagsWidget() *AllocationTagsWidget

NewAllocationTagsWidget creates a new widget

func (*AllocationTagsWidget) UpdateTagCost

func (w *AllocationTagsWidget) UpdateTagCost(tag string, cost float64)

UpdateTagCost updates cost for a tag

type Anomaly

type Anomaly struct {
	Type        string
	Description string
	Severity    string
	DetectedAt  time.Time
	Value       float64
	Expected    float64
	Deviation   float64
}

Anomaly represents a detected anomaly

type AnomalyDetectionWidget

type AnomalyDetectionWidget struct {
	Anomalies    []Anomaly
	LastScan     time.Time
	ScanInterval time.Duration
	Sensitivity  float64
}

AnomalyDetectionWidget displays anomaly detection

func NewAnomalyDetectionWidget

func NewAnomalyDetectionWidget() *AnomalyDetectionWidget

NewAnomalyDetectionWidget creates a new widget

func (*AnomalyDetectionWidget) AddAnomaly

func (w *AnomalyDetectionWidget) AddAnomaly(anomaly Anomaly)

AddAnomaly adds a detected anomaly

func (*AnomalyDetectionWidget) GetHighSeverityAnomalies

func (w *AnomalyDetectionWidget) GetHighSeverityAnomalies() []Anomaly

GetHighSeverityAnomalies returns high severity anomalies

type BudgetCapWidget

type BudgetCapWidget struct {
	BudgetLimit     float64
	BudgetUsed      float64
	BudgetRemaining float64
	UsagePercent    float64
	BurnRate        float64
	DaysUntilCap    int
	AlertThreshold  float64
	IsAtRisk        bool
}

BudgetCapWidget displays budget cap status

func NewBudgetCapWidget

func NewBudgetCapWidget() *BudgetCapWidget

NewBudgetCapWidget creates a new widget

func (*BudgetCapWidget) UpdateBudget

func (w *BudgetCapWidget) UpdateBudget(limit, used float64)

UpdateBudget updates budget data

type Config

type Config struct {
	Port             int         `json:"port"`
	Bind             string      `json:"bind"`
	UpdateInterval   int         `json:"update_interval"`
	Theme            string      `json:"theme"`
	Alerts           AlertConfig `json:"alerts"`
	EnableExport     bool        `json:"enable_export"`
	HistoryRetention int         `json:"history_retention"`
}

Config holds dashboard configuration

type Contribution3DData

type Contribution3DData struct {
	Cells      []ContributionCell3D `json:"cells"`
	Weeks      int                  `json:"weeks"`
	MaxValue   int                  `json:"max_value"`
	TotalValue int                  `json:"total_value"`
	DateRange  DateRange            `json:"date_range"`
}

Contribution3DData represents 3D contribution graph data

type ContributionCell

type ContributionCell struct {
	X         int     `json:"x"` // Day of week (0-6)
	Y         int     `json:"y"` // Week number
	Value     int     `json:"value"`
	Intensity float64 `json:"intensity"`
	Date      string  `json:"date,omitempty"`
}

ContributionCell represents a single cell in the contribution graph

type ContributionCell3D

type ContributionCell3D struct {
	X         int     `json:"x"`         // Day of week (0-6)
	Y         int     `json:"y"`         // Week number
	Z         float64 `json:"z"`         // Height based on value
	Value     int     `json:"value"`     // Raw value
	Intensity float64 `json:"intensity"` // 0.0 - 1.0
	Date      string  `json:"date"`
	Weekday   string  `json:"weekday"`
}

ContributionCell3D represents a 3D cell with height

type CostAlert

type CostAlert struct {
	ID         string
	Type       string
	Message    string
	Severity   string
	CreatedAt  time.Time
	ResolvedAt *time.Time
	Value      float64
	Threshold  float64
}

CostAlert represents a cost alert

type CostAlertsWidget

type CostAlertsWidget struct {
	ActiveAlerts   []CostAlert
	ResolvedAlerts []CostAlert
	AlertCount     int
}

CostAlertsWidget displays cost alerts

func NewCostAlertsWidget

func NewCostAlertsWidget() *CostAlertsWidget

NewCostAlertsWidget creates a new widget

func (*CostAlertsWidget) AddAlert

func (w *CostAlertsWidget) AddAlert(alert CostAlert)

AddAlert adds a cost alert

func (*CostAlertsWidget) ResolveAlert

func (w *CostAlertsWidget) ResolveAlert(id string)

ResolveAlert resolves an alert

type CostDataPoint

type CostDataPoint struct {
	Timestamp time.Time
	Cost      float64
	Tokens    int64
	Requests  int64
}

CostDataPoint represents a cost data point

type CostPerRequestWidget

type CostPerRequestWidget struct {
	CurrentCost   float64
	AverageCost   float64
	P95Cost       float64
	P99Cost       float64
	TotalRequests int64
	TotalCost     float64
	TimeRange     string
	LastUpdated   time.Time
	RefreshRate   time.Duration
}

CostPerRequestWidget displays real-time cost per request

func NewCostPerRequestWidget

func NewCostPerRequestWidget() *CostPerRequestWidget

NewCostPerRequestWidget creates a new widget

func (*CostPerRequestWidget) Update

func (w *CostPerRequestWidget) Update(cost float64)

Update updates widget data

type CostProjection

type CostProjection struct {
	Date        string  `json:"date"`
	TokensSaved int64   `json:"tokens_saved"`
	CostSaved   float64 `json:"cost_saved"`
	Cumulative  float64 `json:"cumulative"`
}

CostProjection represents a projected cost over time

type CostTrendWidget

type CostTrendWidget struct {
	DataPoints  []CostDataPoint
	TimeRange   string
	Aggregation string
}

CostTrendWidget displays cost trends over time

func NewCostTrendWidget

func NewCostTrendWidget() *CostTrendWidget

NewCostTrendWidget creates a new widget

func (*CostTrendWidget) AddDataPoint

func (w *CostTrendWidget) AddDataPoint(point CostDataPoint)

AddDataPoint adds a cost data point

func (*CostTrendWidget) GetTrend

func (w *CostTrendWidget) GetTrend() string

GetTrend returns the cost trend direction

type DashboardLayout

type DashboardLayout struct {
	ID          string
	Name        string
	Description string
	Panels      []Panel
	CreatedAt   string
	UpdatedAt   string
}

DashboardLayout defines the layout structure for the cost intelligence dashboard

func CreateDefaultLayout

func CreateDefaultLayout() *DashboardLayout

CreateDefaultLayout creates the default dashboard layout

func StandardDashboardLayouts

func StandardDashboardLayouts() []DashboardLayout

StandardDashboardLayouts returns standard dashboard layouts

func (*DashboardLayout) AddPanel

func (dl *DashboardLayout) AddPanel(panel Panel)

AddPanel adds a panel to the layout

func (*DashboardLayout) GetPanel

func (dl *DashboardLayout) GetPanel(id string) *Panel

GetPanel returns a panel by ID

func (*DashboardLayout) RemovePanel

func (dl *DashboardLayout) RemovePanel(id string)

RemovePanel removes a panel from the layout

func (*DashboardLayout) UpdatePanel

func (dl *DashboardLayout) UpdatePanel(id string, updates Panel) bool

UpdatePanel updates a panel in the layout

type DashboardState

type DashboardState struct {
	CostPerRequest   *CostPerRequestWidget
	SpendForecast    *SpendForecastWidget
	TokenBreakdown   *TokenBreakdownWidget
	ModelComparison  *ModelComparisonWidget
	BudgetCap        *BudgetCapWidget
	AnomalyDetection *AnomalyDetectionWidget
	CostAlerts       *CostAlertsWidget
	PricingEditor    *PricingEditorWidget
	AllocationTags   *AllocationTagsWidget
	CostTrend        *CostTrendWidget
}

DashboardState represents the complete dashboard state

func NewDashboardState

func NewDashboardState() *DashboardState

NewDashboardState creates a new dashboard state

func (*DashboardState) String

func (ds *DashboardState) String() string

String returns a string representation of the dashboard state

func (*DashboardState) UpdateAll

func (ds *DashboardState) UpdateAll()

UpdateAll updates all widgets with sample data

type DateRange

type DateRange struct {
	Start string `json:"start"`
	End   string `json:"end"`
}

DateRange represents a date range

type LLMProvider

type LLMProvider struct {
	Name       string  `json:"name"`
	Type       string  `json:"type"`
	Model      string  `json:"model"`
	BaseURL    string  `json:"base_url,omitempty"`
	CostInput  float64 `json:"cost_input_per_million"`
	CostOutput float64 `json:"cost_output_per_million"`
}

LLMProvider represents detected LLM configuration

type ModelComparisonWidget

type ModelComparisonWidget struct {
	Models        []ModelCostData
	SelectedModel string
	TimeRange     string
}

ModelComparisonWidget displays model cost comparison

func NewModelComparisonWidget

func NewModelComparisonWidget() *ModelComparisonWidget

NewModelComparisonWidget creates a new widget

func (*ModelComparisonWidget) AddModel

func (w *ModelComparisonWidget) AddModel(model ModelCostData)

AddModel adds a model to comparison

func (*ModelComparisonWidget) GetBestModel

func (w *ModelComparisonWidget) GetBestModel() *ModelCostData

GetBestModel returns the best model by cost efficiency

type ModelCostData

type ModelCostData struct {
	Name          string
	CostPerToken  float64
	AvgLatency    time.Duration
	QualityScore  float64
	TotalRequests int64
	TotalCost     float64
	ErrorRate     float64
}

ModelCostData represents model cost data

type ModelPricing

type ModelPricing struct {
	ModelName     string
	InputPrice    float64 // per 1K tokens
	OutputPrice   float64 // per 1K tokens
	CachePrice    float64 // per 1K tokens
	EffectiveDate time.Time
}

ModelPricing represents pricing for a model

type Panel

type Panel struct {
	ID       string
	Title    string
	Type     PanelType
	Position Position
	Size     Size
	Config   PanelConfig
}

Panel represents a dashboard panel

type PanelConfig

type PanelConfig struct {
	RefreshInterval int
	TimeRange       string
	Metrics         []string
	Aggregation     string
	Filters         map[string]string
}

PanelConfig holds panel-specific configuration

type PanelType

type PanelType string

PanelType represents the type of panel

const (
	PanelCostPerRequest PanelType = "cost_per_request"
	PanelSpendForecast  PanelType = "spend_forecast"
	PanelTokenBreakdown PanelType = "token_breakdown"
	PanelModelCompare   PanelType = "model_comparison"
	PanelBudgetCap      PanelType = "budget_cap"
	PanelAnomalyDetect  PanelType = "anomaly_detection"
	PanelCostAlerts     PanelType = "cost_alerts"
	PanelPricingEditor  PanelType = "pricing_editor"
	PanelAllocationTags PanelType = "allocation_tags"
	PanelCostTrend      PanelType = "cost_trend"
)

type Position

type Position struct {
	X int `json:"x"`
	Y int `json:"y"`
}

Position represents panel position

type PricingEditorWidget

type PricingEditorWidget struct {
	Models      map[string]ModelPricing
	Currency    string
	LastUpdated time.Time
}

PricingEditorWidget allows custom pricing configuration

func NewPricingEditorWidget

func NewPricingEditorWidget() *PricingEditorWidget

NewPricingEditorWidget creates a new widget

func (*PricingEditorWidget) GetModelPricing

func (w *PricingEditorWidget) GetModelPricing(model string) (ModelPricing, bool)

GetModelPricing returns pricing for a model

func (*PricingEditorWidget) SetModelPricing

func (w *PricingEditorWidget) SetModelPricing(model string, pricing ModelPricing)

SetModelPricing sets pricing for a model

type ProjectionRequest

type ProjectionRequest struct {
	Days       int     `json:"days"`
	Model      string  `json:"model"`
	GrowthRate float64 `json:"growth_rate"` // Monthly growth rate (e.g., 0.1 = 10%)
}

ProjectionRequest contains parameters for cost projections

type ProjectionResponse

type ProjectionResponse struct {
	Projections []CostProjection  `json:"projections"`
	Summary     ProjectionSummary `json:"summary"`
	Model       string            `json:"model"`
	CostPer1M   float64           `json:"cost_per_1m"`
}

ProjectionResponse contains all projection data

type ProjectionSummary

type ProjectionSummary struct {
	TotalTokensSaved int64   `json:"total_tokens_saved"`
	TotalCostSaved   float64 `json:"total_cost_saved"`
	DailyAverage     float64 `json:"daily_average"`
	ProjectedMonthly float64 `json:"projected_monthly"`
	ProjectedYearly  float64 `json:"projected_yearly"`
}

ProjectionSummary contains summary statistics

type Size

type Size struct {
	Width  int `json:"width"`
	Height int `json:"height"`
}

Size represents panel size

type SpendForecastWidget

type SpendForecastWidget struct {
	CurrentSpend     float64
	ProjectedMonthly float64
	ProjectedYearly  float64
	ConfidenceLow    float64
	ConfidenceHigh   float64
	GrowthRate       float64
	BudgetLimit      float64
	DaysRemaining    int
	ForecastDate     time.Time
}

SpendForecastWidget displays spend forecasting

func NewSpendForecastWidget

func NewSpendForecastWidget() *SpendForecastWidget

NewSpendForecastWidget creates a new widget

func (*SpendForecastWidget) UpdateForecast

func (w *SpendForecastWidget) UpdateForecast(current, projected, growth float64)

UpdateForecast updates forecast data

type TagCost

type TagCost struct {
	Tag        string
	Cost       float64
	Percentage float64
	Trend      float64
}

TagCost represents cost for a tag

type TokenBreakdownWidget

type TokenBreakdownWidget struct {
	InputTokens  int64
	OutputTokens int64
	CacheTokens  int64
	InputCost    float64
	OutputCost   float64
	CacheCost    float64
	TotalTokens  int64
	TotalCost    float64
	CostPerToken float64
	TimeRange    string
	Breakdown    map[string]TokenCost
}

TokenBreakdownWidget displays token cost breakdown

func NewTokenBreakdownWidget

func NewTokenBreakdownWidget() *TokenBreakdownWidget

NewTokenBreakdownWidget creates a new widget

func (*TokenBreakdownWidget) UpdateBreakdown

func (w *TokenBreakdownWidget) UpdateBreakdown(inputTokens, outputTokens, cacheTokens int64, inputCost, outputCost, cacheCost float64)

UpdateBreakdown updates token breakdown

type TokenCost

type TokenCost struct {
	Type       string
	Tokens     int64
	Cost       float64
	Percentage float64
}

TokenCost represents token cost breakdown

Jump to

Keyboard shortcuts

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