metrics

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2019 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TypeCluster cluster
	TypeCluster = "cluster"
	// TypeNode node
	TypeNode = "node"
	// TypePod pod
	TypePod = "pod"
	// TypePodContainer container in a pod
	TypePodContainer = "pod_container"
	// TypeSysContainer system container
	TypeSysContainer = "sys_container"
)
View Source
const (
	NodesCountName = "stats_nodes_count"
	NodesCountHelp = "Current count of nodes."

	InstanceGroupsName = "stats_nodes_instance_groups"
	InstanceGroupsHelp = "Current count of nodes in an instance group."
	InstanceGroupTag   = "instance_group"

	NodeCapacityCpuName = "kube_node_status_capacity_cpu_cores"
	NodeCapacityCpuHelp = "The total CPU resources of the node."

	NodeCapacityMemoryName = "kube_node_status_capacity_memory_bytes"
	NodeCapacityMemoryHelp = "The total memory resources of the node."

	NodeCapacityPodsName = "kube_node_status_capacity_pods"
	NodeCapacityPodsHelp = "The total pod resources of the node."

	NodeAllocatableCpuName = "kube_node_status_allocatable_cpu_cores"
	NodeAllocatableCpuHelp = "The CPU resources of a node that are available for scheduling."

	NodeAllocatableMemoryName = "kube_node_status_allocatable_memory_bytes"
	NodeAllocatableMemoryHelp = "The memory resources of a node that are available for scheduling."

	NodeAllocatablePodsName = "kube_node_status_allocatable_pods"
	NodeAllocatablePodsHelp = "The pod resources of a node that are available for scheduling."

	ContainerRequestsCpuName = "stats_container_resource_requests_cpu_cores"
	ContainerRequestsCpuHelp = "The number of requested cpu cores by a magalix container."

	ContainerLimitsCpuName = "stats_container_resource_limits_cpu_cores"
	ContainerLimitsCpuHelp = "The limit on cpu cores to be used by a magalix container."

	ContainerRequestsMemoryName = "stats_container_resource_requests_memory_bytes"
	ContainerRequestsMemoryHelp = "The number of requested memory bytes by a magalix container."

	ContainerLimitsMemoryName = "stats_container_resource_limits_memory_bytes"
	ContainerLimitsMemoryHelp = "The limit on memory to be used by a magalix container in bytes."

	NodeTag      = "nodename"
	NamespaceTag = "namespace"
	PodTag       = "pod_name"
	ContainerTag = "container_name"
)

Variables

View Source
var (
	TypeGAUGE = io_prometheus_client.MetricType_GAUGE.String()
)

Functions

func InitMetrics

func InitMetrics(
	client *client.Client,
	scanner *scanner.Scanner,
	kube *kuber.Kube,
	optInAnalysisData bool,
	args map[string]interface{},
) error

InitMetrics init metrics source

func ParseResponse

func ParseResponse(
	allowedMetrics map[string]struct{}, resp *http.Response, ch chan<- *dto.MetricFamily,
) error

ParseResponse consumes an http.Response and pushes it to the MetricFamily channel iff it is in allowedMetrics. It returns when all MetricFamilies are parsed and put on the channel.

func ReadPrometheusMetrics

func ReadPrometheusMetrics(
	allowedMetrics map[string]struct{},
	resp *http.Response,
	bind BindFunc,
) (result map[string]*MetricFamily, err error)

Types

type BindFunc

type BindFunc func(labels map[string]string) (entities *Entities, tags map[string]string)

type CAdvisor

type CAdvisor struct {
	*log.Logger
	// contains filtered or unexported fields
}

func NewCAdvisor

func NewCAdvisor(
	kubeletClient *KubeletClient,
	logger *log.Logger,
	scanner *scanner.Scanner,
	backoff utils.Backoff,
) (*CAdvisor, error)

func (*CAdvisor) GetMetrics

func (cAdvisor *CAdvisor) GetMetrics(tickTime time.Time) (
	chan *MetricsBatch,
	error,
)

type CAdvisorMetrics

type CAdvisorMetrics map[string][]TagsValue

CAdvisorMetrics a struct to hold cadvisor metrics

type Entities

type Entities struct {
	Node        *uuid.UUID
	Application *uuid.UUID
	Service     *uuid.UUID
	Container   *uuid.UUID
}

type Kubelet

type Kubelet struct {
	*log.Logger
	// contains filtered or unexported fields
}

Kubelet kubelet client

func NewKubelet

func NewKubelet(
	kubeletClient *KubeletClient,
	log *log.Logger,
	resolution time.Duration,
	timeouts kubeletTimeouts,
	optInAnalysisData bool,
) (*Kubelet, error)

