config

package
v1.29.5 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultConfig is the default top-level configuration.
	DefaultConfig = Config{
		GlobalConfig: DefaultGlobalConfig,
	}

	// DefaultGlobalConfig is the default global configuration.
	DefaultGlobalConfig = GlobalConfig{
		ScrapeInterval:     model.Duration(1 * time.Minute),
		ScrapeTimeout:      model.Duration(10 * time.Second),
		EvaluationInterval: model.Duration(1 * time.Minute),
	}

	// DefaultScrapeConfig is the default scrape configuration.
	DefaultScrapeConfig = ScrapeConfig{

		MetricsPath:      "/metrics",
		Scheme:           "http",
		HonorLabels:      false,
		HonorTimestamps:  true,
		HTTPClientConfig: config.DefaultHTTPClientConfig,
	}

	// DefaultAlertmanagerConfig is the default alertmanager configuration.
	DefaultAlertmanagerConfig = AlertmanagerConfig{
		Scheme:           "http",
		Timeout:          model.Duration(10 * time.Second),
		APIVersion:       AlertmanagerAPIVersionV2,
		HTTPClientConfig: config.DefaultHTTPClientConfig,
	}

	// DefaultRemoteWriteConfig is the default remote write configuration.
	DefaultRemoteWriteConfig = RemoteWriteConfig{
		RemoteTimeout:    model.Duration(30 * time.Second),
		QueueConfig:      DefaultQueueConfig,
		MetadataConfig:   DefaultMetadataConfig,
		HTTPClientConfig: config.DefaultHTTPClientConfig,
	}

	// DefaultQueueConfig is the default remote queue configuration.
	DefaultQueueConfig = QueueConfig{

		MaxShards:         200,
		MinShards:         1,
		MaxSamplesPerSend: 500,

		Capacity:          2500,
		BatchSendDeadline: model.Duration(5 * time.Second),

		MinBackoff: model.Duration(30 * time.Millisecond),
		MaxBackoff: model.Duration(100 * time.Millisecond),
	}

	// DefaultMetadataConfig is the default metadata configuration for a remote write endpoint.
	DefaultMetadataConfig = MetadataConfig{
		Send:              true,
		SendInterval:      model.Duration(1 * time.Minute),
		MaxSamplesPerSend: 500,
	}

	// DefaultRemoteReadConfig is the default remote read configuration.
	DefaultRemoteReadConfig = RemoteReadConfig{
		RemoteTimeout:    model.Duration(1 * time.Minute),
		HTTPClientConfig: config.DefaultHTTPClientConfig,
	}

	// DefaultStorageConfig is the default TSDB/Exemplar storage configuration.
	DefaultStorageConfig = StorageConfig{
		ExemplarsConfig: &DefaultExemplarsConfig,
	}

	DefaultExemplarsConfig = ExemplarsConfig{
		MaxExemplars: 100000,
	}
)

The defaults applied before parsing the respective config sections.

Functions

func CheckTargetAddress

func CheckTargetAddress(address model.LabelValue) error

CheckTargetAddress checks if target address is valid.

Types

type AlertingConfig added in v1.1.0

type AlertingConfig struct {
	AlertRelabelConfigs []*relabel.Config   `yaml:"alert_relabel_configs,omitempty"`
	AlertmanagerConfigs AlertmanagerConfigs `yaml:"alertmanagers,omitempty"`
}

AlertingConfig configures alerting and alertmanager related configs.

func (*AlertingConfig) SetDirectory added in v1.29.3

func (c *AlertingConfig) SetDirectory(dir string)

SetDirectory joins any relative file paths with dir.

func (*AlertingConfig) UnmarshalYAML added in v1.4.0

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

UnmarshalYAML implements the yaml.Unmarshaler interface.

type AlertmanagerAPIVersion added in v1.29.3

type AlertmanagerAPIVersion string

AlertmanagerAPIVersion represents a version of the github.com/prometheus/alertmanager/api, e.g. 'v1' or 'v2'.

const (
	// AlertmanagerAPIVersionV1 represents
	// github.com/prometheus/alertmanager/api/v1.
	AlertmanagerAPIVersionV1 AlertmanagerAPIVersion = "v1"
	// AlertmanagerAPIVersionV2 represents
	// github.com/prometheus/alertmanager/api/v2.
	AlertmanagerAPIVersionV2 AlertmanagerAPIVersion = "v2"
)

