servergroup

package
v0.0.31 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2018 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultConfig = Config{
		HTTPConfig: HTTPClientConfig{
			DialTimeout: time.Millisecond * 2000,
		},
	}
)

Functions

func FilterMatchers added in v0.0.29

func FilterMatchers(ls model.LabelSet, matchers []*labels.Matcher) ([]*labels.Matcher, bool)

Types

type Config

type Config struct {
	// RemoteRead directs promxy to load data (from the storage API) through the
	// remoteread API on prom.
	// Pros:
	//  - StaleNaNs work
	//  - ~2x faster (in my local testing, more so if you are using default JSON marshaler in prom)
	//
	// Cons:
	//  - proto marshaling prom side doesn't stream, so the data being sent
	//      over the wire will be 2x its size in memory on the remote prom host.
	//  - "experimental" API (according to docs) -- meaning this might break
	//      without much (if any) warning
	//
	// Upstream prom added a StaleNan to determine if a given timeseries has gone
	// NaN -- the problem being that for range vectors they filter out all "stale" samples
	// meaning that it isn't possible to get a "raw" dump of data through the query/query_range v1 API
	// The only option that exists in reality is the "remote read" API -- which suffers
	// from the same memory-balooning problems that the HTTP+JSON API originally had.
	// It has **less** of a problem (its 2x memory instead of 14x) so it is a viable option.
	RemoteRead bool `yaml:"remote_read"`
	// HTTP client config for promxy to use when connecting to the various server_groups
	// this is the same config as prometheus
	HTTPConfig HTTPClientConfig `yaml:"http_client"`
	// Scheme defines how promxy talks to this server group (http, https, etc.)
	Scheme string `yaml:"scheme"`
	// Labels is a set of labels that will be added to all metrics retrieved
	// from this server group
	Labels model.LabelSet `json:"labels"`
	// RelabelConfigs is identical in function and configuration as prometheus'
	// relabel config for scrape jobs
	RelabelConfigs []*config.RelabelConfig `yaml:"relabel_configs,omitempty"`
	// Hosts is a set of ServiceDiscoveryConfig options that allow promxy to discover
	// all hosts in the server_group
	Hosts sd_config.ServiceDiscoveryConfig `yaml:",inline"`
	// PathPrefix to prepend to all queries to hosts in this servergroup
	PathPrefix string `yaml:"path_prefix"`
	// TODO cache this as a model.Time after unmarshal
	// AntiAffinity defines how large of a gap in the timeseries will cause promxy
	// to merge series from 2 hosts in a server_group. This required for a couple reasons
	// (1) Promxy cannot make assumptions on downstream clock-drift and
	// (2) two prometheus hosts scraping the same target may have different times
	// #2 is caused by prometheus storing the time of the scrape as the time the scrape **starts**.
	// in practice this is actually quite frequent as there are a variety of situations that
	// cause variable scrape completion time (slow exporter, serial exporter, network latency, etc.)
	// any one of these can cause the resulting data in prometheus to have the same time but in reality
	// come from different points in time. Best practice for this value is to set it to your scrape interval
	AntiAffinity *time.Duration `yaml:"anti_affinity,omitempty"`
}

Config is the configuration for a ServerGroup that promxy will talk to. This is where the vast majority of options exist.

func (*Config) GetAntiAffinity

func (c *Config) GetAntiAffinity() model.Time

func (*Config) GetScheme

func (c *Config) GetScheme() string

func (*Config) UnmarshalYAML added in v0.0.31

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

UnmarshalYAML implements the yaml.Unmarshaler interface.

type HTTPClientConfig added in v0.0.31

type HTTPClientConfig struct {
	DialTimeout time.Duration                `yaml:"dial_timeout"`
	HTTPConfig  config_util.HTTPClientConfig `yaml:",inline"`
}

type LabelFilterVisitor added in v0.0.9

type LabelFilterVisitor struct {
	// contains filtered or unexported fields
}

func (*LabelFilterVisitor) Visit added in v0.0.9

func (l *LabelFilterVisitor) Visit(node promql.Node, path []promql.Node) (w promql.Visitor, err error)

type ServerGroup

type ServerGroup struct {
	Ready chan struct{}

	// TODO: lock/atomics on cfg and client
	Cfg    *Config
	Client *http.Client

	OriginalURLs []string
	// contains filtered or unexported fields
}

func New

func New() *ServerGroup

func (*ServerGroup) ApplyConfig

func (s *ServerGroup) ApplyConfig(cfg *Config) error

TODO: move config + client into state object to be swapped with atomics

func (*ServerGroup) Cancel

func (s *ServerGroup) Cancel()

func (*ServerGroup) GetValue added in v0.0.2

func (s *ServerGroup) GetValue(ctx context.Context, start, end time.Time, matchers []*labels.Matcher) (model.Value, error)

func (*ServerGroup) LabelValues added in v0.0.31

func (s *ServerGroup) LabelValues(ctx context.Context, label string) (model.LabelValues, error)

LabelValues performs a query for the values of the given label.

func (*ServerGroup) Query added in v0.0.31

func (s *ServerGroup) Query(ctx context.Context, query string, ts time.Time) (model.Value, error)

Query performs a query for the given time.

func (*ServerGroup) QueryRange added in v0.0.31

func (s *ServerGroup) QueryRange(ctx context.Context, query string, r v1.Range) (model.Value, error)

QueryRange performs a query for the given range.

func (*ServerGroup) RemoteRead added in v0.0.2

func (s *ServerGroup) RemoteRead(ctx context.Context, start, end time.Time, matchers []*labels.Matcher) (model.Value, error)

func (*ServerGroup) Series added in v0.0.31

func (s *ServerGroup) Series(ctx context.Context, matches []string, startTime, endTime time.Time) ([]model.LabelSet, error)

Series finds series by label matchers.

func (*ServerGroup) State added in v0.0.29

func (s *ServerGroup) State() *ServerGroupState

func (*ServerGroup) Sync

func (s *ServerGroup) Sync()

type ServerGroupState added in v0.0.29

type ServerGroupState struct {
	// Targets is the list of target URLs for this discovery round
	Targets []string

	// Labels that should be applied to metrics from this serverGroup
	Labels model.LabelSet
	// contains filtered or unexported fields
}

Encapsulate the state of a serverGroup from service discovery

type ServerGroups

type ServerGroups []*ServerGroup

func (ServerGroups) GetValue added in v0.0.2

func (s ServerGroups) GetValue(ctx context.Context, start, end time.Time, matchers []*labels.Matcher) (model.Value, error)

GetValue fetches a `model.Value` from the servergroups

func (ServerGroups) LabelValues added in v0.0.31

func (s ServerGroups) LabelValues(ctx context.Context, label string) (model.LabelValues, error)

func (ServerGroups) Query added in v0.0.31

func (s ServerGroups) Query(ctx context.Context, query string, ts time.Time) (model.Value, error)

Query performs a query for the given time.

func (ServerGroups) QueryRange added in v0.0.31

func (s ServerGroups) QueryRange(ctx context.Context, query string, r v1.Range) (model.Value, error)

QueryRange performs a query for the given range.

func (ServerGroups) Series added in v0.0.31

func (s ServerGroups) Series(ctx context.Context, matches []string, startTime, endTime time.Time) ([]model.LabelSet, error)

Series finds series by label matchers.

Jump to

Keyboard shortcuts

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