config

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2018 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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"`
	Target         *TargetConfig      `yaml:"target,omitempty"`
	Jobs           []*JobConfig       `yaml:"jobs,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 jobs and collectors.

func Load

func Load(configFile string) (*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 JobConfig

type JobConfig struct {
	Name          string          `yaml:"job_name"`       // name of this job
	CollectorRefs []string        `yaml:"collectors"`     // names of collectors to apply to all targets in this job
	StaticConfigs []*StaticConfig `yaml:"static_configs"` // collections of statically defined targets

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

JobConfig defines a set of collectors to be executed on a set of targets.

func (*JobConfig) Collectors

func (j *JobConfig) Collectors() []*CollectorConfig

Collectors returns the collectors referenced by the job, resolved.

func (*JobConfig) UnmarshalYAML

func (j *JobConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface for JobConfig.

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
	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 StaticConfig

type StaticConfig struct {
	Targets map[string]Secret `yaml:"targets"`          // map of target names to data source names
	Labels  map[string]string `yaml:"labels,omitempty"` // labels to apply to all metrics collected from the targets

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

StaticConfig defines a set of targets and optional labels to apply to the metrics collected from them.

func (*StaticConfig) UnmarshalYAML

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

UnmarshalYAML implements the yaml.Unmarshaler interface for StaticConfig.

type TargetConfig

type TargetConfig struct {
	DSN           Secret   `yaml:"data_source_name"` // data source name to connect to
	CollectorRefs []string `yaml:"collectors"`       // names of collectors to execute on the target

	// 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