providers

package
v0.0.0-...-c4caace Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

README

package providers

Providers implement the ConfigProvider interface and are responsible for scanning different sources like files on disk, environment variables, databases or containers and objects metadata, searching for integration configurations. Every configuration, regardless of the format, must specify at least one check instance. Providers dump every configuration they find into a CheckConfig struct containing an array of configuration instances. Configuration instances are converted in YAML format so that a check object will be eventually able to convert them into the appropriate data structure.

Usage example:

var configs []loader.CheckConfig
for _, provider := range configProviders {
  c, _ := provider.Collect(ctx)
  configs = append(configs, c...)
}

Config Providers

FileConfigProvider

The FileConfigProvider is a static config provider, it scans the check configs directory once at startup.

KubeletConfigProvider

The KubeletConfigProvider relies on the Kubelet API to detect check configs defined on pod annotations.

ContainerConfigProvider

The ContainerConfigProvider detects check configs defined on container labels.

ECSConfigProvider

The ECSConfigProvider relies on the ECS API to detect check configs defined on container labels. This config provider is enabled on ECS Fargate only, on ECS EC2 we use the docker config provider.

KubeServiceConfigProvider

The KubeServiceConfigProvider relies on the Kubernetes API server to detect the cluster check configs defined on service annotations. The Datadog Cluster Agent runs this ConfigProvider.

ClusterChecksConfigProvider

The ClusterChecksConfigProvider queries the Datadog Cluster Agent API to consume the exposed cluster check configs. The node Agent or the cluster check runner can run this config provider.

KubeEndpointsConfigProvider

The KubeEndpointsConfigProvider relies on the Kubernetes API server to detect the endpoints check configs defined on service annotations. The Datadog Cluster Agent runs this ConfigProvider.

EndpointChecksConfigProvider

The EndpointChecksConfigProvider queries the Datadog Cluster Agent API to consume the exposed endpoints check configs.

PrometheusPodsConfigProvider

The PrometheusPodsConfigProvider relies on the Kubelet API to detect Prometheus pod annotations and generate a corresponding Openmetrics config.

PrometheusServicesConfigProvider

The PrometheusServicesConfigProvider relies on the Kubernetes API server to watch Prometheus service annotations and generate a corresponding Openmetrics config. The Datadog Cluster Agent runs this ConfigProvider.

CloudFoundryConfigProvider

The CloudFoundryConfigProvider relies on the CloudFoundry BBS API to detect check configs defined in LRP environment variables.

ConsulConfigProvider

The ConsulConfigProvider reads the check configs from consul.

ETCDConfigProvider

The ETCDConfigProvider reads the check configs from etcd.

ZookeeperConfigProvider

The ZookeeperConfigProvider reads the check configs from zookeeper.

Documentation

Index

Constants

View Source
const KubeEndpointsProviderName = "kube_endpoints"

KubeEndpointsProviderName defines the kube endpoints provider name

Variables

View Source
var ProviderCatalog = make(map[string]ConfigProviderFactory)

ProviderCatalog keeps track of config providers by name

Functions

func GetIntegrationConfigFromFile

func GetIntegrationConfigFromFile(name, fpath string) (integration.Config, error)

GetIntegrationConfigFromFile returns an instance of integration.Config if `fpath` points to a valid config file

func GetPollInterval

func GetPollInterval(cp config.ConfigurationProviders) time.Duration

GetPollInterval computes the poll interval from the config

func RegisterProvider

func RegisterProvider(name string, factory ConfigProviderFactory)

RegisterProvider adds a loader to the providers catalog

Types

type ClusterChecksConfigProvider

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

ClusterChecksConfigProvider implements the ConfigProvider interface for the cluster check feature.

func (*ClusterChecksConfigProvider) Collect

Collect retrieves configurations the cluster-agent dispatched to this agent

func (*ClusterChecksConfigProvider) GetConfigErrors

func (c *ClusterChecksConfigProvider) GetConfigErrors() map[string]ErrorMsgSet

GetConfigErrors is not implemented for the ClusterChecksConfigProvider

func (*ClusterChecksConfigProvider) IsUpToDate

func (c *ClusterChecksConfigProvider) IsUpToDate(ctx context.Context) (bool, error)

IsUpToDate queries the cluster-agent to update its status and query if new configurations are available

func (*ClusterChecksConfigProvider) String

func (c *ClusterChecksConfigProvider) String() string

String returns a string representation of the ClusterChecksConfigProvider

type ConfigProvider

type ConfigProvider interface {
	Collect(context.Context) ([]integration.Config, error)
	String() string
	IsUpToDate(context.Context) (bool, error)
	GetConfigErrors() map[string]ErrorMsgSet
}

