config

package
v0.0.0-...-7983b3b Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAppSecEnabled        = true
	DefaultAppSecDDUrl          = ""
	DefaultAppSecMaxPayloadSize = 5 * 1024 * 1024
)

Default configuration values

View Source
const (

	// DefaultSite is the default site the Agent sends data to.
	DefaultSite = "datadoghq.com"

	// DefaultNumWorkers default number of workers for our check runner
	DefaultNumWorkers = 4
	// MaxNumWorkers maximum number of workers for our check runner
	MaxNumWorkers = 25
	// DefaultAPIKeyValidationInterval is the default interval of api key validation checks
	DefaultAPIKeyValidationInterval = 60

	// DefaultForwarderRecoveryInterval is the default recovery interval,
	// also used if the user-provided value is invalid.
	DefaultForwarderRecoveryInterval = 2

	// DefaultBatchWait is the default HTTP batch wait in second for logs
	DefaultBatchWait = 5

	// DefaultBatchMaxConcurrentSend is the default HTTP batch max concurrent send for logs
	DefaultBatchMaxConcurrentSend = 0

	// DefaultBatchMaxSize is the default HTTP batch max size (maximum number of events in a single batch) for logs
	DefaultBatchMaxSize = 100

	// DefaultBatchMaxContentSize is the default HTTP batch max content size (before compression) for logs
	// It is also the maximum possible size of a single event. Events exceeding this limit are dropped.
	DefaultBatchMaxContentSize = 1000000

	// DefaultAuditorTTL is the default logs auditor TTL in hours
	DefaultAuditorTTL = 23

	// ClusterIDCacheKey is the key name for the orchestrator cluster id in the agent in-mem cache
	ClusterIDCacheKey = "orchestratorClusterID"

	// DefaultRuntimePoliciesDir is the default policies directory used by the runtime security module
	DefaultRuntimePoliciesDir = "/etc/datadog-agent/runtime-security.d"

	// DefaultLogsSenderBackoffFactor is the default logs sender backoff randomness factor
	DefaultLogsSenderBackoffFactor = 2.0

	// DefaultLogsSenderBackoffBase is the default logs sender base backoff time, seconds
	DefaultLogsSenderBackoffBase = 1.0

	// DefaultLogsSenderBackoffMax is the default logs sender maximum backoff time, seconds
	DefaultLogsSenderBackoffMax = 120.0

	// DefaultLogsSenderBackoffRecoveryInterval is the default logs sender backoff recovery interval
	DefaultLogsSenderBackoffRecoveryInterval = 2

	// DefaultBatcherBufferSize sets the default buffer size of the batcher to 10000
	// [sts]
	DefaultBatcherBufferSize = 10000

	// DefaultTxManagerChannelBufferSize is the concurrent transactions before the tx manager begins backpressure
	// [sts] transaction manager
	DefaultTxManagerChannelBufferSize = 100
	// DefaultTxManagerTimeoutDurationSeconds is the amount of time before a transaction is marked as stale, 5 minutes by default
	DefaultTxManagerTimeoutDurationSeconds = 60 * 5
	// DefaultTxManagerEvictionDurationSeconds is the amount of time before a transaction is evicted and rolled back, 10 minutes by default
	DefaultTxManagerEvictionDurationSeconds = 60 * 10
	// DefaultTxManagerTickerIntervalSeconds is the ticker interval to mark transactions as stale / timeout.
	DefaultTxManagerTickerIntervalSeconds = 30

	// DefaultCheckStateExpirationDuration is the amount of time before an element is expired from the Check State cache, 10 minutes by default
	// [sts]
	DefaultCheckStateExpirationDuration = 10 * time.Minute
	// DefaultCheckStatePurgeDuration is the amount of time before an element is removed from the Check State cache, 10 minutes by default
	DefaultCheckStatePurgeDuration = 10 * time.Minute
)
View Source
const (
	ExperimentalOTLPSection         = "experimental.otlp"
	ExperimentalOTLPHTTPPort        = ExperimentalOTLPSection + ".http_port"
	ExperimentalOTLPgRPCPort        = ExperimentalOTLPSection + ".grpc_port"
	ExperimentalOTLPTracePort       = ExperimentalOTLPSection + ".internal_traces_port"
	ExperimentalOTLPMetricsEnabled  = ExperimentalOTLPSection + ".metrics_enabled"
	ExperimentalOTLPTracesEnabled   = ExperimentalOTLPSection + ".traces_enabled"
	ReceiverSubSectionKey           = "receiver"
	ExperimentalOTLPReceiverSection = ExperimentalOTLPSection + "." + ReceiverSubSectionKey
	ExperimentalOTLPMetrics         = ExperimentalOTLPSection + ".metrics"
)

