config

package
v0.0.0-...-e57142c Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2019 License: BSD-3-Clause Imports: 19 Imported by: 0

README

Agent Configuration

The trace-agent sources configuration from the following locations:

  1. The Datadog Agent configuration file, provided to the -config command line flag (default: /etc/datadog/datadog.conf)
  2. Environment variables: See full list below

Environment variables will override settings defined in configuration files.

File configuration

Refer to the Datadog Agent example configuration to see all available options.

Environment variables

We allow overriding a subset of configuration values from the environment. These can be useful when running the agent in a Docker container or in other situations where env vars are preferrable to static files

  • DD_APM_ENABLED - overrides [Main] apm_enabled
  • DD_HOSTNAME - overrides [Main] hostname
  • DD_API_KEY - overrides [Main] api_key
  • DD_DOGSTATSD_PORT - overrides [Main] dogstatsd_port
  • DD_BIND_HOST - overrides [Main] bind_host
  • DD_APM_NON_LOCAL_TRAFFIC - overrides [Main] non_local_traffic
  • DD_LOG_LEVEL - overrides [Main] log_level
  • DD_RECEIVER_PORT - overrides [trace.receiver] receiver_port
  • DD_IGNORE_RESOURCE - overrides [trace.ignore] resource

Documentation

Index

Constants

View Source
const (
	// DefaultLogFilePath is where the agent will write logs if not overriden in the conf
	DefaultLogFilePath = "/var/log/datadog/trace-agent.log"
)

Variables

View Source
var (
	// ErrMissingAPIKey is returned when the config could not be validated due to missing API key.
	ErrMissingAPIKey = errors.New("you must specify an API Key, either via a configuration file or the DD_API_KEY env var")

	// ErrMissingHostname is returned when the config could not be validated due to missing hostname.
	ErrMissingHostname = errors.New("failed to automatically set the hostname, you must specify it via configuration for or the DD_HOSTNAME env var")
)

Functions

This section is empty.

Types

type AgentConfig

type AgentConfig struct {
	Enabled bool

	// Global
	Hostname   string
	DefaultEnv string // the traces will default to this environment
	ConfigPath string // the source of this config, if any

	// Endpoints specifies the set of hosts and API keys where traces and stats
	// will be uploaded to. The first endpoint is the main configuration endpoint;
	// any following ones are read from the 'additional_endpoints' parts of the
	// configuration file, if present.
	Endpoints []*Endpoint

	// Concentrator
	BucketInterval   time.Duration // the size of our pre-aggregation per bucket
	ExtraAggregators []string

	// Sampler configuration
	ExtraSampleRate float64
	MaxTPS          float64
	MaxEPS          float64

	// Receiver
	ReceiverHost    string
	ReceiverPort    int
	ConnectionLimit int // for rate-limiting, how many unique connections to allow in a lease period (30s)
	ReceiverTimeout int

	// Writers
	ServiceWriterConfig writerconfig.ServiceWriterConfig
	StatsWriterConfig   writerconfig.StatsWriterConfig
	TraceWriterConfig   writerconfig.TraceWriterConfig

	// internal telemetry
	StatsdHost string
	StatsdPort int

	// logging
	LogLevel             string
	LogFilePath          string
	LogThrottlingEnabled bool

	// watchdog
	MaxMemory        float64       // MaxMemory is the threshold (bytes allocated) above which program panics and exits, to be restarted
	MaxCPU           float64       // MaxCPU is the max UserAvg CPU the program should consume
	MaxConnections   int           // (deprecated) MaxConnections is the threshold (opened TCP connections) above which program panics and exits, to be restarted
	WatchdogInterval time.Duration // WatchdogInterval is the delay between 2 watchdog checks

	// http/s proxying
	ProxyURL          *url.URL
	SkipSSLValidation bool

	// filtering
	Ignore map[string][]string

	// ReplaceTags is used to filter out sensitive information from tag values.
	// It maps tag keys to a set of replacements. Only supported in A6.
	ReplaceTags []*ReplaceRule

	// transaction analytics
	AnalyzedRateByServiceLegacy map[string]float64
	AnalyzedSpansByService      map[string]map[string]float64

	// infrastructure agent binary
	DDAgentBin string // DDAgentBin will be "" for Agent5 scenarios

	// Obfuscation holds sensitive data obufscator's configuration.
	Obfuscation *ObfuscationConfig
}