ConfigProvider is the interface that wraps the Collect method

Collect is responsible of populating a list of CheckConfig instances by retrieving configuration patterns from external resources: files on disk, databases, environment variables are just few examples.

Any type implementing the interface will take care of any dependency or data needed to access the resource providing the configuration. IsUpToDate checks the local cache of the CP and returns accordingly.

func NewClusterChecksConfigProvider

func NewClusterChecksConfigProvider(cfg config.ConfigurationProviders) (ConfigProvider, error)

NewClusterChecksConfigProvider returns a new ConfigProvider collecting cluster check configurations from the cluster-agent. Connectivity is not checked at this stage to allow for retries, Collect will do it.

func NewContainerConfigProvider

func NewContainerConfigProvider(config config.ConfigurationProviders) (ConfigProvider, error)

NewContainerConfigProvider creates a new ContainerConfigProvider

func NewKubeletConfigProvider

func NewKubeletConfigProvider(config config.ConfigurationProviders) (ConfigProvider, error)

NewKubeletConfigProvider returns a new ConfigProvider connected to kubelet. Connectivity is not checked at this stage to allow for retries, Collect will do it.

type ConfigProviderFactory

type ConfigProviderFactory func(cfg config.ConfigurationProviders) (ConfigProvider, error)

ConfigProviderFactory is any function capable to create a ConfigProvider instance

type ContainerConfigProvider

type ContainerConfigProvider struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ContainerConfigProvider implements the ConfigProvider interface for container labels.

func (*ContainerConfigProvider) Collect

Collect retrieves all running containers and extract AD templates from their labels.

func (*ContainerConfigProvider) GetConfigErrors

func (d *ContainerConfigProvider) GetConfigErrors() map[string]ErrorMsgSet

GetConfigErrors is not implemented for the ContainerConfigProvider

func (*ContainerConfigProvider) IsUpToDate

func (d *ContainerConfigProvider) IsUpToDate(ctx context.Context) (bool, error)

IsUpToDate checks whether we have new containers to parse, based on events received by the listen goroutine. If listening fails, we fallback to collecting everytime.

func (*ContainerConfigProvider) String

func (d *ContainerConfigProvider) String() string

String returns a string representation of the ContainerConfigProvider

type ErrorMsgSet

type ErrorMsgSet map[string]struct{}

ErrorMsgSet contains a unique list of configuration errors for a provider

type FileConfigProvider

type FileConfigProvider struct {
	Errors map[string]string
	// contains filtered or unexported fields
}

FileConfigProvider collect configuration files from disk

func NewFileConfigProvider

func NewFileConfigProvider(paths []string) *FileConfigProvider

NewFileConfigProvider creates a new FileConfigProvider searching for configuration files on the given paths

func (*FileConfigProvider) Collect

Collect scans provided paths searching for configuration files. When found, it parses the files and try to unmarshall Yaml contents into a CheckConfig instance

func (*FileConfigProvider) GetConfigErrors

func (c *FileConfigProvider) GetConfigErrors() map[string]ErrorMsgSet

GetConfigErrors is not implemented for the FileConfigProvider

func (*FileConfigProvider) IsUpToDate

func (c *FileConfigProvider) IsUpToDate(ctx context.Context) (bool, error)

IsUpToDate is not implemented for the file Providers as the files are not meant to change very often.

func (*FileConfigProvider) String

func (c *FileConfigProvider) String() string

String returns a string representation of the FileConfigProvider

type KubeletConfigProvider

type KubeletConfigProvider struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

KubeletConfigProvider implements the ConfigProvider interface for the kubelet.

func (*KubeletConfigProvider) Collect

Collect retrieves all running pods and extract AD templates from their annotations.

func (*KubeletConfigProvider) GetConfigErrors

func (k *KubeletConfigProvider) GetConfigErrors() map[string]ErrorMsgSet

GetConfigErrors returns a map of configuration errors for each namespace/pod

func (*KubeletConfigProvider) IsUpToDate

func (k *KubeletConfigProvider) IsUpToDate(ctx context.Context) (bool, error)

IsUpToDate checks whether we have new pods to parse, based on events received by the listen goroutine. If listening fails, we fallback to collecting everytime.

func (*KubeletConfigProvider) String

func (k *KubeletConfigProvider) String() string

String returns a string representation of the KubeletConfigProvider

type ProviderCache

type ProviderCache struct {
	LatestTemplateIdx float64
	NumAdTemplates    int
}

ProviderCache contains the number of AD Templates and the latest Index

func NewCPCache

func NewCPCache() *ProviderCache

NewCPCache instantiate a ProviderCache.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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