prometheus

package
v0.0.0-...-bd75e23 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthEvent

type AuthEvent struct {
	UserID    string    `json:"user_id"`
	EventType string    `json:"event_type"` // "login", "logout", "failed_login"
	Timestamp time.Time `json:"timestamp"`
	Success   bool      `json:"success"`
	Source    string    `json:"source"`
}

type BackupManagerInterface

type BackupManagerInterface interface {
	GetBackupMetrics(ctx context.Context) (BackupMetrics, error)
	GetReplicationMetrics(ctx context.Context) (ReplicationMetrics, error)
}

type BackupMetrics

type BackupMetrics struct {
	TotalBackups      int       `json:"total_backups"`
	SuccessfulBackups int       `json:"successful_backups"`
	FailedBackups     int       `json:"failed_backups"`
	AverageBackupSize float64   `json:"average_backup_size"`
	LastBackupTime    time.Time `json:"last_backup_time"`
}

type ExporterConfig

type ExporterConfig struct {
	CollectionInterval    time.Duration `json:"collection_interval"`
	EnableVMMetrics       bool          `json:"enable_vm_metrics"`
	EnableStorageMetrics  bool          `json:"enable_storage_metrics"`
	EnableNetworkMetrics  bool          `json:"enable_network_metrics"`
	EnableSecurityMetrics bool          `json:"enable_security_metrics"`
	EnableBackupMetrics   bool          `json:"enable_backup_metrics"`
	EnableSystemMetrics   bool          `json:"enable_system_metrics"`
	MetricRetention       time.Duration `json:"metric_retention"`
}

ExporterConfig represents the configuration for the exporter

func DefaultExporterConfig

func DefaultExporterConfig() *ExporterConfig

DefaultExporterConfig returns default exporter configuration

type HighFrequencyCollector

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

HighFrequencyCollector collects metrics at high frequency

type LoadBalancerHealth

type LoadBalancerHealth struct {
	HealthyTargets   int   `json:"healthy_targets"`
	UnhealthyTargets int   `json:"unhealthy_targets"`
	TotalRequests    int64 `json:"total_requests"`
	FailedRequests   int64 `json:"failed_requests"`
}

type MetricSample

type MetricSample struct {
	Metric    map[string]string `json:"metric"`
	Value     float64           `json:"value"`
	Timestamp time.Time         `json:"timestamp"`
}

MetricSample represents a single metric sample

type MigrationMetric

type MigrationMetric struct {
	VMID            string        `json:"vm_id"`
	SourceNode      string        `json:"source_node"`
	TargetNode      string        `json:"target_node"`
	StartTime       time.Time     `json:"start_time"`
	Duration        time.Duration `json:"duration"`
	Success         bool          `json:"success"`
	DataTransferred int64         `json:"data_transferred"`
}

type NetworkManagerInterface

type NetworkManagerInterface interface {
	GetNetworkMetrics(ctx context.Context) (NetworkMetrics, error)
	GetLoadBalancerHealth(ctx context.Context) (LoadBalancerHealth, error)
}

type NetworkMetrics

type NetworkMetrics struct {
	TotalBandwidth    float64 `json:"total_bandwidth"`
	UsedBandwidth     float64 `json:"used_bandwidth"`
	AverageLatency    float64 `json:"average_latency"`
	PacketLossRate    float64 `json:"packet_loss_rate"`
	ActiveConnections int     `json:"active_connections"`
}

type NovaCronExporter

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

NovaCronExporter provides Prometheus metrics for NovaCron components

func NewNovaCronExporter

func NewNovaCronExporter(config *ExporterConfig) *NovaCronExporter

NewNovaCronExporter creates a new NovaCron Prometheus exporter

func (*NovaCronExporter) Collect

func (e *NovaCronExporter) Collect(ch chan<- prometheus.Metric)

Collect implements the prometheus.Collector interface

func (*NovaCronExporter) Describe

func (e *NovaCronExporter) Describe(ch chan<- *prometheus.Desc)

Describe implements the prometheus.Collector interface

func (*NovaCronExporter) RecordAuthenticationEvent

func (e *NovaCronExporter) RecordAuthenticationEvent(eventType, source string, success bool)

RecordAuthenticationEvent records an authentication event

func (*NovaCronExporter) RecordSecurityViolation