NewKubelet returns new kubelet

func (*Kubelet) GetMetrics

func (kubelet *Kubelet) GetMetrics(
	scanner *scanner.Scanner, tickTime time.Time,
) ([]*Metrics, map[string]interface{}, error)

GetMetrics gets metrics

type KubeletClient

type KubeletClient struct {
	*log.Logger
	// contains filtered or unexported fields
}

func NewKubeletClient

func NewKubeletClient(
	logger *log.Logger,
	scanner *scanner.Scanner,
	kube *kuber.Kube,
	args map[string]interface{},
) (*KubeletClient, error)

func (*KubeletClient) Get

func (client *KubeletClient) Get(
	node *kuber.Node,
	path string,
) (*http.Response, error)

func (*KubeletClient) GetBytes

func (client *KubeletClient) GetBytes(
	node *kuber.Node,
	path string,
) ([]byte, error)

func (*KubeletClient) GetJson

func (client *KubeletClient) GetJson(
	node *kuber.Node,
	path string,
	response interface{},
) error

type KubeletSummary

type KubeletSummary struct {
	Node struct {
		CPU struct {
			Time                 time.Time
			UsageCoreNanoSeconds int64
		}

		Memory struct {
			Time     time.Time
			RSSBytes int64
		}

		FS struct {
			Time          time.Time
			UsedBytes     int64
			CapacityBytes int64
		}

		Network struct {
			Time     time.Time
			RxBytes  int64
			RxErrors int64
			TxBytes  int64
			TxErrors int64
		}
	}
	Pods []struct {
		PodRef struct {
			Name      string
			Namespace string
		}

		Containers []KubeletSummaryContainer
		Network    struct {
			Time     time.Time
			RxBytes  int64
			RxErrors int64
			TxBytes  int64
			TxErrors int64
		}
	}
}

KubeletSummary a struct to hold kubelet summary

type KubeletSummaryContainer

type KubeletSummaryContainer struct {
	Name      string
	StartTime time.Time

	CPU struct {
		Time                 time.Time
		UsageCoreNanoSeconds int64
	}

	Memory struct {
		Time     time.Time
		RSSBytes int64
	}

	RootFS struct {
		Time      time.Time
		UsedBytes int64
	}
}

type KubeletValue

type KubeletValue struct {
	Timestamp time.Time
	Value     int64
}

KubeletValue timestamp value struct

type MetricFamily

type MetricFamily struct {
	Name string
	Help string
	Type string
	Tags []string

	Values []*MetricValue
}

type MetricValue

type MetricValue struct {
	*Entities

	Tags  map[string]string
	Value float64
}

type Metrics

type Metrics struct {
	Name        string
	Type        string
	Node        uuid.UUID
	Application uuid.UUID
	Service     uuid.UUID
	Container   uuid.UUID
	Timestamp   time.Time
	Value       int64
	PodName     string

	AdditionalTags map[string]interface{}
}

Metrics metrics struct

type MetricsBatch

type MetricsBatch struct {
	Timestamp time.Time

	Metrics map[string]*MetricFamily
}

type MetricsSource deprecated

type MetricsSource interface {
	GetMetrics(scanner *scanner.Scanner, tickTime time.Time) ([]*Metrics, map[string]interface{}, error)
}

Deprecated: MetricsSource interface is deprecated and will be removed in future releases. Consider using Source interface instead. MetricsSource interface for metrics source

type NodePathGetter

type NodePathGetter func(node *kuber.Node, path_ string) string

type Prometheus

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

type RawMetric

type RawMetric struct {
	Metric string

	Account uuid.UUID
	Cluster uuid.UUID
	Node    uuid.UUID

	Application *uuid.UUID
	Service     *uuid.UUID
	Container   *uuid.UUID

	Tags  map[string]string
	Value float64

	Timestamp time.Time
}

type RawMetrics

type RawMetrics []*RawMetric

map of metric_name:list of metric points

type Source

type Source interface {
	GetMetrics(time time.Time) (chan *MetricsBatch, error)
}

Source interface is to be implemented by metrics sources

type Stats

type Stats struct {
	*log.Logger
	// contains filtered or unexported fields
}

func NewStats

func NewStats(s *scanner.Scanner, logger *log.Logger) *Stats

func (*Stats) GetMetrics

func (stats *Stats) GetMetrics(tickTime time.Time) (
	chan *MetricsBatch,
	error,
)

type TagsValue

type TagsValue struct {
	Tags  map[string]string
	Value float64
}

TagsValue a struct to hod tags and values

Jump to

Keyboard shortcuts

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