Documentation
¶
Index ¶
- func MarshalYAML(v interface{}) (interface{}, error)
- func NewLogger(logger log.Logger, opts ...Option) *logrus.Logger
- func RegisterIntegration(cfg Config)
- func UnmarshalYAML(out interface{}, unmarshal func(interface{}) error) error
- type CollectorIntegration
- type CollectorIntegrationConfig
- type Config
- type Configs
- type Integration
- type ManagerConfig
- func (c *ManagerConfig) ApplyDefaults(sflags *server.Flags, 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 Option
- type UnmarshaledConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalYAML ¶
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 ¶
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 ¶
UnmarshalYAML helps implement yaml.Unmarshaller for structs that have a Configs field that should be inlined in the YAML string.
Types ¶
type CollectorIntegration ¶
type CollectorIntegration struct {
// contains filtered or unexported fields
}
CollectorIntegration is an integration exposing metrics from one or more Prometheus collectors.
func NewCollectorIntegration ¶
func NewCollectorIntegration(name string, configs ...CollectorIntegrationConfig) *CollectorIntegration
NewCollectorIntegration creates a basic integration that exposes metrics from multiple prometheus.Collector.
func (*CollectorIntegration) MetricsHandler ¶
func (i *CollectorIntegration) MetricsHandler() (http.Handler, error)
MetricsHandler returns the HTTP handler for the integration.
func (*CollectorIntegration) Run ¶
func (i *CollectorIntegration) Run(ctx context.Context) error
Run satisfies Integration.Run.
func (*CollectorIntegration) ScrapeConfigs ¶
func (i *CollectorIntegration) ScrapeConfigs() []config.ScrapeConfig
ScrapeConfigs satisfies Integration.ScrapeConfigs.
type CollectorIntegrationConfig ¶
type CollectorIntegrationConfig func(integration *CollectorIntegration)
CollectorIntegrationConfig defines constructor configuration for NewCollectorIntegration
func WithCollectors ¶
func WithCollectors(cs ...prometheus.Collector) CollectorIntegrationConfig
WithCollectors adds more collectors to the CollectorIntegration being created.
func WithExporterMetricsIncluded ¶
func WithExporterMetricsIncluded(included bool) CollectorIntegrationConfig
WithExporterMetricsIncluded can enable the exporter metrics if the flag provided is enabled.
func WithRunner ¶
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 that represents 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 ¶
func RegisteredIntegrations() []Config
RegisteredIntegrations all Configs that were passed to RegisterIntegration. Each call will generate a new set of pointers.
type Configs ¶
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 ¶
func NewHandlerIntegration(name string, handler http.Handler) Integration
NewHandlerIntegration creates a new named integration that will call handler when metrics are needed.
func NewIntegrationWithInstanceKey ¶
func NewIntegrationWithInstanceKey(l log.Logger, cfg Config, key string) (Integration, string, error)
NewIntegrationWithInstanceKey uses cfg to construct an integration and return it along its instance key.
type ManagerConfig ¶
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.
var CurrentManagerConfig ManagerConfig = DefaultManagerConfig()
func DefaultManagerConfig ¶
func DefaultManagerConfig() ManagerConfig
DefaultManagerConfig holds the default settings for integrations.
func (*ManagerConfig) ApplyDefaults ¶
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 ¶
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 ¶
func (c ManagerConfig) MarshalYAML() (interface{}, error)
MarshalYAML implements yaml.Marshaler for ManagerConfig.
func (*ManagerConfig) UnmarshalYAML ¶
func (c *ManagerConfig) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements yaml.Unmarshaler for ManagerConfig.
type Option ¶
type Option func(*output)
Option Exposes logging options
func WithTimestampFromLogrus ¶
func WithTimestampFromLogrus() Option
WithTimestampFromLogrus sets tsFromLogrus logging option
type UnmarshaledConfig ¶
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 apache_http embeds https://github.com/Lusitaniae/apache_exporter
|
Package apache_http embeds https://github.com/Lusitaniae/apache_exporter |
|
docs
command
|
|
|
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 redis_exporter embeds https://github.com/oliver006/redis_exporter
|
Package redis_exporter embeds https://github.com/oliver006/redis_exporter |
|
Package snmp_exporter embeds https://github.com/prometheus/snmp_exporter
|
Package snmp_exporter embeds https://github.com/prometheus/snmp_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. |
|
apache_http
Package apache_http embeds https://github.com/Lusitaniae/apache_exporter
|
Package apache_http embeds https://github.com/Lusitaniae/apache_exporter |
|
autoscrape
Package autoscrape implements a scraper for integrations.
|
Package autoscrape implements a scraper for integrations. |
|
snmp_exporter
Package snmp_exporter embeds https://github.com/prometheus/snmp_exporter
|
Package snmp_exporter embeds https://github.com/prometheus/snmp_exporter |