containers

package
v0.0.0-...-3e0bdff Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 8 Imported by: 10

Documentation

Overview

Package containers implements the functionality needed to fetch metrics from the different runtimes supported (Docker, containerd, etc.).

Index

Constants

View Source
const ContainerEntityName = "container_id"

ContainerEntityName is the entity name applied to all containers

View Source
const ContainerEntityPrefix = ContainerEntityName + EntitySeparator

ContainerEntityPrefix is the prefix that any entity corresponding to a container must have It replaces any prior prefix like <runtime>:// in a pod container status.

View Source
const EntitySeparator = "://"

EntitySeparator is used to separate the entity name from its ID

View Source
const (
	// KubeNamespaceFilterPrefix if the prefix used for Kubernetes namespaces
	KubeNamespaceFilterPrefix = `kube_namespace:`
)

Variables

This section is empty.

Functions

func BuildEntityName

func BuildEntityName(runtime, id string) string

BuildEntityName builds a valid entity name for a given container runtime and cid.

func ContainerIDForEntity

func ContainerIDForEntity(name string) string

ContainerIDForEntity extracts the container ID portion of a container entity name

func GetFilterErrors added in v0.9.0

func GetFilterErrors() map[string]struct{}

GetFilterErrors retrieves a list of errors and warnings resulting from parseFilters

func IsEntityName

func IsEntityName(name string) bool

IsEntityName tests whether a given entity name is valid

func IsPauseContainer added in v0.9.0

func IsPauseContainer(labels map[string]string) bool

IsPauseContainer returns whether a container is a pause container based on the container labels This util can be used to exclude pause container in best-effort Note: Pause containers can still be excluded based on the image name via the container filtering module

func ResetSharedFilter

func ResetSharedFilter()

ResetSharedFilter is only to be used in unit tests: it resets the global filter instance to force re-parsing of the configuration.

func SplitEntityName

func SplitEntityName(name string) (string, string)

SplitEntityName returns the prefix and container cid parts of a valid entity name

Types

type EnvFilter

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

EnvFilter defines a filter for environment variables

func EnvVarFilterFromConfig

func EnvVarFilterFromConfig() EnvFilter

EnvVarFilterFromConfig returns an EnvFilter based on the options present in the config

func (EnvFilter) IsIncluded

func (f EnvFilter) IsIncluded(envVarName string) bool

IsIncluded returns whether the given env variable name is included

type Filter

type Filter struct {
	FilterType           FilterType
	Enabled              bool
	ImageIncludeList     []*regexp.Regexp
	NameIncludeList      []*regexp.Regexp
	NamespaceIncludeList []*regexp.Regexp
	ImageExcludeList     []*regexp.Regexp
	NameExcludeList      []*regexp.Regexp
	NamespaceExcludeList []*regexp.Regexp
	Errors               map[string]struct{}
}

Filter holds the state for the container filtering logic

func GetPauseContainerFilter added in v0.9.0

func GetPauseContainerFilter() (*Filter, error)

GetPauseContainerFilter returns a filter only excluding pause containers

func GetSharedMetricFilter added in v0.9.0

func GetSharedMetricFilter() (*Filter, error)

GetSharedMetricFilter allows to share the result of NewFilterFromConfig for several user classes

func NewAutodiscoveryFilter

func NewAutodiscoveryFilter(ft FilterType) (*Filter, error)

NewAutodiscoveryFilter creates a new container filter for Autodiscovery It sources patterns from the pkg/config options but ignores the exclude_pause_container options It allows to filter metrics and logs separately For use in autodiscovery.

func NewFilter

func NewFilter(ft FilterType, includeList, excludeList []string) (*Filter, error)

NewFilter creates a new container filter from a two slices of regexp patterns for a include list and exclude list. Each pattern should have the following format: "field:pattern" where field can be: [image, name, kube_namespace]. An error is returned if any of the expression don't compile.

func (Filter) IsExcluded

func (cf Filter) IsExcluded(annotations map[string]string, containerName, containerImage, podNamespace string) bool

IsExcluded returns a bool indicating if the container should be excluded based on the filters in the containerFilter instance. Consider also using Note: exclude filters are not applied to empty container names, empty images and empty namespaces.

containerImage may or may not contain the image tag or image digest. (e.g. nginx:latest and nginx are both valid)

type FilterType

type FilterType string

FilterType indicates the container filter type

const (
	// GlobalFilter is used to cover both MetricsFilter and LogsFilter filter types
	GlobalFilter FilterType = "GlobalFilter"
	// MetricsFilter refers to the Metrics filter type
	MetricsFilter FilterType = "MetricsFilter"
	// LogsFilter refers to the Logs filter type
	LogsFilter FilterType = "LogsFilter"
)

Directories

Path Synopsis
image module
Package containers provides metadata for containers.
Package containers provides metadata for containers.
Package metrics registers all the different collectors for container-related metrics.
Package metrics registers all the different collectors for container-related metrics.
containerd
Package containerd implements the containerd metrics collector
Package containerd implements the containerd metrics collector
cri
Package cri implements the CRI metrics collector.
Package cri implements the CRI metrics collector.
docker
Package docker implements the Docker metrics collector.
Package docker implements the Docker metrics collector.
ecsfargate
Package ecsfargate implements the ECS Fargate metrics collector.
Package ecsfargate implements the ECS Fargate metrics collector.
kubelet
Package kubelet implements the Kubelet metrics collector.
Package kubelet implements the Kubelet metrics collector.
provider
Package provider defines the Provider interface which allows to get metrics collectors for the different container runtimes supported (Docker, containerd, etc.).
Package provider defines the Provider interface which allows to get metrics collectors for the different container runtimes supported (Docker, containerd, etc.).
system
Package system implements the system metrics collector, which is based on Linux cgroups.
Package system implements the system metrics collector, which is based on Linux cgroups.

Jump to

Keyboard shortcuts

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