func (*AlertmanagerAPIVersion) UnmarshalYAML added in v1.29.3

func (v *AlertmanagerAPIVersion) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type AlertmanagerConfig added in v1.4.0

type AlertmanagerConfig struct {
	ServiceDiscoveryConfigs discovery.Configs       `yaml:"-"`
	HTTPClientConfig        config.HTTPClientConfig `yaml:",inline"`

	// The URL scheme to use when talking to Alertmanagers.
	Scheme string `yaml:"scheme,omitempty"`
	// Path prefix to add in front of the push endpoint path.
	PathPrefix string `yaml:"path_prefix,omitempty"`
	// The timeout used when sending alerts.
	Timeout model.Duration `yaml:"timeout,omitempty"`

	// The api version of Alertmanager.
	APIVersion AlertmanagerAPIVersion `yaml:"api_version"`

	// List of Alertmanager relabel configurations.
	RelabelConfigs []*relabel.Config `yaml:"relabel_configs,omitempty"`
}

AlertmanagerConfig configures how Alertmanagers can be discovered and communicated with.

func (*AlertmanagerConfig) MarshalYAML added in v1.29.3

func (c *AlertmanagerConfig) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface.

func (*AlertmanagerConfig) SetDirectory added in v1.29.3

func (c *AlertmanagerConfig) SetDirectory(dir string)

SetDirectory joins any relative file paths with dir.

func (*AlertmanagerConfig) UnmarshalYAML added in v1.4.0

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

UnmarshalYAML implements the yaml.Unmarshaler interface.

type AlertmanagerConfigs added in v1.29.3

type AlertmanagerConfigs []*AlertmanagerConfig

AlertmanagerConfigs is a slice of *AlertmanagerConfig.

func (AlertmanagerConfigs) ToMap added in v1.29.3

ToMap converts a slice of *AlertmanagerConfig to a map.

type Config

type Config struct {
	GlobalConfig   GlobalConfig    `yaml:"global"`
	AlertingConfig AlertingConfig  `yaml:"alerting,omitempty"`
	RuleFiles      []string        `yaml:"rule_files,omitempty"`
	ScrapeConfigs  []*ScrapeConfig `yaml:"scrape_configs,omitempty"`
	StorageConfig  StorageConfig   `yaml:"storage,omitempty"`

	RemoteWriteConfigs []*RemoteWriteConfig `yaml:"remote_write,omitempty"`
	RemoteReadConfigs  []*RemoteReadConfig  `yaml:"remote_read,omitempty"`
}

Config is the top-level configuration for Prometheus's config files.

func Load

func Load(s string, expandExternalLabels bool, logger log.Logger) (*Config, error)

Load parses the YAML input s into a Config.

func LoadFile

func LoadFile(filename string, expandExternalLabels bool, logger log.Logger) (*Config, error)

LoadFile parses the given YAML file into a Config.

func (*Config) SetDirectory added in v1.29.3

func (c *Config) SetDirectory(dir string)

SetDirectory joins any relative file paths with dir.

func (Config) String

func (c Config) String() string

func (*Config) UnmarshalYAML

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

UnmarshalYAML implements the yaml.Unmarshaler interface.

type ExemplarsConfig added in v1.29.3

type ExemplarsConfig struct {
	// MaxExemplars sets the size, in # of exemplars stored, of the single circular buffer used to store exemplars in memory.
	// Use a value of 0 or less than 0 to disable the storage without having to restart Prometheus.
	MaxExemplars int64 `yaml:"max_exemplars,omitempty"`
}

ExemplarsConfig configures runtime reloadable configuration options.

type GlobalConfig

type GlobalConfig struct {
	// How frequently to scrape targets by default.
	ScrapeInterval model.Duration `yaml:"scrape_interval,omitempty"`
	// The default timeout when scraping targets.
	ScrapeTimeout model.Duration `yaml:"scrape_timeout,omitempty"`
	// How frequently to evaluate rules by default.
	EvaluationInterval model.Duration `yaml:"evaluation_interval,omitempty"`
	// File to which PromQL queries are logged.
	QueryLogFile string `yaml:"query_log_file,omitempty"`
	// The labels to add to any timeseries that this Prometheus instance scrapes.
	ExternalLabels labels.Labels `yaml:"external_labels,omitempty"`
}

