config

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config provides configuration management for the observability plugin. It handles parsing, validation, and merging of configuration from various sources including YAML files, environment variables, and command-line arguments. The package supports comprehensive configuration for Prometheus, caching, security, alerts, and display preferences.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APISecurityConfig

type APISecurityConfig struct {
	// Enable API authentication
	EnableAuth bool `yaml:"enableAuth" json:"enableAuth"`

	// API token (can reference a secret)
	AuthToken string `yaml:"authToken,omitempty" json:"authToken,omitempty"`

	// Reference to secret containing auth token
	AuthTokenSecretRef string `yaml:"authTokenSecretRef,omitempty" json:"authTokenSecretRef,omitempty"`

	// Rate limiting configuration
	RateLimit security.RateLimitConfig `yaml:"rateLimit" json:"rateLimit"`

	// Request validation configuration
	Validation security.ValidationConfig `yaml:"validation" json:"validation"`

	// Audit logging configuration
	Audit security.AuditConfig `yaml:"audit" json:"audit"`
}

APISecurityConfig contains API security settings

type AlertConfig

type AlertConfig struct {
	// Enable alerting
	Enabled bool `yaml:"enabled" json:"enabled"`

	// Check interval for alerts
	CheckInterval time.Duration `yaml:"checkInterval" json:"checkInterval"`

	// Load predefined alert rules
	LoadPredefinedRules bool `yaml:"loadPredefinedRules" json:"loadPredefinedRules"`

	// Show notifications for new alerts
	ShowNotifications bool `yaml:"showNotifications" json:"showNotifications"`

	// Default alert rules
	Rules []AlertRule `yaml:"rules" json:"rules"`

	// Alert history retention
	HistoryRetention time.Duration `yaml:"historyRetention" json:"historyRetention"`
}

AlertConfig contains alert settings

type AlertRule

type AlertRule struct {
	// Rule name
	Name string `yaml:"name" json:"name"`

	// Metric to monitor
	Metric string `yaml:"metric" json:"metric"`

	// Comparison operator: ">", "<", ">=", "<=", "==", "!="
	Operator string `yaml:"operator" json:"operator"`

	// Threshold value
	Threshold float64 `yaml:"threshold" json:"threshold"`

	// Duration before triggering
	Duration time.Duration `yaml:"duration" json:"duration"`

	// Severity: "info", "warning", "critical"
	Severity string `yaml:"severity" json:"severity"`

	// Rule enabled
	Enabled bool `yaml:"enabled" json:"enabled"`
}

AlertRule defines an alert condition

type AuthConfig

type AuthConfig struct {
	// Type of authentication: "none", "basic", "bearer"
	Type string `yaml:"type" json:"type"`

	// Username for basic auth
	Username string `yaml:"username,omitempty" json:"username,omitempty"`

	// Password for basic auth
	Password string `yaml:"password,omitempty" json:"password,omitempty"`

	// Token for bearer auth
	Token string `yaml:"token,omitempty" json:"token,omitempty"`

	// Secret references for secure token storage
	TokenSecretRef    string `yaml:"tokenSecretRef,omitempty" json:"tokenSecretRef,omitempty"`
	PasswordSecretRef string `yaml:"passwordSecretRef,omitempty" json:"passwordSecretRef,omitempty"`
}

AuthConfig contains authentication settings

type CacheConfig

type CacheConfig struct {
	// Enable caching
	Enabled bool `yaml:"enabled" json:"enabled"`

	// Default TTL for cached metrics
	DefaultTTL time.Duration `yaml:"defaultTTL" json:"defaultTTL"`

	// Maximum cache size in entries
	MaxSize int `yaml:"maxSize" json:"maxSize"`

	// Cleanup interval
	CleanupInterval time.Duration `yaml:"cleanupInterval" json:"cleanupInterval"`
}

CacheConfig contains cache settings

type Config

type Config struct {
	// Prometheus configuration
	Prometheus PrometheusConfig `yaml:"prometheus" json:"prometheus"`

	// Display preferences
	Display DisplayConfig `yaml:"display" json:"display"`

	// Alert configuration
	Alerts AlertConfig `yaml:"alerts" json:"alerts"`

	// Cache configuration
	Cache CacheConfig `yaml:"cache" json:"cache"`

	// Metrics configuration
	Metrics MetricsConfig `yaml:"metrics" json:"metrics"`

	// Security configuration
	Security SecurityConfig `yaml:"security" json:"security"`

	// External API configuration
	ExternalAPI endpoints.Config `yaml:"externalAPI" json:"externalAPI"`

	// Logging configuration
	Logging LoggingConfig `yaml:"logging" json:"logging"`
}

Config represents the observability plugin configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration

func (*Config) MergeWithDefaults

func (c *Config) MergeWithDefaults()

MergeWithDefaults merges the configuration with defaults

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration

type DisplayConfig

