config

package
v0.36.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckSecret added in v0.20.1

func CheckSecret(t *testing.T, rawCfg string, originalValue string)

CheckSecret is a helper function to ensure the original value is overwritten with <secret>

func LoadBytes added in v0.4.0

func LoadBytes(buf []byte, expandEnvVars bool, c *Config) error

LoadBytes unmarshals a config from a buffer. Defaults are not applied to the file and must be done manually if LoadBytes is called directly.

func LoadFile

func LoadFile(filename string, expandEnvVars bool, c *Config) error

LoadFile reads a file and passes the contents to Load

func LoadRemote added in v0.22.0

func LoadRemote(url string, expandEnvVars bool, c *Config) error

LoadRemote reads a config from url

Types

type AgentManagementConfig added in v0.31.0

type AgentManagementConfig struct {
	Enabled          bool                    `yaml:"-"` // Derived from enable-features=agent-management
	Host             string                  `yaml:"host"`
	Protocol         string                  `yaml:"protocol"`
	PollingInterval  time.Duration           `yaml:"polling_interval"`
	HTTPClientConfig config.HTTPClientConfig `yaml:",inline"`

	RemoteConfiguration RemoteConfiguration `yaml:"remote_configuration"`
}

func (*AgentManagementConfig) JitterTime added in v0.33.0

func (am *AgentManagementConfig) JitterTime() time.Duration

jitterTime returns a random duration in the range [0, am.PollingInterval).

func (*AgentManagementConfig) SleepTime added in v0.31.0

func (am *AgentManagementConfig) SleepTime() time.Duration

SleepTime returns the duration in between config fetches.

func (*AgentManagementConfig) Validate added in v0.31.0

func (am *AgentManagementConfig) Validate() error

Validate checks that necessary portions of the config have been set.

type BaseConfigContent added in v0.33.0

type BaseConfigContent string

BaseConfigContent is the content of a base config

type Config

type Config struct {
	Server          *server.Config        `yaml:"server,omitempty"`
	Metrics         metrics.Config        `yaml:"metrics,omitempty"`
	Integrations    VersionedIntegrations `yaml:"integrations,omitempty"`
	Traces          traces.Config         `yaml:"traces,omitempty"`
	Logs            *logs.Config          `yaml:"logs,omitempty"`
	AgentManagement AgentManagementConfig `yaml:"agent_management,omitempty"`

	// Flag-only fields
	ServerFlags server.Flags `yaml:"-"`

	// Deprecated fields user has used. Generated during UnmarshalYAML.
	Deprecations []string `yaml:"-"`

	// Remote config options
	BasicAuthUser     string `yaml:"-"`
	BasicAuthPassFile string `yaml:"-"`

	// Toggle for config endpoint(s)
	EnableConfigEndpoints bool `yaml:"-"`

	// Toggle for support bundle generation.
	DisableSupportBundle bool `yaml:"-"`

	// Report enabled features options
	EnableUsageReport bool     `yaml:"-"`
	EnabledFeatures   []string `yaml:"-"`
}

Config contains underlying configurations for the agent

func DefaultConfig added in v0.14.0

func DefaultConfig() Config

DefaultConfig holds default settings for all the subsystems.

func Load

func Load(fs *flag.FlagSet, args []string, log *server.Logger) (*Config, error)

Load loads a config file from a flagset. Flags will be registered to the flagset before parsing them with the values specified by args.

func LoadFromFunc added in v0.36.0

func LoadFromFunc(fs *flag.FlagSet, args []string, loader loaderFunc) (*Config, error)

LoadFromFunc injects a function for retrieving the config file that doesn't require having a literal file on disk.

func (*Config) LogDeprecations added in v0.19.0

func (c *Config) LogDeprecations(l log.Logger)

LogDeprecations will log use of any deprecated fields to l as warn-level messages.

func (Config) MarshalYAML added in v0.20.1

func (c Config) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler.

func (*Config) RegisterFlags

func (c *Config) RegisterFlags(f *flag.FlagSet)

RegisterFlags registers flags in underlying configs

func (*Config) UnmarshalYAML added in v0.14.0

func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements yaml.Unmarshaler.

func (*Config) Validate added in v0.22.0

func (c *Config) Validate(fs *flag.FlagSet) error

Validate validates the config, flags, and sets default values.

type Integrations added in v0.22.0

