monitoring

package
v0.0.0-...-3bfe646 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNamespace

func GetNamespace(client corev1.CoreV1Interface) (string, error)

GetNamespace uses the provided Kubernetes client to determine namespace where monitoring resources reside

Types

type Metrics

type Metrics interface {
	// GetTotalCPU returns total number of CPU cores in the cluster.
	GetTotalCPU(context.Context) (int, error)
	// GetTotalMemory returns total amount of RAM in the cluster in bytes.
	GetTotalMemory(context.Context) (int64, error)
	// GetCPURate returns CPU usage rate for the specified time range.
	GetCPURate(ctx context.Context, timeRange v1.Range) (Series, error)
	// GetMemoryRate returns RAM usage rate for the specified time range.
	GetMemoryRate(ctx context.Context, timeRange v1.Range) (Series, error)
	// GetCurrentCPURate returns instantaneous CPU usage rate.
	GetCurrentCPURate(context.Context) (int, error)
	// GetCurrentMemoryRate returns instantaneous RAM usage rate.
	GetCurrentMemoryRate(context.Context) (int, error)
	// GetMaxCPURate returns highest CPU usage rate on the specified interval.
	GetMaxCPURate(ctx context.Context, interval time.Duration) (int, error)
	// GetMaxMemoryRate returns highest RAM usage rate on the specified interval.
	GetMaxMemoryRate(ctx context.Context, interval time.Duration) (int, error)
}

Metrics defines an interface for cluster metrics.

type Point

type Point struct {
	// Time is the metric timestamp.
	Time time.Time `json:"time"`
	// Value is the metric value.
	Value int `json:"value"`
}

Point represents a single data point in a time series.

type Prometheus

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

Prometheus retrieves cluster metrics by querying in-cluster Prometheus.

Implements Metrics interface.

func NewInClusterPrometheus

func NewInClusterPrometheus() (*Prometheus, error)

NewInClusterPrometheus returns in-cluster Prometheus client.

func NewPrometheus

func NewPrometheus(address string) (*Prometheus, error)

NewPrometheus returns a new Prometheus-backed metrics collector.

func (*Prometheus) GetCPURate

func (p *Prometheus) GetCPURate(ctx context.Context, timeRange v1.Range) (Series, error)

GetCPURate returns CPU usage rate for the specified time range.

func (*Prometheus) GetCurrentCPURate

func (p *Prometheus) GetCurrentCPURate(ctx context.Context) (int, error)

GetCurrentCPURate returns instantaneous CPU usage rate.

func (*Prometheus) GetCurrentMemoryRate

func (p *Prometheus) GetCurrentMemoryRate(ctx context.Context) (int, error)

GetCurrentMemoryRate returns instantaneous RAM usage rate.

func (*Prometheus) GetMaxCPURate

func (p *Prometheus) GetMaxCPURate(ctx context.Context, interval time.Duration) (int, error)

GetMaxCPURate returns highest CPU usage rate on the specified interval.

func (*Prometheus) GetMaxMemoryRate

func (p *Prometheus) GetMaxMemoryRate(ctx context.Context, interval time.Duration) (int, error)

GetMaxMemoryRate returns highest RAM usage rate on the specified interval.

func (*Prometheus) GetMemoryRate

func (p *Prometheus) GetMemoryRate(ctx context.Context, timeRange v1.Range) (Series, error)

GetMemoryRate returns RAM usage rate for the specified time range.

func (*Prometheus) GetTotalCPU

func (p *Prometheus) GetTotalCPU(ctx context.Context) (int, error)

GetTotalCPU returns total number of CPU cores in the cluster.

func (*Prometheus) GetTotalMemory

func (p *Prometheus) GetTotalMemory(ctx context.Context) (int64, error)

GetTotalMemory returns total amount of RAM in the cluster in bytes.

type Series

type Series []Point

Series represents a time series, collection of data points.

Jump to

Keyboard shortcuts

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