config

package
v0.0.0-...-f2b6d06 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorWrap

func ErrorWrap(logContext []interface{}, err error) error

Types

type CollectorConfig

type CollectorConfig struct {
	Name        string          `yaml:"collector_name"`         // name of this collector
	MinInterval model.Duration  `yaml:"min_interval,omitempty"` // minimum interval between query executions
	Metrics     []*MetricConfig `yaml:"metrics"`                // metrics/queries defined by this collector
	Queries     []*QueryConfig  `yaml:"queries,omitempty"`      // named queries defined by this collector

	// Catches all undefined fields and must be empty after parsing.
	XXX map[string]interface{} `yaml:",inline" json:"-"`
}

CollectorConfig defines a set of metrics and how they are collected.

func (*CollectorConfig) UnmarshalYAML

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

UnmarshalYAML implements the yaml.Unmarshaler interface for CollectorConfig.

type Config

type Config struct {
	Globals        *GlobalConfig      `yaml:"global"`
	CollectorFiles []string           `yaml:"collector_files,omitempty"`
	Targets        []*TargetConfig    `yaml:"targets,omitempty"`
	Collectors     []*CollectorConfig `yaml:"collectors,omitempty"`

	// Catches all undefined fields and must be empty after parsing.
	XXX map[string]interface{} `yaml:",inline" json:"-"`
	// contains filtered or unexported fields
}

Config is a collection of targets and collectors.

func Load

func Load(configFile string, logger log.Logger) (*Config, error)

Load attempts to parse the given config file and return a Config object.

func (*Config) UnmarshalYAML

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

UnmarshalYAML implements the yaml.Unmarshaler interface for Config.

func (*Config) YAML

func (c *Config) YAML() ([]byte, error)

YAML marshals the config into YAML format.

type GlobalConfig

type GlobalConfig struct {
	MinInterval   model.Duration `yaml:"min_interval"`          // minimum interval between query executions, default is 0
	ScrapeTimeout model.Duration `yaml:"scrape_timeout"`        // per-scrape timeout, global
	TimeoutOffset model.Duration `yaml:"scrape_timeout_offset"` // offset to subtract from timeout in seconds
	MaxConns      int            `yaml:"max_connections"`       // maximum number of open connections to any one target
	MaxIdleConns  int            `yaml:"max_idle_connections"`  // maximum number of idle connections to any one target

	// Catches all undefined fields and must be empty after parsing.
	XXX map[string]interface{} `yaml:",inline" json:"-"`
}

GlobalConfig contains globally applicable defaults.

func (*GlobalConfig) UnmarshalYAML

func (g *GlobalConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface for GlobalConfig.

type MetricConfig

type MetricConfig struct {
	Name         string            `yaml:"metric_name"`             // the Prometheus metric name
	TypeString   string            `yaml:"type"`                    // the Prometheus metric type
	Help         string            `yaml:"help"`                    // the Prometheus metric help text
	KeyLabels    []string          `yaml:"key_labels,omitempty"`    // expose these columns as labels from SQL
	StaticLabels map[string]string `yaml:"static_labels,omitempty"` // fixed key/value pairs as static labels
	ValueLabel   string            `yaml:"value_label,omitempty"`   // with multiple value columns, map their names under this label
	Values       []string          `yaml:"values"`                  // expose each of these columns as a value, keyed by column name
	QueryLiteral string            `yaml:"query,omitempty"`         // a literal query
	QueryRef     string            `yaml:"query_ref,omitempty"`     // references a query in the query map

	// Catches all undefined fields and must be empty after parsing.
	XXX map[string]interface{} `yaml:",inline" json:"-"`
	// contains filtered or unexported fields
}

MetricConfig defines a Prometheus metric, the SQL query to populate it and the mapping of columns to metric keys/values.

func (*MetricConfig) Query

func (m *MetricConfig) Query() *QueryConfig

Query returns the query defined (as a literal) or referenced by the metric.

func (*MetricConfig) UnmarshalYAML

func (m *MetricConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface for MetricConfig.

func (*MetricConfig) ValueType

func (m *MetricConfig) ValueType() prometheus.ValueType

ValueType returns the metric type, converted to a prometheus.ValueType.

type QueryConfig

type QueryConfig struct {
	Name  string `yaml:"query_name"` // the query name, to be referenced via `query_ref`
	Query string `yaml:"query"`      // the named query

	// Catches all undefined fields and must be empty after parsing.
	XXX map[string]interface{} `yaml:",inline" json:"-"`
	// contains filtered or unexported fields
}

QueryConfig defines a named query, to be referenced by one or multiple metrics.

func (*QueryConfig) UnmarshalYAML

func (q *QueryConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface for QueryConfig.

type Secret

type Secret string

Secret special type for storing secrets.

func (Secret) MarshalYAML

func (s Secret) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface for Secrets.

func (*Secret) UnmarshalYAML

func (s *Secret) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface for Secrets.

type TargetConfig

type TargetConfig struct {
	Name          string            `yaml:"name"`                    // data source name to connect to
	DSN           Secret            `yaml:"data_source_name"`        // data source definition to connect to
	Labels        map[string]string `yaml:"labels,omitempty"`        // labels to apply to all metrics collected from the targets
	CollectorRefs []string          `yaml:"collectors"`              // names of collectors to execute on the target
	TargetsFiles  []string          `yaml:"targets_files,omitempty"` // slice of path and pattern for files that contains targets

	// Catches all undefined fields and must be empty after parsing.
	XXX map[string]interface{} `yaml:",inline" json:"-"`
	// contains filtered or unexported fields
}

TargetConfig defines a DSN and a set of collectors to be executed on it.

func (*TargetConfig) Collectors

func (t *TargetConfig) Collectors() []*CollectorConfig

Collectors returns the collectors referenced by the target, resolved.

func (*TargetConfig) UnmarshalYAML

func (t *TargetConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface for TargetConfig.

Jump to

Keyboard shortcuts

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