config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TLSCACertsSystem string = "system"
	ProxyEnvironment string = "environment"
	ProxyDirect      string = "direct"
)
View Source
const (
	TLSCertificatePoolMaxNonFileEntryReturn int = 50
)

Variables

View Source
var (
	ErrInvalidExportersConfig = errors.New("exporters key is not in the known format")
	ErrUnknownExporterType    = errors.New("unknown exporter type specified")
)
View Source
var (
	ErrInvalidInputType = errors.New("invalid input type for decoder")
	ErrInvalidPEMFile   = errors.New("PEM file could not be added to certificate pool")
)
View Source
var (
	ErrMapStructureDecode = errors.New("MapStructureDecode function failed")
)

Functions

func Decoder

func Decoder(target interface{}, allowUnused bool) (*mapstructure.Decoder, error)

Decoder returns the decoder for config maps.

func DefaultConfigFile

func DefaultConfigFile() []byte

DefaultConfigFile returns the default embedded YAML config which sets the poller_defaults.

func LoadAndSanitizeConfig

func LoadAndSanitizeConfig(configData []byte) (string, error)

LoadAndSanitizeConfig is used purely for displaying the config to users. It removes sensitive keys from the config and provides a reserialized YAML view of it.

func MapStructureDecodeHookFunc

func MapStructureDecodeHookFunc() mapstructure.DecodeHookFuncType

MapStructureDecodeHookFunc returns a DecodeHookFunc that applies output to the UnmarshalYAML function, when the target type implements the yaml.Unmarshaller interface.

Types

type AuthConfig

type AuthConfig struct {
	BasicAuthCredentials []BasicAuthConfig `mapstructure:"basic_auth,omitempty"`
}

AuthConfig holds the configuration of any authentication put on the exporter interface.

type BaseExporter

type BaseExporter interface {
	GetBaseExporter() Exporter
}

BaseExporter is the interface all exporters must implement.

type BasicAuthConfig

type BasicAuthConfig struct {
	Username string `mapstructure:"username,omitempty"` // Username to accept
	Password string `mapstructure:"password,omitempty"` // Plain text password to accept
}

BasicAuthConfig defines basic authentication credentials to accept on the web interface. If Password is not set, then the credential set is ignored. The password is plaintext.

type Bytes

type Bytes []byte

Bytes implements a custom []byte slice implemented TextMarshaller so base64 binary content can be passed n.

func (*Bytes) MarshalText

func (d *Bytes) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*Bytes) UnmarshalText

func (d *Bytes) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type Config

type Config struct {
	Web              *WebConfig               `mapstructure:"web,omitempty"`
	ExporterDefaults *ExporterDefaults        `mapstructure:"exporter_defaults,omitempty"`
	ReverseExporters []*ReverseExporterConfig `mapstructure:"reverse_exporters,omitempty"`
}

Config is the main application configuration structure.

func Load

func Load(configData []byte) (*Config, error)

Load loads a configuration file from the supplied bytes.

func LoadFromFile

func LoadFromFile(filename string) (*Config, error)

type ExecCachingExporterConfig

type ExecCachingExporterConfig struct {
	Exporter     `mapstructure:",squash"`
	Command      string         `mapstructure:"command"`
	Args         []string       `mapstructure:"args"`
	ExecInterval model.Duration `mapstructure:"exec_interval"`
}

ExecCachingExporterConfig contains configuration specific to reverse proxying cached executable scripts.

type ExecExporterConfig

type ExecExporterConfig struct {
	Exporter `mapstructure:",squash"`
	Command  string   `mapstructure:"command"`
	Args     []string `mapstructure:"args"`
}

ExecExporterConfig contains configuration specific to reverse proxying executable scripts.

type Exporter

type Exporter struct {
	// Name is the name of the underlying exporter which will be appended to the metrics
	Name string `mapstructure:"name"`
	// NoRewrite disables appending of the name (explicit labels will be appended however)
	NoRewrite bool `mapstructure:"no_rewrite"`
	// Labels are additional key-value labels which should be statically added to all metrics
	Labels map[string]string `mapstructure:"labels"`
}

Exporter implements BaseExporter.

func (Exporter) GetBaseExporter

func (e Exporter) GetBaseExporter() Exporter

GetBaseExporter returns the common exporter parameters of an exporter.

type ExporterDefaults

type ExporterDefaults struct {
	HTTPDefaults       *HTTPExporterConfig        `mapstructure:"http"`
	FileDefaults       *FileExporterConfig        `mapstructure:"file"`
	ExecDefaults       *ExecExporterConfig        `mapstructure:"exec"`
	ExecCachedDefaults *ExecCachingExporterConfig `mapstructure:"exec_cached"`
}

type ExportersConfig

type ExportersConfig struct {
	HTTPExporters       []*HTTPExporterConfig        `mapstructure:"http"`
	FileExporters       []*FileExporterConfig        `mapstructure:"file"`
	ExecExporters       []*ExecExporterConfig        `mapstructure:"exec"`
	ExecCachedExporters []*ExecCachingExporterConfig `mapstructure:"exec_cached"`
}

ExportersConfig is the internal mapping the exporter config representation.