AgentConfig handles the interpretation of the configuration (with default behaviors) in one place. It is also a simple structure to share across all the Agent components, with 100% safe and reliable values. It is exposed with expvar, so make sure to exclude any sensible field from JSON encoding. Use New() to create an instance.

func Load

func Load(path string) (*AgentConfig, error)

Load returns a new configuration based on the given path. The path must not necessarily exist and a valid configuration can be returned based on defaults and environment variables. If a valid configuration can not be obtained, an error is returned.

func New

func New() *AgentConfig

New returns a configuration with the default values.

type Enablable

type Enablable struct {
	Enabled bool `mapstructure:"enabled"`
}

Enablable can represent any option that has an "enabled" boolean sub-field.

type Endpoint

type Endpoint struct {
	APIKey string `json:"-"` // never marshal this
	Host   string

	// NoProxy will be set to true when the proxy setting for the trace API endpoint
	// needs to be ignored (e.g. it is part of the "no_proxy" list in the yaml settings).
	NoProxy bool
}

Endpoint specifies an endpoint that the trace agent will write data (traces, stats & services) to.

type HTTPObfuscationConfig

type HTTPObfuscationConfig struct {
	// RemoveQueryStrings determines query strings to be removed from HTTP URLs.
	RemoveQueryString bool `mapstructure:"remove_query_string"`

	// RemovePathDigits determines digits in path segments to be obfuscated.
	RemovePathDigits bool `mapstructure:"remove_paths_with_digits"`
}

HTTPObfuscationConfig holds the configuration settings for HTTP obfuscation.

type JSONObfuscationConfig

type JSONObfuscationConfig struct {
	// Enabled will specify whether obfuscation should be enabled.
	Enabled bool `mapstructure:"enabled"`

	// KeepValues will specify a set of keys for which their values will
	// not be obfuscated.
	KeepValues []string `mapstructure:"keep_values"`
}

JSONObfuscationConfig holds the obfuscation configuration for sensitive data found in JSON objects.

type ObfuscationConfig

type ObfuscationConfig struct {
	// ES holds the obfuscation configuration for ElasticSearch bodies.
	ES JSONObfuscationConfig `mapstructure:"elasticsearch"`

	// Mongo holds the obfuscation configuration for MongoDB queries.
	Mongo JSONObfuscationConfig `mapstructure:"mongodb"`

	// HTTP holds the obfuscation settings for HTTP URLs.
	HTTP HTTPObfuscationConfig `mapstructure:"http"`

	// RemoveStackTraces specifies whether stack traces should be removed.
	// More specifically "error.stack" tag values will be cleared.
	RemoveStackTraces bool `mapstructure:"remove_stack_traces"`

	// Redis holds the configuration for obfuscating the "redis.raw_command" tag
	// for spans of type "redis".
	Redis Enablable `mapstructure:"redis"`

	// Memcached holds the configuration for obfuscating the "memcached.command" tag
	// for spans of type "memcached".
	Memcached Enablable `mapstructure:"memcached"`
}

ObfuscationConfig holds the configuration for obfuscating sensitive data for various span types.

type ReplaceRule

type ReplaceRule struct {
	// Name specifies the name of the tag that the replace rule addresses. However,
	// some exceptions apply such as:
	// • "resource.name" will target the resource
	// • "*" will target all tags and the resource
	Name string `mapstructure:"name"`

	// Pattern specifies the regexp pattern to be used when replacing. It must compile.
	Pattern string `mapstructure:"pattern"`

	// Re holds the compiled Pattern and is only used internally.
	Re *regexp.Regexp `mapstructure:"-"`

	// Repl specifies the replacement string to be used when Pattern matches.
	Repl string `mapstructure:"repl"`
}

Jump to

Keyboard shortcuts

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