utilization

package
v0.0.0-...-9250c3b Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	AppCPURequest = `` /* 145-byte string literal not displayed */
	AppCPUUsage   = `rate(container_cpu_usage_seconds_total{k8s_cluster_name=%q, namespace=%q, container=%q}[5m])`

	AppMemoryRequest = `` /* 148-byte string literal not displayed */
	AppMemoryUsage   = `last_over_time(container_memory_working_set_bytes{k8s_cluster_name=%q, namespace=%q, container=%q}[5m])`

	TeamCPURequest    = `` /* 227-byte string literal not displayed */
	TeamCPUUsage      = `` /* 207-byte string literal not displayed */
	TeamMemoryRequest = `` /* 230-byte string literal not displayed */
	TeamMemoryUsage   = `` /* 197-byte string literal not displayed */

	TeamsCPURequest    = `` /* 247-byte string literal not displayed */
	TeamsCPUUsage      = `` /* 226-byte string literal not displayed */
	TeamsMemoryRequest = `` /* 250-byte string literal not displayed */
	TeamsMemoryUsage   = `` /* 217-byte string literal not displayed */

)

Variables

Functions

func NewLoaderContext

func NewLoaderContext(ctx context.Context, client ResourceUsageClient, log logrus.FieldLogger) context.Context

func WorkloadResourceLimit

func WorkloadResourceLimit(ctx context.Context, env string, teamSlug slug.Slug, workloadName string, resourceType UtilizationResourceType) (*float64, error)

func WorkloadResourceRequest

func WorkloadResourceRequest(ctx context.Context, env string, teamSlug slug.Slug, workloadName string, resourceType UtilizationResourceType) (float64, error)

func WorkloadResourceUsage

func WorkloadResourceUsage(ctx context.Context, env string, teamSlug slug.Slug, workloadName string, resourceType UtilizationResourceType) (float64, error)

Types

type ApplicationInstanceUtilization

type ApplicationInstanceUtilization struct {
	// Get the current usage for the requested resource type.
	Current float64 `json:"current"`
}

func ForInstance

func ForInstance(ctx context.Context, env string, teamSlug slug.Slug, workloadName string, instanceName string, resourceType UtilizationResourceType) (*ApplicationInstanceUtilization, error)

type ResourceUsageClient

type ResourceUsageClient interface {
	Query(ctx context.Context, environment string, query string, opts ...promclient.QueryOption) (prom.Vector, error)
	QueryAll(ctx context.Context, query string, opts ...promclient.QueryOption) (prom.Vector, error)
	QueryRange(ctx context.Context, environment string, query string, promRange promv1.Range) (prom.Value, promv1.Warnings, error)
}

type TeamServiceUtilization

type TeamServiceUtilization struct {
	TeamSlug slug.Slug `json:"-"`
}

type TeamUtilization

type TeamUtilization struct {
	TeamSlug slug.Slug `json:"-"`
}

type TeamUtilizationData

type TeamUtilizationData struct {
	Requested       float64   `json:"requested"`
	Used            float64   `json:"used"`
	EnvironmentName string    `json:"-"`
	TeamSlug        slug.Slug `json:"-"`
}

func ForTeams

func ForTeams(ctx context.Context, resourceType UtilizationResourceType) ([]*TeamUtilizationData, error)

type UtilizationResourceType

type UtilizationResourceType string
const (
	UtilizationResourceTypeCPU    UtilizationResourceType = "CPU"
	UtilizationResourceTypeMemory UtilizationResourceType = "MEMORY"
)

func (UtilizationResourceType) IsValid

func (e UtilizationResourceType) IsValid() bool

func (UtilizationResourceType) MarshalGQL

func (e UtilizationResourceType) MarshalGQL(w io.Writer)

func (UtilizationResourceType) String

func (e UtilizationResourceType) String() string

func (*UtilizationResourceType) UnmarshalGQL

func (e *UtilizationResourceType) UnmarshalGQL(v any) error

type UtilizationSample

type UtilizationSample struct {
	Timestamp time.Time `json:"timestamp"`
	Value     float64   `json:"value"`
	Instance  string    `json:"instance"`
}

func WorkloadResourceLimitRange

func WorkloadResourceLimitRange(ctx context.Context, env string, teamSlug slug.Slug, workloadName string, resourceType UtilizationResourceType, start time.Time, end time.Time, step int) ([]*UtilizationSample, error)

func WorkloadResourceRequestRange

func WorkloadResourceRequestRange(ctx context.Context, env string, teamSlug slug.Slug, workloadName string, resourceType UtilizationResourceType, start time.Time, end time.Time, step int) ([]*UtilizationSample, error)

func WorkloadResourceUsageRange

func WorkloadResourceUsageRange(ctx context.Context, env string, teamSlug slug.Slug, workloadName string, resourceType UtilizationResourceType, start time.Time, end time.Time, step int) ([]*UtilizationSample, error)

type WorkloadType

type WorkloadType int
const (
	WorkloadTypeApplication WorkloadType = iota
	WorkloadTypeJob
)

type WorkloadUtilization

type WorkloadUtilization struct {
	EnvironmentName string       `json:"-"`
	WorkloadName    string       `json:"-"`
	TeamSlug        slug.Slug    `json:"-"`
	WorkloadType    WorkloadType `json:"-"`
}

type WorkloadUtilizationData

type WorkloadUtilizationData struct {
	Requested float64 `json:"requested"`
	Used      float64 `json:"used"`

	TeamSlug        slug.Slug `json:"-"`
	EnvironmentName string    `json:"-"`
	WorkloadName    string    `json:"-"`
}

func ForTeam

func ForTeam(ctx context.Context, teamSlug slug.Slug, resourceType UtilizationResourceType) ([]*WorkloadUtilizationData, error)

type WorkloadUtilizationRecommendations

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

func WorkloadResourceRecommendations

func WorkloadResourceRecommendations(ctx context.Context, env string, teamSlug slug.Slug, workloadName string) (*WorkloadUtilizationRecommendations, error)

func (WorkloadUtilizationRecommendations) CPURequestCores

func (WorkloadUtilizationRecommendations) MemoryLimitBytes

func (w WorkloadUtilizationRecommendations) MemoryLimitBytes(ctx context.Context) (int64, error)

func (WorkloadUtilizationRecommendations) MemoryRequestBytes

func (w WorkloadUtilizationRecommendations) MemoryRequestBytes(ctx context.Context) (int64, error)

type WorkloadUtilizationSeriesInput

type WorkloadUtilizationSeriesInput struct {
	Start        time.Time               `json:"start"`
	End          time.Time               `json:"end"`
	ResourceType UtilizationResourceType `json:"resourceType"`
}

func (*WorkloadUtilizationSeriesInput) Step

Jump to

Keyboard shortcuts

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