prometheus

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MetricsFilter

type MetricsFilter struct {
	TeamID        uuid.UUID
	ProjectID     uuid.UUID
	EnvironmentID uuid.UUID
	// Support numerous service IDs as an OR condition
	ServiceIDs []uuid.UUID
}

type MetricsFilterSumBy

type MetricsFilterSumBy string
const (
	MetricsFilterSumByProject     MetricsFilterSumBy = "project"
	MetricsFilterSumByEnvironment MetricsFilterSumBy = "environment"
	MetricsFilterSumByService     MetricsFilterSumBy = "service"
)

func (MetricsFilterSumBy) Label

func (m MetricsFilterSumBy) Label() string

type NodeMetrics

type NodeMetrics struct {
	CPU        []model.SamplePair
	RAM        []model.SamplePair
	Network    []model.SamplePair
	Disk       []model.SamplePair
	FileSystem []model.SamplePair
	Load       []model.SamplePair
}

type NodeMetricsFilter

type NodeMetricsFilter struct {
	NodeName []string
}

NodeMetricsFilter contains filtering options for node metrics

type PVCVolumeStats

type PVCVolumeStats struct {
	PVCName    string   `json:"pvc_name"`
	UsedGB     *float64 `json:"used_gb,omitempty"`
	CapacityGB float64  `json:"capacity_gb,omitempty"`
}

PVCVolumeStats holds the used and capacity stats for a PVC.

type PrometheusClient

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

func NewPrometheusClient

func NewPrometheusClient(cfg *config.Config) (*PrometheusClient, error)

func (*PrometheusClient) GetNodeMetrics

func (self *PrometheusClient) GetNodeMetrics(
	ctx context.Context,
	start time.Time,
	end time.Time,
	step time.Duration,
	filter *NodeMetricsFilter,
) (map[string]*NodeMetrics, error)

Get metrics for specific nodes

func (*PrometheusClient) GetPVCsVolumeStats

func (self *PrometheusClient) GetPVCsVolumeStats(ctx context.Context, pvcNames []string, namespace string, client *kubernetes.Clientset) ([]*PVCVolumeStats, error)

GetPVCsVolumeStats queries Prometheus for volume usage and gets all PVC info from Kubernetes. Returns stats for all requested PVCs from K8s, with UsedGB attached from Prometheus when available.

func (*PrometheusClient) GetResourceMetrics

func (self *PrometheusClient) GetResourceMetrics(
	ctx context.Context,
	sumBy MetricsFilterSumBy,
	start time.Time,
	end time.Time,
	step time.Duration,
	filter *MetricsFilter,
) (map[string]*ResourceMetrics, error)

Get metrics for specific resources (team, project, environment, service)

func (*PrometheusClient) GetVolumeStatsWithHistory

func (self *PrometheusClient) GetVolumeStatsWithHistory(
	ctx context.Context,
	pvcName string,
	start time.Time,
	end time.Time,
	step time.Duration,
	namespace string,
	client *kubernetes.Clientset,
) (*VolumeStatsWithHistory, error)

GetVolumeStatsWithHistory gets both current PVC stats and historical usage data for a specific volume. This is equivalent to the diskQuery but targeted at a specific volume by name.

type ResourceMetrics

type ResourceMetrics struct {
	CPU     []model.SamplePair
	RAM     []model.SamplePair
	Network []model.SamplePair
	Disk    []model.SamplePair
}

type VolumeStatsWithHistory

type VolumeStatsWithHistory struct {
	Stats   *PVCVolumeStats    `json:"stats"`
	History []model.SamplePair `json:"history"`
}

VolumeStatsWithHistory combines current PVC stats with historical usage data.

Jump to

Keyboard shortcuts

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