type DisplayConfig struct {
	// Refresh interval for metrics
	RefreshInterval time.Duration `yaml:"refreshInterval" json:"refreshInterval"`

	// Show metric overlays on existing views
	ShowOverlays bool `yaml:"showOverlays" json:"showOverlays"`

	// Enable sparklines in tables
	ShowSparklines bool `yaml:"showSparklines" json:"showSparklines"`

	// Number of historical points for sparklines
	SparklinePoints int `yaml:"sparklinePoints" json:"sparklinePoints"`

	// Color scheme: "default", "colorblind", "monochrome"
	ColorScheme string `yaml:"colorScheme" json:"colorScheme"`

	// Decimal precision for values
	DecimalPrecision int `yaml:"decimalPrecision" json:"decimalPrecision"`
}

DisplayConfig contains display preferences

type JobMetricsConfig

type JobMetricsConfig struct {
	// Enable job metrics collection
	Enabled bool `yaml:"enabled" json:"enabled"`

	// cgroup path pattern
	CgroupPattern string `yaml:"cgroupPattern" json:"cgroupPattern"`

	// Metrics to collect
	EnabledMetrics []string `yaml:"enabledMetrics" json:"enabledMetrics"`
}

JobMetricsConfig contains job-specific metric settings

type LoggingConfig

type LoggingConfig struct {
	// Enable debug logging
	Enabled bool `yaml:"enabled" json:"enabled"`

	// Log level: "DEBUG", "INFO", "WARN", "ERROR"
	Level string `yaml:"level" json:"level"`

	// Log file path
	LogFile string `yaml:"logFile" json:"logFile"`

	// Component name for logging
	Component string `yaml:"component" json:"component"`

	// Log to console as well as file
	LogToConsole bool `yaml:"logToConsole" json:"logToConsole"`
}

LoggingConfig contains logging settings

type MetricsConfig

type MetricsConfig struct {
	// Node metrics configuration
	Node NodeMetricsConfig `yaml:"node" json:"node"`

	// Job metrics configuration
	Job JobMetricsConfig `yaml:"job" json:"job"`

	// Custom queries
	CustomQueries map[string]string `yaml:"customQueries" json:"customQueries"`
}

MetricsConfig contains metric collection settings

type NodeMetricsConfig

type NodeMetricsConfig struct {
	// Label used to identify nodes in Prometheus
	NodeLabel string `yaml:"nodeLabel" json:"nodeLabel"`

	// Metrics to collect
	EnabledMetrics []string `yaml:"enabledMetrics" json:"enabledMetrics"`

	// Query range for rate calculations
	RateRange string `yaml:"rateRange" json:"rateRange"`
}

NodeMetricsConfig contains node-specific metric settings

type Parser

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

Parser handles configuration parsing from generic maps

func NewParser

func NewParser(data map[string]interface{}) *Parser

NewParser creates a new configuration parser

func (*Parser) ParseConfig

func (p *Parser) ParseConfig() (*Config, error)

ParseConfig parses configuration from map into Config struct

type PrometheusConfig

type PrometheusConfig struct {
	// Endpoint is the Prometheus server URL
	Endpoint string `yaml:"endpoint" json:"endpoint"`

	// Timeout for Prometheus queries
	Timeout time.Duration `yaml:"timeout" json:"timeout"`

	// Authentication settings
	Auth AuthConfig `yaml:"auth" json:"auth"`

	// TLS configuration
	TLS TLSConfig `yaml:"tls" json:"tls"`

	// Retry configuration
	Retry RetryConfig `yaml:"retry" json:"retry"`
}

PrometheusConfig contains Prometheus connection settings

type RetryConfig

type RetryConfig struct {
	// Maximum number of retries
	MaxRetries int `yaml:"maxRetries" json:"maxRetries"`

	// Initial retry delay
	InitialDelay time.Duration `yaml:"initialDelay" json:"initialDelay"`

	// Maximum retry delay
	MaxDelay time.Duration `yaml:"maxDelay" json:"maxDelay"`

	// Backoff multiplier
	Multiplier float64 `yaml:"multiplier" json:"multiplier"`
}

RetryConfig contains retry settings

type SecurityConfig

type SecurityConfig struct {
	// Secrets management configuration
	Secrets security.SecretConfig `yaml:"secrets" json:"secrets"`

	// API security settings
	API APISecurityConfig `yaml:"api" json:"api"`
}

SecurityConfig contains security settings

type TLSConfig

type TLSConfig struct {
	// Enable TLS
	Enabled bool `yaml:"enabled" json:"enabled"`

	// Skip certificate verification (insecure)
	InsecureSkipVerify bool `yaml:"insecureSkipVerify" json:"insecureSkipVerify"`

	// CA certificate file path
	CAFile string `yaml:"caFile,omitempty" json:"caFile,omitempty"`

	// Client certificate file path
	CertFile string `yaml:"certFile,omitempty" json:"certFile,omitempty"`

	// Client key file path
	KeyFile string `yaml:"keyFile,omitempty" json:"keyFile,omitempty"`
}

TLSConfig contains TLS settings

Jump to

Keyboard shortcuts

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