discovery

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrefixAnnotation = "wavefront.com/prefix"
	LabelsAnnotation = "wavefront.com/includeLabels"
)

Variables

This section is empty.

Functions

func ConvertPromToPlugin added in v1.0.0

func ConvertPromToPlugin(cfg *Config)

converts deprecated prometheus configs to plugin configs

func FakePod

func FakePod(name, namespace, ip string) *v1.Pod

func FakeService added in v0.9.4

func FakeService(name, namespace, ip string) *v1.Service

func NewFileListener added in v1.0.0

func NewFileListener(handler util.ConfigHandler) util.FileListener

func ResourceName added in v1.0.0

func ResourceName(kind string, meta metav1.ObjectMeta) string

Types

type CollectionConfig added in v1.0.0

type CollectionConfig struct {
	Interval time.Duration `yaml:"interval"`
	Timeout  time.Duration `yaml:"timeout"`
}

type Config

type Config struct {
	// frequency of evaluating discovery rules. Defaults to 5 minutes.
	// format is [0-9]+(ms|[smhdwy])
	DiscoveryInterval time.Duration `yaml:"discovery_interval"`

	// the annotation prefix for annotations based discovery
	// if specified, this substitutes the default prefix such as "prometheus.io" etc that is used during discovery
	AnnotationPrefix string `yaml:"annotation_prefix"`

	// AnnotationExcludes represents Selector rules for excluding kubernetes resources from annotation based discovery
	AnnotationExcludes []Selectors `yaml:"annotation_excludes"`

	// enables support for sourcing plugin configurations dynamically from configmaps
	// with the annotation "wavefront.com/discovery-config: 'true'". Defaults to false.
	EnableRuntimePlugins bool `yaml:"enable_runtime_plugins"`

	// disables annotation based discovery. Defaults to false.
	DisableAnnotationDiscovery bool `yaml:"disable_annotation_discovery"`

	// list of discovery rules
	PluginConfigs []PluginConfig `yaml:"plugins"`

	// Deprecated: ignored. Use top level configuration properties.
	Global GlobalConfig `yaml:"global"`

	// Deprecated: Use PluginConfigs instead.
	PromConfigs []PrometheusConfig `yaml:"prom_configs"`
}

configuration for auto discovery

func FromFile added in v1.0.0

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

func FromYAML added in v1.0.0

func FromYAML(contents []byte) (*Config, error)

FromYAML loads the configuration from a blob of YAML.

type Discoverer

type Discoverer interface {
	Discover(resource Resource)
	Delete(resource Resource)
	DeleteAll()
	Stop()
}

Discoverer discovers endpoints from resources based on rules or annotations

type Encoder added in v1.0.0

type Encoder interface {
	Encode(ip, kind string, meta metav1.ObjectMeta, rule interface{}) (string, interface{}, bool)
}

Encoder generates a configuration to collect data from a given resource based on the given rules

type Endpoint added in v1.1.0

type Endpoint struct {
	Name       string
	PluginType string
	Config     interface{}
}

Endpoint captures the data around a specific endpoint to collect data from

type EndpointHandler added in v1.1.0

type EndpointHandler interface {
	Add(ep *Endpoint)
	Delete(ep *Endpoint)
}

EndpointHandler handles the configuration of a source to collect data from discovered endpoints

func NewEndpointHandler added in v1.1.0

func NewEndpointHandler(providers map[string]ProviderInfo) EndpointHandler

type FakeDiscoverer added in v1.0.0

type FakeDiscoverer struct{}

func (*FakeDiscoverer) Delete added in v1.0.0

func (f *FakeDiscoverer) Delete(resource Resource)

func (*FakeDiscoverer) Discover added in v1.0.0

func (f *FakeDiscoverer) Discover(resource Resource)

type GlobalConfig

type GlobalConfig struct {
	// frequency of evaluating discovery rules. Defaults to 10 minutes.
	// format is [0-9]+(ms|[smhdwy])
	DiscoveryInterval time.Duration `yaml:"discovery_interval"`
}

Describes global rules that define the default discovery behavior Deprecated: This configuration is ignored and retained for backwards compatibility

type PluginConfig added in v1.0.0

