config

package
v0.99.35 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2017 License: BSD-3-Clause Imports: 14 Imported by: 12

README

Agent Configuration

The trace-agent sources configuration from the following locations:

  1. The path pointed to by the -ddconfig command line flag (default: /etc/dd-agent/datadog.conf)
  2. The path pointed to by the -config command line flag (default: /etc/dd-agent/dd-process-agent.ini)
  3. Environment variables: See full list below

Environment variables will override settings defined in configuration files.

Classic configuration values, and how the trace-agent treats them

Note that changing these will also change the behavior of the datadog-agent running on the same host.

In the file pointed to by -ddconfig

[Main]
# Enable the process agent.
process_agent_enabled = true

# process-agent will use this api key when reporting to the Datadog backend.
# no default.
api_key =

# process-agent will log it's output with this log level
log_level = INFO

Other process-specific config lives in the [process.config] section.

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_PROCESS_AGENT_ENABLED - overrides [Main] process_agent_enabled
  • DD_HOSTNAME - overrides [Main] hostname
  • DD_API_KEY - overrides [Main] api_key
  • DD_LOG_LEVEL - overrides [Main] log_level

Logging

Unlike dd-agent, the process-agent does not configure it's own logging and relies on the process manager to redirect it's output. While standard installs (apt-get, yum) will log output to /var/log/datadog/process-agent.log, any non-standard install should attempt to handle STDERR in a sane way

Documentation

Overview

This is a duplicate of config/config.go without a dependency on dd-go/util to avoid pulling in the world.

Index

Constants

View Source
const (
	DefaultLogLevel    = "info"
	DefaultSyslogHost  = "localhost:514"
	DefaultSyslogLevel = "error"
)

Variables

This section is empty.

Functions

func IsBlacklisted

func IsBlacklisted(cmdline []string, blacklist []*regexp.Regexp) bool

IsBlacklisted returns a boolean indicating if the given command is blacklisted by our config.

func NewLoggerLevel added in v0.99.32

func NewLoggerLevel(logLevel string) error

func ReplaceLogger added in v0.99.32

func ReplaceLogger(cfg *LoggerConfig) error

func Set

func Set(config *ini.File)

Set points to the given config as the new global config. This is only used for testing.

Types

type AgentConfig

type AgentConfig struct {
	Enabled       bool
	APIKey        string
	HostName      string
	APIEndpoint   *url.URL
	LogLevel      string
	QueueSize     int
	Blacklist     []*regexp.Regexp
	MaxProcFDs    int
	ProcLimit     int
	AllowRealTime bool
	Proxy         *url.URL
	Timers        *CheckTimers
	Logger        *LoggerConfig

	// Kubernetes
	CollectKubernetesMetadata  bool
	KubernetesKubeletHost      string
	KubernetesHTTPKubeletPort  int
	KubernetesHTTPSKubeletPort int
}

func NewAgentConfig

func NewAgentConfig(agentConf, legacyConf *File) (*AgentConfig, error)

NewAgentConfig returns an AgentConfig using a conf and legacy configuration. conf will be nil if there is no configuration available but legacyConf will give an error if nil.

func NewDefaultAgentConfig

func NewDefaultAgentConfig() *AgentConfig

NewDefaultAgentConfig returns an AgentConfig with defaults initialized

type CheckTimers

type CheckTimers struct {
	Process     *time.Ticker
	Connections *time.Ticker
	RealTime    *time.Ticker
}

type File

type File struct {
	Path string
	// contains filtered or unexported fields
}

A File is a representation of an ini file with some custom convenience methods.

func Get

func Get() *File

Get returns the currently active global config (the previous config opened via NewFile)

func New

func New(configPath string) (*File, error)

New reads the file in configPath and returns a corresponding *File or an error if encountered. This File is set as the default active config file.

func NewIfExists

func NewIfExists(configPath string) (*File, error)

NewIfExists works as New, but does not return an error if the file does not exist. Instead, it returns a null File pointer.

func (*File) Get

func (c *File) Get(section, name string) (string, error)

Get returns a value from the section/name pair, or an error if it can't be found.

func (*File) GetBool

func (c *File) GetBool(section, name string, defaultVal bool) bool

GetBool returns a truthy config value. It accepts 1, t, T, TRUE, true, True, YES, yes, Yes, y, ON, on, On, 0, f, F, FALSE, false, False, NO, no, No, n, OFF, off, Off. Any other value returns an error.

func (*File) GetDefault

func (c *File) GetDefault(section, name string, defaultVal string) string

GetDefault attempts to get the value in section/name, but returns the default if one is not found.

func (*File) GetDuration

func (c *File) GetDuration(section, name string, unit time.Duration) (time.Duration, error)

GetDuration returns a value from section/name converted to a duration using unit.

func (*File) GetDurationDefault

func (c *File) GetDurationDefault(section, name string, unit, defaultVal time.Duration) time.Duration

GetDuration returns a value from section/name converted to a duration using unit and returns the default if any error occurs.

func (*File) GetFloat

func (c *File) GetFloat(section, name string) (float64, error)

GetFloat gets an float value from section/name, or an error if it is missing or cannot be converted to an float.

func (*File) GetInt

func (c *File) GetInt(section, name string) (int, error)

GetInt gets an integer value from section/name, or an error if it is missing or cannot be converted to an integer.

func (*File) GetIntDefault

func (c *File) GetIntDefault(section, name string, defaultVal int) int

GetIntDefault gets an integer value from section/name, but returns the default if one is not found.

func (*File) GetSection

func (c *File) GetSection(key string) (*ini.Section, error)

GetSection is a convenience method to return an entire section of ini config

func (*File) GetStrArray

func (c *File) GetStrArray(section, name, sep string) ([]string, error)

GetStrArray returns the value split across `sep` into an array of strings.

func (*File) GetStrArrayDefault

func (c *File) GetStrArrayDefault(section, name, sep string, defaultVal []string) []string

GetStrArrayDefault returns the value split across `sep` into an array of strings or the defaultVal if the key is not available in section.

type LoggerConfig added in v0.99.32

type LoggerConfig struct {
	AppName     string
	LogLevel    string
	Console     bool
	Syslog      bool
	SyslogLevel string
	SyslogHost  string
	Filename    string
}

LoggerConfig defines the configuration of a logger

func (*LoggerConfig) SeelogConfig added in v0.99.32

func (cfg *LoggerConfig) SeelogConfig() (*seelogConfig, error)

func (*LoggerConfig) SeelogLogger added in v0.99.32

func (cfg *LoggerConfig) SeelogLogger() (log.LoggerInterface, error)

SeelogLogger returns a new seelog Logger

Jump to

Keyboard shortcuts

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