GlobalConfig configures values that are used across other configuration objects.

func (*GlobalConfig) SetDirectory added in v1.29.3

func (c *GlobalConfig) SetDirectory(dir string)

SetDirectory joins any relative file paths with dir.

func (*GlobalConfig) UnmarshalYAML

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

UnmarshalYAML implements the yaml.Unmarshaler interface.

type MetadataConfig added in v1.29.3

type MetadataConfig struct {
	// Send controls whether we send metric metadata to remote storage.
	Send bool `yaml:"send"`
	// SendInterval controls how frequently we send metric metadata.
	SendInterval model.Duration `yaml:"send_interval"`
	// Maximum number of samples per send.
	MaxSamplesPerSend int `yaml:"max_samples_per_send,omitempty"`
}

MetadataConfig is the configuration for sending metadata to remote storage.

type QueueConfig added in v1.8.0

type QueueConfig struct {
	// Number of samples to buffer per shard before we block. Defaults to
	// MaxSamplesPerSend.
	Capacity int `yaml:"capacity,omitempty"`

	// Max number of shards, i.e. amount of concurrency.
	MaxShards int `yaml:"max_shards,omitempty"`

	// Min number of shards, i.e. amount of concurrency.
	MinShards int `yaml:"min_shards,omitempty"`

	// Maximum number of samples per send.
	MaxSamplesPerSend int `yaml:"max_samples_per_send,omitempty"`

	// Maximum time sample will wait in buffer.
	BatchSendDeadline model.Duration `yaml:"batch_send_deadline,omitempty"`

	// On recoverable errors, backoff exponentially.
	MinBackoff       model.Duration `yaml:"min_backoff,omitempty"`
	MaxBackoff       model.Duration `yaml:"max_backoff,omitempty"`
	RetryOnRateLimit bool           `yaml:"retry_on_http_429,omitempty"`
}

QueueConfig is the configuration for the queue used to write to remote storage.

type RemoteReadConfig added in v1.6.0

type RemoteReadConfig struct {
	URL           *config.URL       `yaml:"url"`
	RemoteTimeout model.Duration    `yaml:"remote_timeout,omitempty"`
	Headers       map[string]string `yaml:"headers,omitempty"`
	ReadRecent    bool              `yaml:"read_recent,omitempty"`
	Name          string            `yaml:"name,omitempty"`

	// We cannot do proper Go type embedding below as the parser will then parse
	// values arbitrarily into the overflow maps of further-down types.
	HTTPClientConfig config.HTTPClientConfig `yaml:",inline"`

	// RequiredMatchers is an optional list of equality matchers which have to
	// be present in a selector to query the remote read endpoint.
	RequiredMatchers model.LabelSet `yaml:"required_matchers,omitempty"`
}

RemoteReadConfig is the configuration for reading from remote storage.

func (*RemoteReadConfig) SetDirectory added in v1.29.3

func (c *RemoteReadConfig) SetDirectory(dir string)

SetDirectory joins any relative file paths with dir.

func (*RemoteReadConfig) UnmarshalYAML added in v1.6.0

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

UnmarshalYAML implements the yaml.Unmarshaler interface.

type RemoteWriteConfig added in v1.2.0

type RemoteWriteConfig struct {
	URL                 *config.URL       `yaml:"url"`
	RemoteTimeout       model.Duration    `yaml:"remote_timeout,omitempty"`
	Headers             map[string]string `yaml:"headers,omitempty"`
	WriteRelabelConfigs []*relabel.Config `yaml:"write_relabel_configs,omitempty"`
	Name                string            `yaml:"name,omitempty"`
	SendExemplars       bool              `yaml:"send_exemplars,omitempty"`

	// We cannot do proper Go type embedding below as the parser will then parse
	// values arbitrarily into the overflow maps of further-down types.
	HTTPClientConfig config.HTTPClientConfig `yaml:",inline"`
	QueueConfig      QueueConfig             `yaml:"queue_config,omitempty"`
	MetadataConfig   MetadataConfig          `yaml:"metadata_config,omitempty"`
	SigV4Config      *SigV4Config            `yaml:"sigv4,omitempty"`
}

