metrics

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package metrics provides utilities for generating metrics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeV1

func EncodeV1(metrics []types.Metric) (*prompb.WriteRequest, error)

EncodeV1 takes a slice of types.Metric and converts it into a prompb.WriteRequest.

func GenerateCPUUsageRecords

func GenerateCPUUsageRecords(
	input *MetricRecordInput,
	numCPUs int,
	utilizationRatio float64,
	samplesPerHour int,
	nodeName, namespace, podName string,
) []types.Metric

func GenerateClusterMetrics

func GenerateClusterMetrics(
	organizationID, cloudAccountID, clusterName string,
	startTime, endTime time.Time,
	cpuPerNode, memPerNode int64,
	numNodes, podsPerNode int,
) []types.Metric

func GenerateContainerRecords

func GenerateContainerRecords(
	input *MetricRecordInput,
	currentTime time.Time,
	containerName string,
	nodeName, podName, namespace, workload string,
	cpuReq, cpuLimit, memReq, memLimit int64,
) []types.Metric

func GenerateMemoryUsageRecords

func GenerateMemoryUsageRecords(
	input *MetricRecordInput,
	totalMemoryBytesAvailable int64,
	maxPercentage float64,
	samplesPerHour int,
	nodeName, namespace, podName string,
) []types.Metric

func GenerateNodeRecords

func GenerateNodeRecords(
	input *MetricRecordInput,
	nodeName, region string,
	maxCPU, maxMemory int64,
	totalPods int,
) []types.Metric

func GeneratePodRecords

func GeneratePodRecords(
	input *MetricRecordInput,
	nodeName, podName, namespace, workload string,
	maxCPU, maxMemory int64,
	numContainers int,
) []types.Metric

Types

type MetricRecordInput

type MetricRecordInput struct {
	OrganizationID string
	CloudAccountID string
	ClusterName    string
	StartTime      time.Time
	EndTime        time.Time
}

func (MetricRecordInput) GetEndTime

func (m MetricRecordInput) GetEndTime() time.Time

func (MetricRecordInput) GetStartTime

func (m MetricRecordInput) GetStartTime() time.Time

type SummaryRecord

type SummaryRecord struct {
	MetricsHour                   time.Time              `json:"metrics_hour"`
	CloudAccountID                string                 `json:"cloud_account_id"`
	ClusterName                   string                 `json:"cluster_name"`
	NodeName                      string                 `json:"node_name"`
	InstanceType                  string                 `json:"instance_type"`
	CloudLocalID                  string                 `json:"cloud_local_id"`
	CloudRegion                   string                 `json:"cloud_region"`
	CloudProvider                 string                 `json:"cloud_provider"`
	KubernetesNodeID              string                 `json:"kubernetes_node_id"`
	NodeCores                     int                    `json:"node_cores"`
	NodeMemory                    int64                  `json:"node_memory"`
	NodeUsageMinutes              int                    `json:"node_usage_minutes"`
	NodeMinUsageDate              time.Time              `json:"node_min_usage_date"`
	NodeMaxUsageDate              time.Time              `json:"node_max_usage_date"`
	NodeTotalRuntime              int                    `json:"node_total_runtime"`
	WorkloadType                  string                 `json:"workload_type"`
	Tags                          map[string]interface{} `json:"tags"`
	Namespace                     string                 `json:"namespace"`
	PodName                       string                 `json:"pod_name"`
	KubernetesPodName             string                 `json:"kubernetes_pod_name"`
	KubernetesPodID               string                 `json:"kubernetes_pod_id"`
	PodMinUsageDate               time.Time              `json:"pod_min_usage_date"`
	PodMaxUsageDate               time.Time              `json:"pod_max_usage_date"`
	PodTotalRuntime               int                    `json:"pod_total_runtime"`
	PodUsageMinutes               int                    `json:"pod_usage_minutes"`
	SumPodCPUUtilization          float64                `json:"sum_pod_cpu_utilization"`
	SumPodMemoryUtilization       float64                `json:"sum_pod_memory_utilization"`
	PodCPULimit                   float64                `json:"pod_cpu_limit"`
	PodCPURequest                 float64                `json:"pod_cpu_request"`
	PodMemoryLimit                float64                `json:"pod_memory_limit"`
	PodMemoryRequest              float64                `json:"pod_memory_request"`
	SumPodCPUReservedCapacity     int                    `json:"sum_pod_cpu_reserved_capacity"`
	SumPodMemoryReservedCapacity  int                    `json:"sum_pod_memory_reserved_capacity"`
	CPURequestContainerMap        map[string]float64     `json:"cpu_request_container_map"`
	CPULimitContainerMap          map[string]float64     `json:"cpu_limit_container_map"`
	MemoryRequestContainerMap     map[string]float64     `json:"memory_request_container_map"`
	MemoryLimitContainerMap       map[string]float64     `json:"memory_limit_container_map"`
	ContainerValidUtilizationMap  map[string]float64     `json:"container_valid_utilization_map"`
	ContainerRawSumCPUUtilMap     map[string]float64     `json:"container_raw_sum_cpu_utilization_map"`
	ContainerMaxCPUUtilizationMap map[string]float64     `json:"container_max_cpu_utilization_map"`
}

SummaryRecord is what a transformed output from the summary query.

A subset of SummaryRecord will be generated from a list of MetricRecord

Jump to

Keyboard shortcuts

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