generic

package
v0.0.0-...-fbba564 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package generic implements the container check.

Index

Constants

View Source
const (
	// CheckName is the name of the check
	CheckName = "container"
)
View Source
const (
	// NetworkExtensionID uniquely identifies network extensions
	NetworkExtensionID = "network"
)

Variables

This section is empty.

Functions

func ConvertNanosecondsToHz

func ConvertNanosecondsToHz(val float64) float64

ConvertNanosecondsToHz converts nanoseconds to User Hz (1/100s)

func Factory

func Factory(store workloadmeta.Component) optional.Option[func() check.Check]

Factory returns a new check factory

func NewCappedSender

func NewCappedSender(cappedMetrics map[string]float64, sender sender.Sender) sender.Sender

NewCappedSender returns a capped sender

Types

type ANDContainerFilter

type ANDContainerFilter struct {
	Filters []ContainerFilter
}

ANDContainerFilter implements a logical AND between given filters

func (ANDContainerFilter) IsExcluded

func (f ANDContainerFilter) IsExcluded(container *workloadmeta.Container) bool

IsExcluded returns if a container should be excluded or not

type CappedSender

type CappedSender struct {
	sender.Sender
	// contains filtered or unexported fields
}

CappedSender wraps around the standard Sender and overrides the Rate method to implement rate capping

func (*CappedSender) Rate

func (s *CappedSender) Rate(metric string, value float64, hostname string, tags []string)

Rate checks the rate value against the `capped_metrics` configuration to filter out buggy spikes coming for cgroup cpu accounting

type ContainerAccessor

type ContainerAccessor interface {
	ListRunning() []*workloadmeta.Container
}

ContainerAccessor abstracts away how to list all running containers

type ContainerCheck

type ContainerCheck struct {
	core.CheckBase
	// contains filtered or unexported fields
}

ContainerCheck generates metrics for all containers

func (*ContainerCheck) Configure

func (c *ContainerCheck) Configure(senderManager sender.SenderManager, integrationConfigDigest uint64, config, initConfig integration.Data, source string) error

Configure parses the check configuration and init the check

func (*ContainerCheck) Run

func (c *ContainerCheck) Run() error

Run executes the check

type ContainerConfig

type ContainerConfig struct{}

ContainerConfig holds the check configuration

func (*ContainerConfig) Parse

func (c *ContainerConfig) Parse(data []byte) error

Parse parses the container check config and set default values

type ContainerFilter

type ContainerFilter interface {
	IsExcluded(container *workloadmeta.Container) bool
}

ContainerFilter defines an interface to exclude containers based on Metadata

type FuncContainerFilter

type FuncContainerFilter func(container *workloadmeta.Container) bool

FuncContainerFilter allows any function to be used as a ContainerFilter

func (FuncContainerFilter) IsExcluded

func (f FuncContainerFilter) IsExcluded(container *workloadmeta.Container) bool

IsExcluded returns if a container should be excluded or not

type GenericMetricsAdapter

type GenericMetricsAdapter struct{}

GenericMetricsAdapter implements MetricsAdapter API in a basic way. Adds `runtime` tag and do not change metrics.

func (GenericMetricsAdapter) AdaptMetrics

func (a GenericMetricsAdapter) AdaptMetrics(metricName string, value float64) (string, float64)

AdaptMetrics is a passthrough (does not change anything)

func (GenericMetricsAdapter) AdaptTags

func (a GenericMetricsAdapter) AdaptTags(tags []string, c *workloadmeta.Container) []string

AdaptTags adds a `runtime` tag for all containers

type LegacyContainerFilter

type LegacyContainerFilter struct {
	OldFilter *containers.Filter
	Store     workloadmeta.Component
}

LegacyContainerFilter allows to use old containers.Filter within this new framework

func (LegacyContainerFilter) IsExcluded

func (f LegacyContainerFilter) IsExcluded(container *workloadmeta.Container) bool

IsExcluded returns if a container should be excluded or not

type MetadataContainerAccessor

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

MetadataContainerAccessor implements ContainerLister interface using Workload meta service

func NewMetadataContainerAccessor

func NewMetadataContainerAccessor(store workloadmeta.Component) MetadataContainerAccessor

NewMetadataContainerAccessor returns a new MetadataContainerAccessor

func (MetadataContainerAccessor) ListRunning

ListRunning returns all running containers

type MetricsAdapter

type MetricsAdapter interface {
	// AdaptTags can be used to change Tagger tags before submitting the metrics
	AdaptTags(tags []string, c *workloadmeta.Container) []string
	// AdaptMetrics can be used to change metrics (change name or value) before submitting the metric.
	AdaptMetrics(metricName string, value float64) (string, float64)
}

MetricsAdapter provides a way to change metrics and tags before sending them out

type Processor

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

Processor contains the core logic of the generic check, allowing reusability

func NewProcessor

func NewProcessor(provider metrics.Provider, lister ContainerAccessor, adapter MetricsAdapter, filter ContainerFilter) Processor

NewProcessor creates a new processor

func (*Processor) RegisterExtension

func (p *Processor) RegisterExtension(id string, extension ProcessorExtension)

RegisterExtension allows to register (or override) an extension

func (*Processor) Run

func (p *Processor) Run(sender sender.Sender, cacheValidity time.Duration) error

Run executes the check

type ProcessorExtension

type ProcessorExtension interface {
	// PreProcess is called once during check run, before any call to `Process`
	PreProcess(sender SenderFunc, aggSender sender.Sender)

	// Process is called after core process (regardless of encountered error)
	// Tags are given after `AdaptTags()` has been called
	// aggSender is only passed as the sender function (sender.Gauge for instance) needs to be passed back to sender
	Process(tags []string, container *workloadmeta.Container, collector metrics.Collector, cacheValidity time.Duration)

	// PostProcess is called once during each check run, after all calls to `Process`
	PostProcess()
}

ProcessorExtension allows to replace or add optional parts of the core check

func NewProcessorNetwork

func NewProcessorNetwork() ProcessorExtension

NewProcessorNetwork returns a default ProcessorExtension

type ProcessorNetwork

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

ProcessorNetwork is a Processor extension taking care of network metrics

func (*ProcessorNetwork) PostProcess

func (pn *ProcessorNetwork) PostProcess()

PostProcess actually computes the metrics

func (*ProcessorNetwork) PreProcess

func (pn *ProcessorNetwork) PreProcess(sender SenderFunc, aggSender sender.Sender)

PreProcess is called once during check run, before any call to `Process`

func (*ProcessorNetwork) Process

func (pn *ProcessorNetwork) Process(tags []string, container *workloadmeta.Container, collector metrics.Collector, cacheValidity time.Duration)

Process stores each container in relevant network group

type RuntimeContainerFilter

type RuntimeContainerFilter struct {
	Runtime workloadmeta.ContainerRuntime
}

RuntimeContainerFilter filters containers by runtime

func (RuntimeContainerFilter) IsExcluded

func (f RuntimeContainerFilter) IsExcluded(container *workloadmeta.Container) bool

IsExcluded returns if a container should be excluded or not

type SenderFunc

type SenderFunc func(func(string, float64, string, []string), string, *float64, []string)

SenderFunc is a function that wraps sending metrics

Jump to

Keyboard shortcuts

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