Experimental OTLP configuration paths.

Variables

View Source
var (
	DefaultPython string

	// ForceDefaultPython has its value set to true at compile time if we should ignore
	// the Python version set in the configuration and use `DefaultPython` instead.
	// We use this to force Python 3 in the Agent 7 as it's the only one available.
	ForceDefaultPython string
)

Variables to initialize at build time

View Source
var StandardJMXIntegrations = map[string]struct{}{
	"activemq":    {},
	"activemq_58": {},
	"cassandra":   {},
	"jmx":         {},
	"presto":      {},
	"solr":        {},
	"tomcat":      {},
	"kafka":       {},
}

StandardJMXIntegrations is the list of standard jmx integrations. This list is used by the Agent to determine if an integration is JMXFetch-based, based only on the integration name. DEPRECATED: this list is only used for backward compatibility with older JMXFetch integration configs. All JMXFetch integrations should instead define `is_jmx: true` at the init_config or instance level.

View Source
var StandardStatsdPrefixes = []string{
	"datadog.agent",
	"datadog.dogstatsd",
	"datadog.process",
	"datadog.trace_agent",
	"datadog.tracer",

	"activemq",
	"activemq_58",
	"airflow",
	"cassandra",
	"confluent",
	"hazelcast",
	"hive",
	"ignite",
	"jboss",
	"jvm",
	"kafka",
	"presto",
	"sidekiq",
	"solr",
	"tomcat",

	"runtime",
}

StandardStatsdPrefixes is a list of the statsd prefixes used by the agent and its components

View Source
var (
	// StartTime is the agent startup time
	StartTime = time.Now()
)

Variables to initialize at start time

Functions

func AddAgentVersionToDomain

func AddAgentVersionToDomain(DDURL string, app string) (string, error)

AddAgentVersionToDomain prefixes the domain with the agent version: X-Y-Z.domain

func AddOverride

func AddOverride(name string, value interface{})

AddOverride provides an externally accessible method for overriding config variables. This method must be called before Load() to be effective.

func AddOverrideFunc

func AddOverrideFunc(f func(Config))

AddOverrideFunc allows to add a custom logic to override configuration. This method must be called before Load() to be effective.

func AddOverrides

func AddOverrides(vars map[string]interface{})

AddOverrides provides an externally accessible method for overriding config variables. This method must be called before Load() to be effective.

func ChangeLogLevel

func ChangeLogLevel(level string) error

ChangeLogLevel immediately changes the log level to the given one.

func DetectFeatures

func DetectFeatures()

DetectFeatures runs the feature detection. We guarantee that Datadog configuration is entirely loaded (env + YAML) before this function is called

func FileUsedDir

func FileUsedDir() string

FileUsedDir returns the absolute path to the folder containing the config file used to populate the registry

func GenerateLoggerInterface

func GenerateLoggerInterface(logConfig *seelogCfg.Config) (seelog.LoggerInterface, error)

GenerateLoggerInterface return a logger Interface from a log config

func GetBindHost

func GetBindHost() string

GetBindHost returns `bind_host` variable or default value Not using `config.BindEnvAndSetDefault` as some processes need to know if value was default one or not (e.g. trace-agent)

func GetConfiguredTags

func GetConfiguredTags(includeDogstatsd bool) []string

GetConfiguredTags returns complete list of user configured tags

func GetEnvDefault

func GetEnvDefault(key, def string) string

GetEnvDefault retrieves a value from the environment named by the key or return def if not set.

func GetIPCAddress

func GetIPCAddress() (string, error)

GetIPCAddress returns the IPC address or an error if the address is not local

func GetMainEndpoint

func GetMainEndpoint(prefix string, ddURLKey string) string

GetMainEndpoint returns the main DD URL defined in the config, based on `site` and the prefix, or ddURLKey

func GetMainEndpointWithConfig

func GetMainEndpointWithConfig(config Config, prefix string, ddURLKey string) (resolvedDDURL string)

GetMainEndpointWithConfig implements the logic to extract the DD URL from a config, based on `site` and ddURLKey

func GetMainEndpointWithConfigBackwardCompatible

func GetMainEndpointWithConfigBackwardCompatible(config Config, prefix string, ddURLKey string, backwardKey string) (resolvedDDURL string)

GetMainEndpointWithConfigBackwardCompatible implements the logic to extract the DD URL from a config, based on `site`,ddURLKey and a backward compatible key

func GetMainInfraEndpoint

