config

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfigFromFile

func LoadConfigFromFile(logger *log.Logger, config *Config, filename string) error

LoadConfigFromFile fills a configuration object (passed as parameter) with values read from a configuration file (pass as parameter by filename). The configuration file needs to be in HCL format.

func LoadConfigFromFlags

func LoadConfigFromFlags(config *Config, flags *StartupFlags) error

LoadConfigFromFlags fills a configuration object (passed as parameter) with values from command-line flags.

func LoadConfigFromStream

func LoadConfigFromStream(logger *log.Logger, config *Config, stream io.Reader, typ FileFormat) error

LoadConfigFromStream fills a configuration object (passed as parameter) with values read from a Reader interface (passed as parameter).

Types

type Config

type Config struct {
	Listen                     ListenConfig
	Consul                     ConsulConfig
	Namespaces                 []NamespaceConfig `hcl:"namespace"`
	EnableExperimentalFeatures bool              `hcl:"enable_experimental" yaml:"enable_experimental"`

	// In YAML, the EnableExperimentalFeatures property was originally set by the
	// "enableexperimentalfeatures" property (although documented as "enable_experimental").
	// This property is here for enabling the config to behave as documented, while keeping BC.
	EnableExperimentalFeaturesOld bool `yaml:"enableexperimentalfeatures"`
}

Config models the application's configuration

func (*Config) StabilityWarnings

func (c *Config) StabilityWarnings() error

StabilityWarnings tests if the Config or any of its sub-objects uses any configuration settings that are not yet declared "stable"

type ConsulConfig

type ConsulConfig struct {
	Enable     bool
	Address    string
	Datacenter string
	Scheme     string
	Token      string
	Service    ConsulServiceConfig
}

ConsulConfig describes the connection to a Consul server that the exporter should register itself at

type ConsulServiceConfig

type ConsulServiceConfig struct {
	ID      string
	Name    string
	Address string
	Tags    []string
}

ConsulServiceConfig describes the Consul service that the exporter should use

type FileFormat

type FileFormat int

FileFormat describes which kind of configuration file the exporter was started with

const (
	// TypeHCL describes the HCL (Hashicorp configuration language) file format
	TypeHCL FileFormat = iota
	// TypeYAML describes the YAML file format
	TypeYAML
)

type FileSource

type FileSource []string

type ListenConfig

type ListenConfig struct {
	Port            int
	Address         string
	MetricsEndpoint string `hcl:"metrics_endpoint" yaml:"metrics_endpoint"`
}

ListenConfig is a struct describing the built-in webserver configuration

func (*ListenConfig) MetricsEndpointOrDefault

func (l *ListenConfig) MetricsEndpointOrDefault() string

MetricsEndpointOrDefault returns the configured metrics endpoint or the default value if no configuration was provided.

type NamespaceConfig

type NamespaceConfig struct {
	Name string `hcl:",key"`

	NamespaceLabelName string `hcl:"namespace_label" yaml:"namespace_label"`
	NamespaceLabels    map[string]string

	MetricsOverride *struct {
		Prefix string `hcl:"prefix" yaml:"prefix"`
	} `hcl:"metrics_override" yaml:"metrics_override"`
	NamespacePrefix string

	SourceFiles      []string          `hcl:"source_files" yaml:"source_files"`
	SourceData       SourceData        `hcl:"source" yaml:"source"`
	Parser           string            `hcl:"parser" yaml:"parser"`
	Format           string            `hcl:"format" yaml:"format"`
	Labels           map[string]string `hcl:"labels" yaml:"labels"`
	RelabelConfigs   []RelabelConfig   `hcl:"relabel" yaml:"relabel_configs"`
	HistogramBuckets []float64         `hcl:"histogram_buckets" yaml:"histogram_buckets"`

	PrintLog bool `hcl:"print_log" yaml:"print_log"`

	OrderedLabelNames  []string
	OrderedLabelValues []string
}

NamespaceConfig is a struct describing single metric namespaces

func (*NamespaceConfig) Compile

func (c *NamespaceConfig) Compile() error

Compile compiles the configuration (mostly regular expressions that are used in configuration variables) for later use

func (*NamespaceConfig) DeprecationWarnings

func (c *NamespaceConfig) DeprecationWarnings() error

DeprecationWarnings tests if the NamespaceConfig uses any deprecated configuration settings

func (*NamespaceConfig) MustCompile

func (c *NamespaceConfig) MustCompile()

MustCompile compiles the configuration (mostly regular expressions that are used in configuration variables) for later use

func (*NamespaceConfig) OrderLabels

func (c *NamespaceConfig) OrderLabels()

OrderLabels builds two lists of label keys and values, ordered by label name

func (*NamespaceConfig) ResolveDeprecations

func (c *NamespaceConfig) ResolveDeprecations()

ResolveDeprecations converts any values from depreated fields into the new structures

func (*NamespaceConfig) ResolveGlobs

func (c *NamespaceConfig) ResolveGlobs(logger *log.Logger) error

ResolveGlobs finds globs in file sources and expand them to the actual list of files

func (*NamespaceConfig) StabilityWarnings

func (c *NamespaceConfig) StabilityWarnings() error

StabilityWarnings tests if the NamespaceConfig uses any configuration settings that are not yet declared "stable"

type RelabelConfig

type RelabelConfig struct {
	TargetLabel string              `hcl:",key" yaml:"target_label"`
	SourceValue string              `hcl:"from" yaml:"from"`
	Whitelist   []string            `hcl:"whitelist"`
	Matches     []RelabelValueMatch `hcl:"match"`
	Split       int                 `hcl:"split"`
	Separator   string              `hcl:"separator"`
	OnlyCounter bool                `hcl:"only_counter" yaml:"only_counter"`

	WhitelistExists bool
	WhitelistMap    map[string]interface{}
}

RelabelConfig is a struct describing a single re-labeling configuration for taking over label values from an access log line into a Prometheus metric

func (*RelabelConfig) Compile

func (c *RelabelConfig) Compile() error

Compile compiles expressions and lookup tables for efficient later use

type RelabelValueMatch

type RelabelValueMatch struct {
	RegexpString string `hcl:",key" yaml:"regexp"`
	Replacement  string `hcl:"replacement"`

	CompiledRegexp *regexp.Regexp
}

RelabelValueMatch describes a single label match statement

type SourceData

type SourceData struct {
	Files  FileSource    `hcl:"files" yaml:"files"`
	Syslog *SyslogSource `hcl:"syslog" yaml:"syslog"`
}

type StartupFlags

type StartupFlags struct {
	ConfigFile                 string
	Filenames                  []string
	Parser                     string
	Format                     string
	Namespace                  string
	ListenAddress              string
	ListenPort                 int
	EnableExperimentalFeatures bool
	MetricsEndpoint            string
	VerifyConfig               bool
	Version                    bool

	LogLevel  string
	LogFormat string

	CPUProfile string
	MemProfile string
}

StartupFlags is a struct containing options that can be passed via the command line

type SyslogSource

type SyslogSource struct {
	ListenAddress string   `hcl:"listen_address" yaml:"listen_address"`
	Format        string   `hcl:"format" yaml:"format"`
	Tags          []string `hcl:"tags" yaml:"tags"`
}

Jump to

Keyboard shortcuts

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