func (e *NovaCronExporter) RecordSecurityViolation(violationType, severity string)

RecordSecurityViolation records a security violation

func (*NovaCronExporter) SetBackupManager

func (e *NovaCronExporter) SetBackupManager(manager BackupManagerInterface)

SetBackupManager sets the backup manager interface

func (*NovaCronExporter) SetNetworkManager

func (e *NovaCronExporter) SetNetworkManager(manager NetworkManagerInterface)

SetNetworkManager sets the network manager interface

func (*NovaCronExporter) SetSecurityManager

func (e *NovaCronExporter) SetSecurityManager(manager SecurityManagerInterface)

SetSecurityManager sets the security manager interface

func (*NovaCronExporter) SetStorageManager

func (e *NovaCronExporter) SetStorageManager(manager StorageManagerInterface)

SetStorageManager sets the storage manager interface

func (*NovaCronExporter) SetVMManager

func (e *NovaCronExporter) SetVMManager(manager VMManagerInterface)

SetVMManager sets the VM manager interface

func (*NovaCronExporter) UpdateMigrationMetric

func (e *NovaCronExporter) UpdateMigrationMetric(sourceNode, targetNode, migrationType string, duration time.Duration, success bool)

UpdateMigrationMetric updates a migration metric

type PrometheusConfig

type PrometheusConfig struct {
	// Server configuration
	ServerURL     string `json:"server_url"`
	ListenAddress string `json:"listen_address"`
	MetricsPath   string `json:"metrics_path"`

	// Query configuration
	QueryTimeout time.Duration `json:"query_timeout"`
	QueryStep    time.Duration `json:"query_step"`
	MaxSamples   int           `json:"max_samples"`

	// High-frequency collection
	HighFrequencyEnabled   bool          `json:"high_frequency_enabled"`
	HighFrequencyInterval  time.Duration `json:"high_frequency_interval"`
	HighFrequencyRetention time.Duration `json:"high_frequency_retention"`

	// Federation
	FederationEnabled bool     `json:"federation_enabled"`
	FederationTargets []string `json:"federation_targets"`

	// Storage
	LocalStorageEnabled  bool          `json:"local_storage_enabled"`
	LocalStoragePath     string        `json:"local_storage_path"`
	LocalRetentionPeriod time.Duration `json:"local_retention_period"`

	// Security
	EnableBasicAuth bool   `json:"enable_basic_auth"`
	Username        string `json:"username"`
	Password        string `json:"password"`
	TLSCertFile     string `json:"tls_cert_file"`
	TLSKeyFile      string `json:"tls_key_file"`
}

PrometheusConfig represents the configuration for Prometheus integration

func DefaultPrometheusConfig

func DefaultPrometheusConfig() *PrometheusConfig

DefaultPrometheusConfig returns a default configuration

type PrometheusIntegration

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

PrometheusIntegration handles Prometheus metrics collection and exposition

func NewPrometheusIntegration

func NewPrometheusIntegration(config *PrometheusConfig) (*PrometheusIntegration, error)

NewPrometheusIntegration creates a new Prometheus integration

func (*PrometheusIntegration) BuildQuery

func (p *PrometheusIntegration) BuildQuery(metric string, labels map[string]string, function string, duration time.Duration) string

BuildQuery builds a Prometheus query with common patterns

func (*PrometheusIntegration) GetConfig

GetConfig retrieves Prometheus configuration

func (*PrometheusIntegration) GetLabelValues

func (p *PrometheusIntegration) GetLabelValues(ctx context.Context, labelName string) ([]string, error)

GetLabelValues retrieves the values for a specific label

func (*PrometheusIntegration) GetMetricLabels

func (p *PrometheusIntegration) GetMetricLabels(ctx context.Context, metricName string) ([]string, error)

GetMetricLabels retrieves the labels for a metric

func (*PrometheusIntegration) GetTargets

GetTargets retrieves Prometheus targets

func (*PrometheusIntegration) Query

func (p *PrometheusIntegration) Query(ctx context.Context, query string, timestamp time.Time) (*QueryResult, error)

Query executes a Prometheus query

func (*PrometheusIntegration) QueryRange

func (p *PrometheusIntegration) QueryRange(ctx context.Context, query string, startTime, endTime time.Time, step time.Duration) (*QueryResult, error)

QueryRange executes a Prometheus range query

