integrations

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultManagerConfig = ManagerConfig{
		ScrapeIntegrations:        true,
		IntegrationRestartBackoff: 5 * time.Second,
		UseHostnameLabel:          true,
		ReplaceInstanceLabel:      true,
	}
)

Functions

func MarshalYAML added in v0.10.0

func MarshalYAML(v interface{}) (interface{}, error)

MarshalYAML helps implement yaml.Marshaller for structs that have a Configs field that should be inlined in the YAML string.

func RegisterIntegration added in v0.10.0

func RegisterIntegration(cfg Config)

RegisterIntegration dynamically registers a new integration. The Config will represent the configuration that controls the specific integration. Registered Configs may be loaded using UnmarshalYAML or manually constructed.

RegisterIntegration panics if cfg is not a pointer.

func UnmarshalYAML added in v0.10.0

func UnmarshalYAML(out interface{}, unmarshal func(interface{}) error) error

UnmarshalYAML helps implement yaml.Unmarshaller for structs that have a Configs field that should be inlined in the YAML string.

Types

type CollectorIntegration added in v0.10.0

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

CollectorIntegration is an integration exposing metrics from one or more Prometheus collectors.

func NewCollectorIntegration added in v0.10.0

func NewCollectorIntegration(name string, configs ...CollectorIntegrationConfig) *CollectorIntegration

NewCollectorIntegration creates a basic integration that exposes metrics from multiple prometheus.Collector.

func (*CollectorIntegration) RegisterRoutes added in v0.10.0

func (i *CollectorIntegration) RegisterRoutes(r *mux.Router) error

RegisterRoutes satisfies Integration.RegisterRoutes. The mux.Router provided here is expected to be a subrouter, where all registered paths will be registered within that subroute.

func (*CollectorIntegration) Run added in v0.10.0

Run satisfies Integration.Run.

func (*CollectorIntegration) ScrapeConfigs added in v0.10.0

func (i *CollectorIntegration) ScrapeConfigs() []config.ScrapeConfig

ScrapeConfigs satisfies Integration.ScrapeConfigs.

type CollectorIntegrationConfig added in v0.12.0

type CollectorIntegrationConfig func(integration *CollectorIntegration)

CollectorIntegrationConfig defines constructor configuration for NewCollectorIntegration

func WithCollectors added in v0.12.0

func WithCollectors(cs ...prometheus.Collector) CollectorIntegrationConfig

WithCollector adds more collectors to the CollectorIntegration being created.

func WithExporterMetricsIncluded added in v0.12.0

func WithExporterMetricsIncluded(included bool) CollectorIntegrationConfig

WithExporterMetricsIncluded can enable the exporter metrics if the flag provided is enabled.

func WithRunner added in v0.12.0

func WithRunner(runner func(context.Context) error) CollectorIntegrationConfig

WithRunner replaces the runner of the CollectorIntegration. The runner function should run while the context provided is not done.

type Config

type Config interface {
	// Name returns the name of the integration and the key that will be used to
	// pull the configuration from the Agent config YAML.
	Name() string

	// CommonConfig returns the set of common configuration values present across
	// all integrations.
	CommonConfig() config.Common

	// NewIntegration returns an integration for the given with the given logger.
	NewIntegration(l log.Logger) (Integration, error)
}

Config provides the configuration and constructor for an integration.

type Configs added in v0.10.0

type Configs []Config

Configs is a list of integrations.

func (*Configs) UnmarshalYAML added in v0.10.0

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

type Integration

type Integration interface {
	// RegisterRoutes should register any HTTP handlers needed for the
	// integrations. The mux router provided will be a subrouter for the path
	// /integrations/<integration name>, where the integration name is retrieved
	// by the config that created this integration.
	RegisterRoutes(r *mux.Router) error

	// ScrapeConfigs returns a set of scrape configs that determine where metrics
	// can be scraped.
	ScrapeConfigs() []config.ScrapeConfig

	// Run should start the integration and do any required tasks, if necessary.
	// For example, an Integration that requires a persistent connection to a
	// database would establish that connection here. If the integration doesn't
	// need to do anything, it should wait for the ctx to be canceled.
	Run(ctx context.Context) error
}

An Integration is a process that integrates with some external system and pulls telemetry data.

type Manager

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

Manager manages a set of integrations and runs them.

func NewManager

func NewManager(c ManagerConfig, logger log.Logger, im instance.Manager) (*Manager, error)

NewManager creates a new integrations manager. NewManager must be given an InstanceManager which is responsible for accepting instance configs to scrape and send metrics from running integrations.

func (*Manager) Stop

