Documentation
¶
Overview ¶
Package containers implements the functionality needed to fetch metrics from the different runtimes supported (Docker, containerd, etc.).
Index ¶
- Constants
- func BuildEntityName(runtime, id string) string
- func GetPauseContainerExcludeList() []string
- func IsEntityName(name string) bool
- func IsExcludedByAnnotationInner(annotations map[string]string, containerName string, excludePrefix string) bool
- func IsPauseContainer(labels map[string]string) bool
- func PreprocessImageFilter(imageFilter string) string
- func ShortContainerID(containerID string) string
- func SplitEntityName(name string) (string, string)
- type EnvFilter
- type Filter
- type FilterType
Constants ¶
const ContainerEntityName = "container_id"
ContainerEntityName is the entity name applied to all containers
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.
const EntitySeparator = "://"
EntitySeparator is used to separate the entity name from its ID
const (
// KubeNamespaceFilterPrefix if the prefix used for Kubernetes namespaces
KubeNamespaceFilterPrefix = `kube_namespace:`
)
Variables ¶
This section is empty.
Functions ¶
func BuildEntityName ¶
BuildEntityName builds a valid entity name for a given container runtime and cid.
func GetPauseContainerExcludeList ¶
func GetPauseContainerExcludeList() []string
GetPauseContainerExcludeList returns the exclude list for pause containers
func IsEntityName ¶
IsEntityName tests whether a given entity name is valid
func IsExcludedByAnnotationInner ¶
func IsExcludedByAnnotationInner(annotations map[string]string, containerName string, excludePrefix string) bool
IsExcludedByAnnotationInner checks if an entity is excluded by annotations.
func IsPauseContainer ¶ added in v0.9.0
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 PreprocessImageFilter ¶
PreprocessImageFilter modifies image filters having the format `name$`, where {name} doesn't include a colon (e.g. nginx$, ^nginx$), to `name:.*`. This is done so that image filters can still match even if the matched image contains the tag or digest.
func ShortContainerID ¶
ShortContainerID shortens the container identifier.
func SplitEntityName ¶
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 ¶
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
GetPauseContainerFilter returns a filter only excluding pause containers
func NewFilter ¶
func NewFilter(ft FilterType, includeList, excludeList []string) (*Filter, error)
NewFilter creates a new container filter from 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 or if any filter field is not recognized
func (Filter) GetResult ¶
func (cf Filter) GetResult(annotations map[string]string, containerName, containerImage, podNamespace string) workloadfilter.Result
GetResult returns a workloadfilter.Result indicating if the container should be included, excluded or unknown. 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)
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. 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" )
Source Files
¶
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. |
|
ecsmanagedinstances
Package ecsmanagedinstances implements the ECS Managed Instances metrics collector.
|
Package ecsmanagedinstances implements the ECS Managed Instances 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. |