func GetMainInfraEndpoint() string

GetMainInfraEndpoint returns the main DD Infra URL defined in the config, based on the value of `site` and `dd_url`

func GetMaxCapacity

func GetMaxCapacity() int

GetMaxCapacity returns the maximum amount of elements per batch for the transactionbatcher [sts]

func GetMultipleEndpoints

func GetMultipleEndpoints() (map[string][]string, error)

GetMultipleEndpoints returns the api keys per domain specified in the main agent config

func GetSyslogURI

func GetSyslogURI() string

GetSyslogURI returns the configured/default syslog uri. Returns an empty string when syslog is disabled.

func GetTxManagerConfig

func GetTxManagerConfig() (int, time.Duration, time.Duration, time.Duration)

GetTxManagerConfig returns the transaction manager configuration. The buffer size, the time duration and the eviction duration [sts]

func GetValidHostAliases

func GetValidHostAliases() []string

GetValidHostAliases validates host aliases set in `host_aliases` variable and returns only valid ones.

func GetVectorURL

func GetVectorURL(datatype DataType) (string, error)

GetVectorURL returns the URL under the 'vector.' prefix for the given datatype

func InitConfig

func InitConfig(config Config)

InitConfig initializes the config defaults on a config

func InitSystemProbeConfig

func InitSystemProbeConfig(cfg Config)

InitSystemProbeConfig declares all the configuration values normally read from system-probe.yaml. This function should not be called before ResolveSecrets, unless you call `cmd/system-probe/config.New` or `cmd/system-probe/config.Merge` in-between. This is to prevent the in-memory values from being fixed before the file-based values have had a chance to be read.

func IsAutoconfigEnabled

func IsAutoconfigEnabled() bool

IsAutoconfigEnabled returns if autoconfig from environment is activated or not

func IsCLCRunner

func IsCLCRunner() bool

IsCLCRunner returns whether the Agent is in cluster check runner mode

func IsCloudProviderEnabled

func IsCloudProviderEnabled(cloudProviderName string) bool

IsCloudProviderEnabled checks the cloud provider family provided in pkg/util/<cloud_provider>.go against the value for cloud_provider: on the global config object Datadog

func IsContainerized

func IsContainerized() bool

IsContainerized returns whether the Agent is running on a Docker container DOCKER_DD_AGENT is set in our official Dockerfile

func IsDockerRuntime

func IsDockerRuntime() bool

IsDockerRuntime returns true if we are to find the /.dockerenv file which is typically only set by Docker

func IsDockerSwarm

func IsDockerSwarm() bool

IsDockerSwarm returns whether the Agent is running on a Swarm cluster [sts]

func IsECSFargate

func IsECSFargate() bool

IsECSFargate returns whether the Agent is running in ECS Fargate

func IsFeaturePresent

func IsFeaturePresent(feature Feature) bool

IsFeaturePresent returns if a particular feature is activated

func IsHostProcAvailable

func IsHostProcAvailable() bool

IsHostProcAvailable returns whether host proc is available or not

func IsHostSysAvailable

func IsHostSysAvailable() bool

IsHostSysAvailable returns whether host proc is available or not

func IsKubernetes

func IsKubernetes() bool

IsKubernetes returns whether the Agent is running on a kubernetes cluster

func ResolveSecrets

func ResolveSecrets(config Config, origin string) error

ResolveSecrets merges all the secret values from origin into config. Secret values are identified by a value of the form "ENC[key]" where key is the secret key. See: https://github.com/StackVista/stackstate-agent/blob/master/docs/agent/secrets.md

func SanitizeAPIKey

func SanitizeAPIKey(key string) string

SanitizeAPIKey strips newlines and other control characters from a given string.

func SanitizeAPIKeyConfig

func SanitizeAPIKeyConfig(config Config, key string)

SanitizeAPIKeyConfig strips newlines and other control characters from a given key.

func SetDetectedFeatures

func SetDetectedFeatures(features FeatureMap)

SetDetectedFeatures - for tests to enable features

func SetupJMXLogger

func SetupJMXLogger(loggerName LoggerName, logLevel, logFile, syslogURI string, syslogRFC, logToConsole, jsonFormat bool) error

SetupJMXLogger sets up a logger with JMX logger name and log level if a non empty logFile is provided, it will also log to the file a non empty syslogURI will enable syslog, and format them following RFC 5424 if specified you can also specify to log to the console and in JSON format

func SetupLogger

func SetupLogger(loggerName LoggerName, logLevel, logFile, syslogURI string, syslogRFC, logToConsole, jsonFormat bool) error