type PluginConfig struct {
	// the unique name for this configuration rule. Used internally as map keys and needs to be unique per rule.
	Name string `yaml:"name"`

	// the plugin type, for example: 'prometheus' or 'telegraf/redis'
	Type string `yaml:"type"`

	// the selectors for identifying matching kubernetes resources
	Selectors Selectors `yaml:"selectors"`

	// the port to be monitored on the container
	Port string `yaml:"port"`

	// the scheme to use. Defaults to "http".
	Scheme string `yaml:"scheme"`

	// Optional. Defaults to "/metrics" for prometheus plugin type. Empty string for telegraf plugins.
	Path string `yaml:"path"`

	// configuration specific to the plugin.
	// For telegraf based plugins config is provided in toml format: https://github.com/toml-lang/toml
	// and parsed using https://github.com/influxdata/toml
	Conf string `yaml:"conf"`

	// Optional static source for metrics collected using this rule. Defaults to agent node name.
	Source string `yaml:"source"`

	// prefix for metrics collected using this rule. Defaults to empty string.
	Prefix string `yaml:"prefix"`

	// optional map of custom tags to include with the reported metrics
	Tags map[string]string `yaml:"tags"`

	// whether to include resource labels with the reported metrics. Defaults to "true".
	IncludeLabels string `yaml:"includeLabels"`

	Filters    filter.Config    `yaml:"filters"`
	Collection CollectionConfig `yaml:"collection"`

	// Internal: whether this plugin config was produced internally
	Internal bool `yaml:"-"`
}

Describes rules for auto discovering supported services

type PluginProvider added in v1.11.0

type PluginProvider interface {
	DiscoveryPluginConfigs() []PluginConfig
}

type PrometheusConfig deprecated

type PrometheusConfig struct {
	// name of the rule
	Name string `yaml:"name"`

	// the resource type to discover. defaults to pod.
	// one of "pod|service|apiserver".
	ResourceType string `yaml:"resourceType"`

	// map of labels to select resources by
	Labels map[string]string `yaml:"labels"`

	// the optional namespace to filter resources by.
	Namespace string `yaml:"namespace"`

	// the port to scrape for prometheus metrics. If omitted, defaults to a port-free target.
	Port string `yaml:"port"`

	// Optional. Defaults to "/metrics".
	Path string `yaml:"path"`

	// the scheme to use. Defaults to "http".
	Scheme string `yaml:"scheme"`

	// prefix for metrics collected using this rule. Defaults to empty string.
	Prefix string `yaml:"prefix"`

	// optional map of custom tags to include with the reported metrics.
	Tags map[string]string `yaml:"tags"`

	// optional source for metrics collected using this rule. Defaults to the name of the Kubernetes resource.
	Source string `yaml:"source"`

	// whether to include resource labels with the reported metrics. Defaults to "true".
	IncludeLabels string `yaml:"includeLabels"`

	Filters filter.Config `yaml:"filters"`
}

Deprecated: Use PluginConfig's instead.

type ProviderInfo added in v1.0.0

type ProviderInfo struct {
	Handler metrics.ProviderHandler
	Factory metrics.ProviderFactory
	Encoder Encoder
}

type Resource added in v1.0.0

type Resource struct {
	Kind   string
	IP     string
	Meta   metav1.ObjectMeta
	Status string

	// list of containers for a pod resource
	Containers []v1.Container
}

Resource encapsulates metadata about a Kubernetes resource

type ResourceLister added in v0.9.4

type ResourceLister interface {
	ListPods(ns string, labels map[string]string) ([]*v1.Pod, error)
	ListServices(ns string, labels map[string]string) ([]*v1.Service, error)
	ListNodes() ([]*v1.Node, error)
}

ResourceLister lists kubernetes resources based on custom criteria

type ResourceType added in v0.9.4

type ResourceType int
const (
	PodType     ResourceType = 1
	ServiceType ResourceType = 2
	NodeType    ResourceType = 3
)

func (ResourceType) String added in v0.9.4

func (resType ResourceType) String() string

type Selectors added in v1.0.0

type Selectors struct {
	// The resource type the rule applies to. One of <pod|service|node>. Defaults to pod.
	ResourceType string `yaml:"resourceType"`

	// the container images to match against specified as a list of glob pattern strings. Ex: 'redis*'
	Images []string `yaml:"images"`

	// map of labels to select resources by
	Labels map[string][]string `yaml:"labels"`

	// the optional namespaces to filter resources by.
	Namespaces []string `yaml:"namespaces"`
}

Describes selectors for identifying kubernetes resources

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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