Documentation
¶
Index ¶
- func GetNamespace(client corev1.CoreV1Interface) (string, error)
- type Metrics
- type Point
- type Prometheus
- func (p *Prometheus) GetCPURate(ctx context.Context, timeRange v1.Range) (Series, error)
- func (p *Prometheus) GetCurrentCPURate(ctx context.Context) (int, error)
- func (p *Prometheus) GetCurrentMemoryRate(ctx context.Context) (int, error)
- func (p *Prometheus) GetMaxCPURate(ctx context.Context, interval time.Duration) (int, error)
- func (p *Prometheus) GetMaxMemoryRate(ctx context.Context, interval time.Duration) (int, error)
- func (p *Prometheus) GetMemoryRate(ctx context.Context, timeRange v1.Range) (Series, error)
- func (p *Prometheus) GetTotalCPU(ctx context.Context) (int, error)
- func (p *Prometheus) GetTotalMemory(ctx context.Context) (int64, error)
- type Series
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 ¶
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 ¶
GetMaxCPURate returns highest CPU usage rate on the specified interval.
func (*Prometheus) GetMaxMemoryRate ¶
GetMaxMemoryRate returns highest RAM usage rate on the specified interval.
func (*Prometheus) GetMemoryRate ¶
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.