SetupLogger sets up a logger with the specified logger name and log level if a non empty logFile is provided, it will also log to the file a non empty syslogURI will enable syslog, and format them following RFC 5424 if specified you can also specify to log to the console and in JSON format

func SetupOTLP

func SetupOTLP(config Config)

SetupOTLP related configuration.

func ValidHostname

func ValidHostname(hostname string) error

ValidHostname determines whether the passed string is a valid hostname. sts

Types

type Config

type Config interface {
	Set(key string, value interface{})
	SetDefault(key string, value interface{})
	SetFs(fs afero.Fs)
	IsSet(key string) bool

	Get(key string) interface{}
	GetString(key string) string
	GetBool(key string) bool
	GetInt(key string) int
	GetInt32(key string) int32
	GetInt64(key string) int64
	GetFloat64(key string) float64
	GetTime(key string) time.Time
	GetDuration(key string) time.Duration
	GetStringSlice(key string) []string
	GetFloat64SliceE(key string) ([]float64, error)
	GetStringMap(key string) map[string]interface{}
	GetStringMapString(key string) map[string]string
	GetStringMapStringSlice(key string) map[string][]string
	GetSizeInBytes(key string) uint

	SetEnvPrefix(in string)
	BindEnv(input ...string)
	SetEnvKeyReplacer(r *strings.Replacer)
	SetEnvKeyTransformer(key string, fn func(string) interface{})

	UnmarshalKey(key string, rawVal interface{}, opts ...viper.DecoderConfigOption) error
	Unmarshal(rawVal interface{}) error
	UnmarshalExact(rawVal interface{}) error

	ReadInConfig() error
	ReadConfig(in io.Reader) error
	MergeConfig(in io.Reader) error
	MergeConfigOverride(in io.Reader) error

	AllSettings() map[string]interface{}
	AllKeys() []string

	AddConfigPath(in string)
	SetConfigName(in string)
	SetConfigFile(in string)
	SetConfigType(in string)
	ConfigFileUsed() string

	BindPFlag(key string, flag *pflag.Flag) error

	// SetKnown adds a key to the set of known valid config keys
	SetKnown(key string)
	// GetKnownKeys returns all the keys that meet at least one of these criteria:
	// 1) have a default, 2) have an environment variable binded, 3) are an alias or 4) have been SetKnown()
	GetKnownKeys() map[string]interface{}

	// BindEnvAndSetDefault sets the default value for a config parameter and adds an env binding
	// in one call, used for most config options.
	//
	// If env is provided, it will override the name of the environment variable used for this
	// config key
	BindEnvAndSetDefault(key string, val interface{}, env ...string)

	// GetEnvVars returns a list of the env vars that the config supports.
	// These have had the EnvPrefix applied, as well as the EnvKeyReplacer.
	GetEnvVars() []string
}

Config represents an object that can load and store configuration parameters coming from different kind of sources: - defaults - files - environment variables - flags

var (
	Datadog Config
)

Datadog is the global configuration object

func NewConfig

func NewConfig(name string, envPrefix string, envKeyReplacer *strings.Replacer) Config

NewConfig returns a new Config object.

type ConfigurationProviders

type ConfigurationProviders struct {
	Name             string `mapstructure:"name"`
	Polling          bool   `mapstructure:"polling"`
	PollInterval     string `mapstructure:"poll_interval"`
	TemplateURL      string `mapstructure:"template_url"`
	TemplateDir      string `mapstructure:"template_dir"`
	Username         string `mapstructure:"username"`
	Password         string `mapstructure:"password"`
	CAFile           string `mapstructure:"ca_file"`
	CAPath           string `mapstructure:"ca_path"`
	CertFile         string `mapstructure:"cert_file"`
	KeyFile          string `mapstructure:"key_file"`
	Token            string `mapstructure:"token"`
	GraceTimeSeconds int    `mapstructure:"grace_time_seconds"`
}

ConfigurationProviders helps unmarshalling `config_providers` config param

type DataType

type DataType string

DataType represent the generic data type (e.g. metrics, logs) that can be sent by the Agent

const (
	// Metrics type covers series & sketches
	Metrics DataType = "metrics"
)

type ErrorLogWriter

type ErrorLogWriter struct {
	AdditionalDepth int
}

ErrorLogWriter is a Writer that logs all written messages with the global seelog logger at an error level

func (*ErrorLogWriter) Write

func (s *ErrorLogWriter) Write(p []byte) (n int, err error)

type Feature

type Feature string

Feature represents a feature of current environment