type Integrations interface {
	ApplyConfig(*VersionedIntegrations, IntegrationsGlobals) error
	WireAPI(*mux.Router)
	Stop()
}

Integrations is an abstraction over both the v1 and v2 systems.

func NewIntegrations added in v0.22.0

func NewIntegrations(logger log.Logger, cfg *VersionedIntegrations, globals IntegrationsGlobals) (Integrations, error)

NewIntegrations creates a new subsystem. globals should be provided regardless of useV2. globals.SubsystemOptions will be automatically set if cfg.Version is set to IntegrationsVersion2.

type IntegrationsGlobals added in v0.22.0

type IntegrationsGlobals = v2.Globals

IntegrationsGlobals is a global struct shared across integrations.

type RemoteConfig added in v0.33.0

type RemoteConfig struct {
	BaseConfig BaseConfigContent `json:"base_config" yaml:"base_config"`
	Snippets   []Snippet         `json:"snippets" yaml:"snippets"`
}

func NewRemoteConfig added in v0.33.0

func NewRemoteConfig(buf []byte) (*RemoteConfig, error)

func (*RemoteConfig) BuildAgentConfig added in v0.33.0

func (rc *RemoteConfig) BuildAgentConfig() (*Config, error)

BuildAgentConfig builds an agent configuration from a base config and a list of snippets

type RemoteConfiguration added in v0.31.0

type RemoteConfiguration struct {
	Labels                 labelMap `yaml:"labels"`
	LabelManagementEnabled bool     `yaml:"label_management_enabled"`
	AgentID                string   `yaml:"agent_id"`
	Namespace              string   `yaml:"namespace"`
	CacheLocation          string   `yaml:"cache_location"`
}

type Snippet added in v0.33.0

type Snippet struct {
	// Config is the snippet of config to be included.
	Config string `json:"config" yaml:"config"`
}

Snippet is a snippet of configuration returned by the config API.

type SnippetContent added in v0.33.0

type SnippetContent struct {
	// MetricsScrapeConfigs is a YAML containing list of metrics scrape configs.
	MetricsScrapeConfigs []*pc.ScrapeConfig `yaml:"metrics_scrape_configs,omitempty"`

	// LogsScrapeConfigs is a YAML containing list of logs scrape configs.
	LogsScrapeConfigs []scrapeconfig.Config `yaml:"logs_scrape_configs,omitempty"`

	// IntegrationConfigs is a YAML containing list of integrations.
	IntegrationConfigs integrations.ManagerConfig `yaml:"integration_configs,omitempty"`
}

SnippetContent defines the internal structure of a snippet configuration.

type VersionedIntegrations added in v0.22.0

type VersionedIntegrations struct {
	ConfigV1 *v1.ManagerConfig

	// ExtraIntegrations is used when adding any integrations NOT in the default agent configuration
	ExtraIntegrations []v2.Config
	// contains filtered or unexported fields
}

VersionedIntegrations abstracts the subsystem configs for integrations v1 and v2. VersionedIntegrations can only be unmarshaled as part of Load.

func DefaultVersionedIntegrations added in v0.22.0

func DefaultVersionedIntegrations() VersionedIntegrations

DefaultVersionedIntegrations is the default config for integrations.

func (*VersionedIntegrations) ApplyDefaults added in v0.22.0

func (c *VersionedIntegrations) ApplyDefaults(sflags *server.Flags, mcfg *metrics.Config) error

ApplyDefaults applies defaults to the subsystem based on globals.

func (*VersionedIntegrations) EnabledIntegrations added in v0.29.0

func (c *VersionedIntegrations) EnabledIntegrations() []string

EnabledIntegrations returns a slice of enabled integrations

func (VersionedIntegrations) IsZero added in v0.22.0

func (c VersionedIntegrations) IsZero() bool

IsZero implements yaml.IsZeroer.

func (VersionedIntegrations) MarshalYAML added in v0.22.0

func (c VersionedIntegrations) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler.

func (*VersionedIntegrations) UnmarshalYAML added in v0.22.0

func (c *VersionedIntegrations) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements yaml.Unmarshaler. Full unmarshaling is deferred until setVersion is invoked.

Directories

Path Synopsis
Package features enables a way to encode enabled features in a flag.FlagSet.
Package features enables a way to encode enabled features in a flag.FlagSet.

Jump to

Keyboard shortcuts

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