RemoteWriteConfig is the configuration for writing to remote storage.

func (*RemoteWriteConfig) SetDirectory added in v1.29.3

func (c *RemoteWriteConfig) SetDirectory(dir string)

SetDirectory joins any relative file paths with dir.

func (*RemoteWriteConfig) UnmarshalYAML added in v1.2.0

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

UnmarshalYAML implements the yaml.Unmarshaler interface.

type ScrapeConfig

type ScrapeConfig struct {
	// The job name to which the job label is set by default.
	JobName string `yaml:"job_name"`
	// Indicator whether the scraped metrics should remain unmodified.
	HonorLabels bool `yaml:"honor_labels,omitempty"`
	// Indicator whether the scraped timestamps should be respected.
	HonorTimestamps bool `yaml:"honor_timestamps"`
	// A set of query parameters with which the target is scraped.
	Params url.Values `yaml:"params,omitempty"`
	// How frequently to scrape the targets of this scrape config.
	ScrapeInterval model.Duration `yaml:"scrape_interval,omitempty"`
	// The timeout for scraping targets of this config.
	ScrapeTimeout model.Duration `yaml:"scrape_timeout,omitempty"`
	// The HTTP resource path on which to fetch metrics from targets.
	MetricsPath string `yaml:"metrics_path,omitempty"`
	// The URL scheme with which to fetch metrics from targets.
	Scheme string `yaml:"scheme,omitempty"`
	// An uncompressed response body larger than this many bytes will cause the
	// scrape to fail. 0 means no limit.
	BodySizeLimit units.Base2Bytes `yaml:"body_size_limit,omitempty"`
	// More than this many samples post metric-relabeling will cause the scrape to
	// fail.
	SampleLimit uint `yaml:"sample_limit,omitempty"`
	// More than this many targets after the target relabeling will cause the
	// scrapes to fail.
	TargetLimit uint `yaml:"target_limit,omitempty"`
	// More than this many labels post metric-relabeling will cause the scrape to
	// fail.
	LabelLimit uint `yaml:"label_limit,omitempty"`
	// More than this label name length post metric-relabeling will cause the
	// scrape to fail.
	LabelNameLengthLimit uint `yaml:"label_name_length_limit,omitempty"`
	// More than this label value length post metric-relabeling will cause the
	// scrape to fail.
	LabelValueLengthLimit uint `yaml:"label_value_length_limit,omitempty"`

	ServiceDiscoveryConfigs discovery.Configs       `yaml:"-"`
	HTTPClientConfig        config.HTTPClientConfig `yaml:",inline"`

	// List of target relabel configurations.
	RelabelConfigs []*relabel.Config `yaml:"relabel_configs,omitempty"`
	// List of metric relabel configurations.
	MetricRelabelConfigs []*relabel.Config `yaml:"metric_relabel_configs,omitempty"`
}

ScrapeConfig configures a scraping unit for Prometheus.

func (*ScrapeConfig) MarshalYAML added in v1.29.3

func (c *ScrapeConfig) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface.

func (*ScrapeConfig) SetDirectory added in v1.29.3

func (c *ScrapeConfig) SetDirectory(dir string)

SetDirectory joins any relative file paths with dir.

func (*ScrapeConfig) UnmarshalYAML

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

UnmarshalYAML implements the yaml.Unmarshaler interface.

type SigV4Config added in v1.29.3

type SigV4Config struct {
	Region    string        `yaml:"region,omitempty"`
	AccessKey string        `yaml:"access_key,omitempty"`
	SecretKey config.Secret `yaml:"secret_key,omitempty"`
	Profile   string        `yaml:"profile,omitempty"`
	RoleARN   string        `yaml:"role_arn,omitempty"`
}

SigV4Config is the configuration for signing remote write requests with AWS's SigV4 verification process. Empty values will be retrieved using the AWS default credentials chain.

type StorageConfig added in v1.29.3

type StorageConfig struct {
	ExemplarsConfig *ExemplarsConfig `yaml:"exemplars,omitempty"`
}

StorageConfig configures runtime reloadable configuration options.

Jump to

Keyboard shortcuts

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