const (
	// Docker socket present
	Docker Feature = "docker"
	// Containerd socket present
	Containerd Feature = "containerd"
	// Cri is any cri socket present
	Cri Feature = "cri"
	// Kubernetes environment
	Kubernetes Feature = "kubernetes"
	// ECSFargate environment
	ECSFargate Feature = "ecsfargate"
	// EKSFargate environment
	EKSFargate Feature = "eksfargate"
	// KubeOrchestratorExplorer can be enabled
	KubeOrchestratorExplorer Feature = "orchestratorexplorer"
	// CloudFoundry socket present
	CloudFoundry Feature = "cloudfoundry"
)

Remember to also register feature in init()

type FeatureMap

type FeatureMap map[Feature]struct{}

FeatureMap represents all detected features

func GetDetectedFeatures

func GetDetectedFeatures() FeatureMap

GetDetectedFeatures returns all detected features (detection only performed once)

func (FeatureMap) String

func (fm FeatureMap) String() string

type LegacyConfigConverter

type LegacyConfigConverter struct {
	Config
}

LegacyConfigConverter is used in the legacy package to convert A5 config to A6

func NewConfigConverter

func NewConfigConverter() *LegacyConfigConverter

NewConfigConverter is creating and returning a config converter

func (*LegacyConfigConverter) Set

func (c *LegacyConfigConverter) Set(key string, value interface{})

Set is used for setting configuration from A5 config

type Listeners

type Listeners struct {
	Name string `mapstructure:"name"`
}

Listeners helps unmarshalling `listeners` config param

type LoggerName

type LoggerName string

LoggerName specifies the name of an instantiated logger.

type MappingProfile

type MappingProfile struct {
	Name     string          `mapstructure:"name" json:"name"`
	Prefix   string          `mapstructure:"prefix" json:"prefix"`
	Mappings []MetricMapping `mapstructure:"mappings" json:"mappings"`
}

MappingProfile represent a group of mappings

func GetDogstatsdMappingProfiles

func GetDogstatsdMappingProfiles() ([]MappingProfile, error)

GetDogstatsdMappingProfiles returns mapping profiles used in DogStatsD mapper

type MetadataProviders

type MetadataProviders struct {
	Name     string        `mapstructure:"name"`
	Interval time.Duration `mapstructure:"interval"`
}

MetadataProviders helps unmarshalling `metadata_providers` config param

type MetricMapping

type MetricMapping struct {
	Match     string            `mapstructure:"match" json:"match"`
	MatchType string            `mapstructure:"match_type" json:"match_type"`
	Name      string            `mapstructure:"name" json:"name"`
	Tags      map[string]string `mapstructure:"tags" json:"tags"`
}

MetricMapping represent one mapping rule

type MockConfig

type MockConfig struct {
	Config
}

MockConfig should only be used in tests

func Mock

func Mock() *MockConfig

Mock is creating and returning a mock config

func (*MockConfig) Set

func (c *MockConfig) Set(key string, value interface{})

Set is used for setting configuration in tests

type Proxy

type Proxy struct {
	HTTP    string   `mapstructure:"http"`
	HTTPS   string   `mapstructure:"https"`
	NoProxy []string `mapstructure:"no_proxy"`
}

Proxy represents the configuration for proxies in the agent

func GetProxies

func GetProxies() *Proxy

GetProxies returns the proxy settings from the configuration

type SyslogReceiver

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

SyslogReceiver implements seelog.CustomReceiver

func (*SyslogReceiver) AfterParse

func (s *SyslogReceiver) AfterParse(initArgs seelog.CustomReceiverInitArgs) error

AfterParse parses the receiver configuration

func (*SyslogReceiver) Close

func (s *SyslogReceiver) Close() error

Close is a NOP in current implementation

func (*SyslogReceiver) Flush

func (s *SyslogReceiver) Flush()

Flush is a NOP in current implementation

func (*SyslogReceiver) ReceiveMessage

func (s *SyslogReceiver) ReceiveMessage(message string, level seelog.LogLevel, context seelog.LogContextInterface) error

ReceiveMessage process current log message

type Warnings

type Warnings struct {
	TraceMallocEnabledWithPy2 bool
}

Warnings represent the warnings in the config

func Load

func Load() (*Warnings, error)

Load reads configs files and initializes the config module

func LoadWithoutSecret

func LoadWithoutSecret() (*Warnings, error)

LoadWithoutSecret reads configs files, initializes the config module without decrypting any secrets

Directories

Path Synopsis
remote
Package resolver contains logic to perform per `transaction.Endpoint` domain resolution.
Package resolver contains logic to perform per `transaction.Endpoint` domain resolution.

Jump to

Keyboard shortcuts

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