Documentation ¶
Index ¶
- Constants
- Variables
- func AddAgentVersionToDomain(DDURL string, app string) (string, error)
- func AddOverride(name string, value interface{})
- func AddOverrideFunc(f func(Config))
- func AddOverrides(vars map[string]interface{})
- func ChangeLogLevel(level string) error
- func DetectFeatures()
- func FileUsedDir() string
- func GenerateLoggerInterface(logConfig *seelogCfg.Config) (seelog.LoggerInterface, error)
- func GetBindHost() string
- func GetConfiguredTags(includeDogstatsd bool) []string
- func GetEnvDefault(key, def string) string
- func GetIPCAddress() (string, error)
- func GetMainEndpoint(prefix string, ddURLKey string) string
- func GetMainEndpointWithConfig(config Config, prefix string, ddURLKey string) (resolvedDDURL string)
- func GetMainEndpointWithConfigBackwardCompatible(config Config, prefix string, ddURLKey string, backwardKey string) (resolvedDDURL string)
- func GetMainInfraEndpoint() string
- func GetMultipleEndpoints() (map[string][]string, error)
- func GetSyslogURI() string
- func GetValidHostAliases() []string
- func InitConfig(config Config)
- func InitSystemProbeConfig(cfg Config)
- func IsAutoconfigEnabled() bool
- func IsCLCRunner() bool
- func IsCloudProviderEnabled(cloudProviderName string) bool
- func IsContainerized() bool
- func IsDockerRuntime() bool
- func IsECSFargate() bool
- func IsFeaturePresent(feature Feature) bool
- func IsKubernetes() bool
- func ResolveSecrets(config Config, origin string) error
- func SanitizeAPIKey(key string) string
- func SanitizeAPIKeyConfig(config Config, key string)
- func SetDetectedFeatures(features FeatureMap)
- func SetupJMXLogger(loggerName LoggerName, logLevel, logFile, syslogURI string, ...) error
- func SetupLogger(loggerName LoggerName, logLevel, logFile, syslogURI string, ...) error
- func SetupOTLP(config Config)
- type Config
- type ConfigurationProviders
- type ErrorLogWriter
- type Feature
- type FeatureMap
- type LegacyConfigConverter
- type Listeners
- type LoggerName
- type MappingProfile
- type MetadataProviders
- type MetricMapping
- type MockConfig
- type Proxy
- type SyslogReceiver
- type Warnings
Constants ¶
const ( DefaultAppSecEnabled = true DefaultAppSecDDUrl = "" DefaultAppSecMaxPayloadSize = 5 * 1024 * 1024 )
Default configuration values
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 )
const ( ExperimentalOTLPHTTPPort = experimentalOTLPPrefix + ".http_port" ExperimentalOTLPgRPCPort = experimentalOTLPPrefix + ".grpc_port" ExperimentalOTLPTracePort = experimentalOTLPPrefix + ".internal_traces_port" ExperimentalOTLPMetricsEnabled = experimentalOTLPPrefix + ".metrics_enabled" ExperimentalOTLPTracesEnabled = experimentalOTLPPrefix + ".traces_enabled" )
Experimental OTLP configuration paths.
Variables ¶
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
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.
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
var ( // StartTime is the agent startup time StartTime = time.Now() )
Variables to initialize at start time
Functions ¶
func AddAgentVersionToDomain ¶
AddAgentVersionToDomain prefixes the domain with the agent version: X-Y-Z.domain
func AddOverride ¶ added in v0.9.0
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 ¶ added in v0.9.0
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 ¶
ChangeLogLevel immediately changes the log level to the given one.
func DetectFeatures ¶ added in v0.9.0
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 ¶ added in v0.9.0
func GenerateLoggerInterface(logConfig *seelogCfg.Config) (seelog.LoggerInterface, error)
GenerateLoggerInterface return a logger Interface from a log config
func GetBindHost ¶ added in v0.9.0
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 ¶ added in v0.9.0
GetConfiguredTags returns complete list of user configured tags
func GetEnvDefault ¶ added in v0.9.0
GetEnvDefault retrieves a value from the environment named by the key or return def if not set.
func GetIPCAddress ¶
GetIPCAddress returns the IPC address or an error if the address is not local
func GetMainEndpoint ¶
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 ¶ added in v0.9.0
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 GetMultipleEndpoints ¶
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 GetValidHostAliases ¶ added in v0.9.0
func GetValidHostAliases() []string
GetValidHostAliases validates host aliases set in `host_aliases` variable and returns only valid ones.
func InitConfig ¶
func InitConfig(config Config)
InitConfig initializes the config defaults on a config
func InitSystemProbeConfig ¶ added in v0.9.0
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 ¶ added in v0.9.0
func IsAutoconfigEnabled() bool
IsAutoconfigEnabled returns if autoconfig from environment is activated or not
func IsCLCRunner ¶ added in v0.9.0
func IsCLCRunner() bool
IsCLCRunner returns whether the Agent is in cluster check runner mode
func IsCloudProviderEnabled ¶
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 ¶ added in v0.9.0
func IsDockerRuntime() bool
IsDockerRuntime returns true if we are to find the /.dockerenv file which is typically only set by Docker
func IsECSFargate ¶ added in v0.9.0
func IsECSFargate() bool
IsECSFargate returns whether the Agent is running in ECS Fargate
func IsFeaturePresent ¶ added in v0.9.0
IsFeaturePresent returns if a particular feature is activated
func IsKubernetes ¶
func IsKubernetes() bool
IsKubernetes returns whether the Agent is running on a kubernetes cluster
func ResolveSecrets ¶
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/DataDog/datadog-agent/blob/main/docs/agent/secrets.md
func SanitizeAPIKey ¶
SanitizeAPIKey strips newlines and other control characters from a given string.
func SanitizeAPIKeyConfig ¶
SanitizeAPIKeyConfig strips newlines and other control characters from a given key.
func SetDetectedFeatures ¶ added in v0.9.0
func SetDetectedFeatures(features FeatureMap)
SetDetectedFeatures - for tests to enable features
func SetupJMXLogger ¶ added in v0.9.0
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
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 non-sensitive env vars that the config supports 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
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 ErrorLogWriter ¶
type ErrorLogWriter struct {
AdditionalDepth int
}
ErrorLogWriter is a Writer that logs all written messages with the global seelog logger at an error level
type Feature ¶ added in v0.9.0
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 ¶ added in v0.9.0
type FeatureMap map[Feature]struct{}
FeatureMap represents all detected features
func GetDetectedFeatures ¶ added in v0.9.0
func GetDetectedFeatures() FeatureMap
GetDetectedFeatures returns all detected features (detection only performed once)
func (FeatureMap) String ¶ added in v0.9.0
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 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 (*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 LoadWithoutSecret ¶
LoadWithoutSecret reads configs files, initializes the config module without decrypting any secrets