func (m *Manager) Stop()

Stop stops the manager and all of its integrations.

func (*Manager) WireAPI

func (m *Manager) WireAPI(r *mux.Router) error

type ManagerConfig added in v0.10.0

type ManagerConfig struct {
	// Whether the Integration subsystem should be enabled.
	Enabled bool `yaml:"-"`

	// When true, scrapes metrics from integrations.
	ScrapeIntegrations bool `yaml:"scrape_integrations,omitempty"`
	// When true, replaces the instance label with the agent hostname.
	ReplaceInstanceLabel bool `yaml:"replace_instance_label,omitempty"`

	// DEPRECATED. When true, adds an agent_hostname label to all samples from integrations.
	// ReplaceInstanceLabel should be used instead.
	UseHostnameLabel bool `yaml:"use_hostname_label,omitempty"`

	// The integration configs is merged with the manager config struct so we
	// don't want to export it here; we'll manually unmarshal it in UnmarshalYAML.
	Integrations Configs `yaml:"-"`

	// Extra labels to add for all integration samples
	Labels model.LabelSet `yaml:"labels,omitempty"`

	// Prometheus RW configs to use for all integrations.
	PrometheusRemoteWrite []*instance.RemoteWriteConfig `yaml:"prometheus_remote_write,omitempty"`

	IntegrationRestartBackoff time.Duration `yaml:"integration_restart_backoff,omitempty"`

	// ListenPort tells the integration Manager which port the Agent is
	// listening on for generating Prometheus instance configs.
	ListenPort *int `yaml:"-"`

	// ListenHost tells the integration Manager which port the Agent is
	// listening on for generating Prometheus instance configs
	ListenHost *string `yaml:"-"`

	TLSConfig config_util.TLSConfig `yaml:"http_tls_config"`

	// This is set to true if the Server TLSConfig Cert and Key path are set
	ServerUsingTLS bool `yaml:"-"`
}

ManagerConfig holds the configuration for all integrations.

func (*ManagerConfig) DefaultRelabelConfigs added in v0.10.0

func (c *ManagerConfig) DefaultRelabelConfigs() ([]*relabel.Config, error)

DefaultRelabelConfigs returns the set of relabel configs that should be prepended to all RelabelConfigs for an integration.

func (ManagerConfig) MarshalYAML added in v0.10.0

func (c ManagerConfig) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler for ManagerConfig.

func (*ManagerConfig) UnmarshalYAML added in v0.10.0

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

UnmarshalYAML implements yaml.Unmarshaler for ManagerConfig.

Directories

Path Synopsis
Package agent is an "example" integration that has very little functionality, but is still useful in practice.
Package agent is an "example" integration that has very little functionality, but is still useful in practice.
Package config provides common configuration structs shared among implementations of integrations.Integration.
Package config provides common configuration structs shared among implementations of integrations.Integration.
Package consul_exporter embeds https://github.com/prometheus/consul_exporter
Package consul_exporter embeds https://github.com/prometheus/consul_exporter
Package dnsmasq_exporter embeds https://github.com/google/dnsmasq_exporter
Package dnsmasq_exporter embeds https://github.com/google/dnsmasq_exporter
Package elasticsearch_exporter instantiates the exporter from github.com/justwatchcom/elasticsearch_exporter Using the YAML config provided by the agent
Package elasticsearch_exporter instantiates the exporter from github.com/justwatchcom/elasticsearch_exporter Using the YAML config provided by the agent
Package install registers all in-source integrations for use.
Package install registers all in-source integrations for use.
Package memcached_exporter embeds https://github.com/google/memcached_exporter
Package memcached_exporter embeds https://github.com/google/memcached_exporter
Package mysqld_exporter embeds https://github.com/prometheus/mysqld_exporter
Package mysqld_exporter embeds https://github.com/prometheus/mysqld_exporter
Package postgres_exporter embeds https://github.com/prometheus/postgres_exporter
Package postgres_exporter embeds https://github.com/prometheus/postgres_exporter
Package process_exporter embeds https://github.com/ncabatoff/process-exporter Package process_exporter embeds https://github.com/ncabatoff/process-exporter
Package process_exporter embeds https://github.com/ncabatoff/process-exporter Package process_exporter embeds https://github.com/ncabatoff/process-exporter
package redis_exporter embeds https://github.com/oliver006/redis_exporter
package redis_exporter embeds https://github.com/oliver006/redis_exporter
Package statsd_exporter embeds https://github.com/prometheus/statsd_exporter
Package statsd_exporter embeds https://github.com/prometheus/statsd_exporter

Jump to

Keyboard shortcuts

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