Documentation ¶
Index ¶
- Variables
- func MarshalYAML(v interface{}) (interface{}, error)
- func RegisterIntegration(cfg Config)
- func UnmarshalYAML(out interface{}, unmarshal func(interface{}) error) error
- type CollectorIntegration
- type CollectorIntegrationConfig
- type Config
- type Configs
- type Integration
- type Manager
- type ManagerConfig
- func (c *ManagerConfig) ApplyDefaults(scfg *server.Config, mcfg *metrics.Config) error
- func (c *ManagerConfig) DefaultRelabelConfigs(instanceKey string) []*relabel.Config
- func (c ManagerConfig) MarshalYAML() (interface{}, error)
- func (c *ManagerConfig) UnmarshalYAML(unmarshal func(interface{}) error) error
- type StubIntegration
- type UnmarshaledConfig
Constants ¶
This section is empty.
Variables ¶
var DefaultManagerConfig = ManagerConfig{ ScrapeIntegrations: true, IntegrationRestartBackoff: 5 * time.Second, UseHostnameLabel: true, ReplaceInstanceLabel: true, }
DefaultManagerConfig holds the default settings for integrations.
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
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) MetricsHandler ¶ added in v0.14.0
func (i *CollectorIntegration) MetricsHandler() (http.Handler, error)
MetricsHandler returns the HTTP handler for the integration.
func (*CollectorIntegration) Run ¶ added in v0.10.0
func (i *CollectorIntegration) Run(ctx context.Context) error
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
WithCollectors 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 // InstanceKey should return the key the reprsents the config, which will be // used to populate the value of the `instance` label for metrics. // // InstanceKey is given an agentKey that represents the agent process. This // may be used if the integration being configured applies to an entire // machine. // // This method may not be invoked if the instance key for a Config is // overridden. InstanceKey(agentKey string) (string, error) // 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.
func RegisteredIntegrations ¶ added in v0.22.0
func RegisteredIntegrations() []Config
RegisteredIntegrations all Configs that were passed to RegisterIntegration. Each call will generate a new set of pointers.
type Configs ¶ added in v0.10.0
type Configs []UnmarshaledConfig
Configs is a list of UnmarshaledConfig. Configs for integrations which are unmarshaled from YAML are combined with common settings.
type Integration ¶
type Integration interface { // MetricsHandler returns an http.Handler that will return metrics. MetricsHandler() (http.Handler, 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. // // An error will be returned if the integration failed. Integrations should // not return the ctx error. Run(ctx context.Context) error }
An Integration is a process that integrates with some external system and pulls telemetry data.
func NewHandlerIntegration ¶ added in v0.20.0
func NewHandlerIntegration(name string, handler http.Handler) Integration
NewHandlerIntegration creates a new named integration that will call handler when metrics are needed.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages a set of integrations and runs them.
func NewManager ¶
func NewManager(cfg ManagerConfig, logger log.Logger, im instance.Manager, validate configstore.Validator) (*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) ApplyConfig ¶ added in v0.14.0
func (m *Manager) ApplyConfig(cfg ManagerConfig) error
ApplyConfig updates the configuration of the integrations subsystem.
type ManagerConfig ¶ added in v0.10.0
type ManagerConfig struct { // When true, scrapes metrics from integrations. ScrapeIntegrations bool `yaml:"scrape_integrations,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 []*promConfig.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,omitempty"` // This is set to true if the Server TLSConfig Cert and Key path are set ServerUsingTLS bool `yaml:"-"` // We use this config to check if we need to reload integrations or not // The Integrations Configs don't have prometheus defaults applied which // can cause us skip reload when scrape configs change PrometheusGlobalConfig promConfig.GlobalConfig `yaml:"-"` ReplaceInstanceLabel bool `yaml:"replace_instance_label,omitempty"` // DEPRECATED, unused UseHostnameLabel bool `yaml:"use_hostname_label,omitempty"` // DEPRECATED, unused }
ManagerConfig holds the configuration for all integrations.
func (*ManagerConfig) ApplyDefaults ¶ added in v0.14.0
ApplyDefaults applies default settings to the ManagerConfig and validates that it can be used.
If any integrations are enabled and are configured to be scraped, the Prometheus configuration must have a WAL directory configured.
func (*ManagerConfig) DefaultRelabelConfigs ¶ added in v0.10.0
func (c *ManagerConfig) DefaultRelabelConfigs(instanceKey string) []*relabel.Config
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.
type StubIntegration ¶ added in v0.22.0
type StubIntegration struct{}
StubIntegration implements a no-op integration for use on platforms not supported by an integration
func (*StubIntegration) MetricsHandler ¶ added in v0.22.0
func (i *StubIntegration) MetricsHandler() (http.Handler, error)
MetricsHandler returns an http.NotFoundHandler to satisfy the Integration interface
func (*StubIntegration) Run ¶ added in v0.22.0
func (i *StubIntegration) Run(ctx context.Context) error
Run just waits for the context to finish
func (*StubIntegration) ScrapeConfigs ¶ added in v0.22.0
func (i *StubIntegration) ScrapeConfigs() []config.ScrapeConfig
ScrapeConfigs returns an empty list of scrape configs, since there is nothing to scrape
type UnmarshaledConfig ¶ added in v0.22.0
UnmarshaledConfig combines an integration's config with common settings.
Source Files ¶
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 - replaced for github.com/prometheus-community/elasticsearch_exporter Using the YAML config provided by the agent
|
Package elasticsearch_exporter instantiates the exporter from github.com/justwatchcom/elasticsearch_exporter - replaced for github.com/prometheus-community/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 |
Package integrations provides a way to run and manage Grafana Agent "integrations," which integrate some external system (such as MySQL) to Grafana Agent's existing metrics, logging, and tracing subsystems.
|
Package integrations provides a way to run and manage Grafana Agent "integrations," which integrate some external system (such as MySQL) to Grafana Agent's existing metrics, logging, and tracing subsystems. |
agent
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. |
autoscrape
Package autoscrape implements a scraper for integrations.
|
Package autoscrape implements a scraper for integrations. |
eventhandler
Package eventhandler watches for Kubernetes Event objects and hands them off to Agent's Logs subsystem (embedded promtail)
|
Package eventhandler watches for Kubernetes Event objects and hands them off to Agent's Logs subsystem (embedded promtail) |