monitoring

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

internal/monitoring/collector.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CPUMetrics

type CPUMetrics struct {
	UsagePercent float64 `json:"usage_percent"`
	SystemCPU    uint64  `json:"system_cpu"`
	OnlineCPUs   int     `json:"online_cpus"`
}

CPUMetrics represents CPU usage metrics

type Collector

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

Collector collects metrics from containers

func NewCollector

func NewCollector(cfg *config.Config) (*Collector, error)

NewCollector creates a new metrics collector

func (*Collector) GetMetrics

func (c *Collector) GetMetrics() map[string]*Metrics

GetMetrics returns current metrics for all services

func (*Collector) GetServiceMetrics

func (c *Collector) GetServiceMetrics(service string) (*Metrics, bool)

GetServiceMetrics returns metrics for a specific service

func (*Collector) Start

func (c *Collector) Start(ctx context.Context) error

Start begins metrics collection

func (*Collector) Stop

func (c *Collector) Stop()

Stop stops all metric collectors

type DiskMetrics

type DiskMetrics struct {
	ReadBytes  uint64 `json:"read_bytes"`
	WriteBytes uint64 `json:"write_bytes"`
	ReadOps    uint64 `json:"read_ops"`
	WriteOps   uint64 `json:"write_ops"`
}

DiskMetrics represents disk usage metrics

type MemoryMetrics

type MemoryMetrics struct {
	Usage      uint64  `json:"usage"`
	Limit      uint64  `json:"limit"`
	Percent    float64 `json:"percent"`
	Cache      uint64  `json:"cache"`
	WorkingSet uint64  `json:"working_set"`
}

MemoryMetrics represents memory usage metrics

type Metrics

type Metrics struct {
	Service     string                 `json:"service"`
	ContainerID string                 `json:"container_id"`
	Timestamp   time.Time              `json:"timestamp"`
	CPU         CPUMetrics             `json:"cpu"`
	Memory      MemoryMetrics          `json:"memory"`
	Network     NetworkMetrics         `json:"network"`
	Disk        DiskMetrics            `json:"disk"`
	Performance map[string]interface{} `json:"performance,omitempty"`
}

Metrics represents collected metrics for a service

type NetworkMetrics

type NetworkMetrics struct {
	RxBytes   uint64 `json:"rx_bytes"`
	TxBytes   uint64 `json:"tx_bytes"`
	RxPackets uint64 `json:"rx_packets"`
	TxPackets uint64 `json:"tx_packets"`
	RxDropped uint64 `json:"rx_dropped"`
	TxDropped uint64 `json:"tx_dropped"`
}

NetworkMetrics represents network I/O metrics

type PerformanceHandler

type PerformanceHandler func(containerID string) (map[string]interface{}, error)

PerformanceHandler is a function that collects performance metrics for a specific service

Jump to

Keyboard shortcuts

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