config

package
v0.0.0-...-3dd6856 Latest Latest
Warning

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

Go to latest
Published: May 20, 2019 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultForwarderRecoveryInterval = 2

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

View Source
const DefaultSite = "datadoghq.com"

DefaultSite is the default site the Agent sends data to.

Variables

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

StandardJMXIntegrations is the list of standard jmx integrations

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

	"activemq",
	"activemq_58",
	"cassandra",
	"jvm",
	"presto",
	"solr",
	"tomcat",
	"kafka",
}

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

Functions

func AddAgentVersionToDomain

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

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

func BuildCommonFormat

func BuildCommonFormat(loggerName LoggerName) string

BuildCommonFormat returns the log common format seelog string

func BuildJSONFormat

func BuildJSONFormat(loggerName LoggerName) string

BuildJSONFormat returns the log JSON format seelog string

func FileUsedDir

func FileUsedDir() string

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

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 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

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 IsContainerized

func IsContainerized() bool

IsContainerized returns whether the Agent is running on a Docker container

func IsKubernetes

func IsKubernetes() bool

IsKubernetes returns whether the Agent is running on a kubernetes cluster

func Load

func Load() error

Load reads configs files and initializes the config module

func LoadWithoutSecret

func LoadWithoutSecret() error

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

func SetOverrides

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

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

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
	GetInt64(key string) int64
	GetFloat64(key string) float64
	GetTime(key string) time.Time
	GetDuration(key string) time.Duration
	GetStringSlice(key string) []string
	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) error
	SetEnvKeyReplacer(r *strings.Replacer)

	UnmarshalKey(key string, rawVal interface{}) 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
	BindEnvAndSetDefault(key string, val interface{})
	// 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

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 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 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 MetadataProviders

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

MetadataProviders helps unmarshalling `metadata_providers` config param

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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