func (*PrometheusIntegration) RegisterCollector

func (p *PrometheusIntegration) RegisterCollector(name string, collector prometheus.Collector) error

RegisterCollector registers a custom Prometheus collector

func (*PrometheusIntegration) Start

func (p *PrometheusIntegration) Start() error

Start starts the Prometheus integration

func (*PrometheusIntegration) StartHighFrequencyCollection

func (p *PrometheusIntegration) StartHighFrequencyCollection(name, query string, interval time.Duration) (<-chan *MetricSample, error)

StartHighFrequencyCollection starts high-frequency collection for a query

func (*PrometheusIntegration) Stop

func (p *PrometheusIntegration) Stop() error

Stop stops the Prometheus integration

func (*PrometheusIntegration) StopHighFrequencyCollection

func (p *PrometheusIntegration) StopHighFrequencyCollection(name string) error

StopHighFrequencyCollection stops high-frequency collection for a query

func (*PrometheusIntegration) UnregisterCollector

func (p *PrometheusIntegration) UnregisterCollector(name string) error

UnregisterCollector unregisters a custom Prometheus collector

type QueryResult

type QueryResult struct {
	Type   model.ValueType `json:"type"`
	Result model.Value     `json:"result"`
	Error  string          `json:"error,omitempty"`
}

QueryResult represents the result of a Prometheus query

type ReplicationMetrics

type ReplicationMetrics struct {
	ReplicationLag    time.Duration `json:"replication_lag"`
	ReplicationHealth string        `json:"replication_health"`
	SyncedReplicas    int           `json:"synced_replicas"`
	TotalReplicas     int           `json:"total_replicas"`
}

type SecurityManagerInterface

type SecurityManagerInterface interface {
	GetAuthenticationEvents(ctx context.Context) ([]AuthEvent, error)
	GetActiveUsers(ctx context.Context) (int, error)
	GetSecurityViolations(ctx context.Context) ([]SecurityViolation, error)
}

type SecurityViolation

type SecurityViolation struct {
	ViolationType string    `json:"violation_type"`
	Severity      string    `json:"severity"`
	Timestamp     time.Time `json:"timestamp"`
	UserID        string    `json:"user_id"`
	Details       string    `json:"details"`
}

type StorageManagerInterface

type StorageManagerInterface interface {
	GetStorageMetrics(ctx context.Context) (StorageMetrics, error)
	GetTieringMetrics(ctx context.Context) (TieringMetrics, error)
}

type StorageMetrics

type StorageMetrics struct {
	TotalCapacity     int64   `json:"total_capacity"`
	UsedCapacity      int64   `json:"used_capacity"`
	AvailableCapacity int64   `json:"available_capacity"`
	IOPS              float64 `json:"iops"`
	Throughput        float64 `json:"throughput"`
	AverageLatency    float64 `json:"average_latency"`
}

type TieringMetrics

type TieringMetrics struct {
	DeduplicationRatio float64 `json:"deduplication_ratio"`
	CompressionRatio   float64 `json:"compression_ratio"`
	HotTierUsage       int64   `json:"hot_tier_usage"`
	ColdTierUsage      int64   `json:"cold_tier_usage"`
	TieringOperations  int64   `json:"tiering_operations"`
}

type VMInfo

type VMInfo struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Status   string `json:"status"`
	TenantID string `json:"tenant_id"`
	NodeID   string `json:"node_id"`
}

type VMManagerInterface

type VMManagerInterface interface {
	GetVMCount(ctx context.Context) (int, error)
	GetVMMetrics(ctx context.Context, vmID string) (VMMetrics, error)
	ListVMs(ctx context.Context) ([]VMInfo, error)
	GetMigrationMetrics(ctx context.Context) ([]MigrationMetric, error)
}

Interfaces for data sources

type VMMetrics

type VMMetrics struct {
	VMID           string  `json:"vm_id"`
	CPUUsage       float64 `json:"cpu_usage"`
	MemoryUsage    float64 `json:"memory_usage"`
	DiskUsage      float64 `json:"disk_usage"`
	NetworkRxBytes int64   `json:"network_rx_bytes"`
	NetworkTxBytes int64   `json:"network_tx_bytes"`
	Status         string  `json:"status"`
}

Data structures

Jump to

Keyboard shortcuts

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