func (*ExportersConfig) All

func (ex *ExportersConfig) All() []BaseExporter

type FileExporterConfig

type FileExporterConfig struct {
	Exporter `mapstructure:",squash"`
	Path     string `mapstructure:"path"`
}

FileExporterConfig contains configuration specific to reverse proxying files.

type HTTPExporterConfig

type HTTPExporterConfig struct {
	Exporter `mapstructure:",squash"`
	// A URI giving the address the exporter is found at.
	// HTTP: http://localhost/metrics
	// Unix: http://unix:/path/to/socket:/metrics
	Address string `mapstructure:"address"`
	// Timeout is the maximum length of time connecting to and retrieving the
	// results of this exporter can take.
	Timeout model.Duration `mapstructure:"timeout,omitempty"`
	// ForwardURLParams determines whether the exporter will have ALL url params
	// of the parent request added to it.
	ForwardURLParams bool `mapstructure:"forward_url_params"`
}

HTTPExporterConfig contains configuration specific to reverse proxying normal http-based Prometheus exporters.

type HTTPStatusRange

type HTTPStatusRange map[int]bool

HTTPStatusRange is a range of HTTP status codes which can be specifid in YAML using human-friendly ranging notation.

func (*HTTPStatusRange) FromString

func (hsr *HTTPStatusRange) FromString(ranges string) error

FromString initializes a new HTTPStatusRange from the given string specifier

func (HTTPStatusRange) MarshalText

func (hsr HTTPStatusRange) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler.

func (*HTTPStatusRange) UnmarshalText

func (hsr *HTTPStatusRange) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler.

type HTTPVerb

type HTTPVerb string

HTTPVerb wraps string to ensure that verbs are uppercase. It doesn't check if they're valid to allow people to do stupid things with them if they want.

func (*HTTPVerb) MarshalText

func (d *HTTPVerb) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (HTTPVerb) String

func (d HTTPVerb) String() string

func (*HTTPVerb) UnmarshalText

func (d *HTTPVerb) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type IPNetwork

type IPNetwork struct {
	net.IPNet
}

IPNetwork is the config wrapper type for an IP Network.

func (IPNetwork) MarshalYAML

func (ipn IPNetwork) MarshalYAML() (interface{}, error)

func (*IPNetwork) UnmarshalYAML

func (ipn *IPNetwork) UnmarshalYAML(unmarshal func(interface{}) error) error

type MapStructureDecoder

type MapStructureDecoder interface {
	MapStructureDecode(interface{}) error
}

MapStructureDecoder is detected by MapStructureDecodeHookFunc to allow a type to decode itself.

type ProxyURL

type ProxyURL string

ProxyURL is a custom type to validate roxy specifications.

func (*ProxyURL) MarshalText

func (p *ProxyURL) MarshalText() ([]byte, error)

UnmarshalText MarshalText encoding.UnmarshalText.

func (*ProxyURL) UnmarshalText

func (p *ProxyURL) UnmarshalText(text []byte) error

UnmarshalText implements encoding.UnmarshalText.

type Regexp

type Regexp struct {
	*regexp.Regexp
}

Regexp encapsulates a regexp.Regexp and makes it YAML marshallable.

func (*Regexp) MarshalText

func (r *Regexp) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*Regexp) UnmarshalText

func (r *Regexp) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type ReverseExporterConfig

type ReverseExporterConfig struct {
	// Path is the URL path this set of exporters will be found under.
	Path string `mapstructure:"path"`
	// Auth is the auth to request for this path
	Auth *AuthConfig `mapstructure:"auth,omitempty"`
	// Exporters is a list of URLs defining exporter endpoints to be aggregated
	// and the unique name to be given to differentiate their metrics.
	Exporters *ExportersConfig `mapstructure:"exporters"`
}

ReverseExporterConfig is a configuration struct describing a logically-decoded proxied exporter.

type TLSCertificatePool

type TLSCertificatePool struct {
	*x509.CertPool
	// contains filtered or unexported fields
}

TLSCertificatePool is our custom type for decoding a certificate pool out of YAML.

func (*TLSCertificatePool) MapStructureDecode

func (t *TLSCertificatePool) MapStructureDecode(input interface{}) error

MapStructureDecode implements the yaml.Unmarshaler interface for tls_cacerts.

type URL

type URL struct {
	*url.URL
}

URL is a custom URL type that allows validation at configuration load time.

func NewURL

func NewURL(url string) (URL, error)

func (*URL) MarshalText

func (u *URL) MarshalText() ([]byte, error)

MarshalYAML implements the yaml.Marshaler interface for URLs.

func (*URL) UnmarshalText

func (u *URL) UnmarshalText(text []byte) error

UnmarshalYAML implements the yaml.Unmarshaler interface for URLs.

type WebConfig

type WebConfig struct {
	ContextPath       string         `mapstructure:"context_path,omitempty"`
	ReadHeaderTimeout model.Duration `mapstructure:"read_header_timeout,omitempty"`
	Listen            []URL          `mapstructure:"listen,omitempty"`
}

WebConfig holds global configuration for the exporters webserver.

Jump to

Keyboard shortcuts

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