Skip to content
This repository was archived by the owner on Jul 28, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions pkg/integrations/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,13 @@ import (
)

// Config controls the Agent integration.
type Config struct {
Common config.Common `yaml:",inline"`
}
type Config struct{}

// Name returns the name of the integration that this config represents.
func (c *Config) Name() string {
return "agent"
}

// CommonConfig returns the common settings shared across all integrations.
func (c *Config) CommonConfig() config.Common {
return c.Common
}

// InstanceKey returns the hostname of the machine.
func (c *Config) InstanceKey(agentKey string) (string, error) {
return agentKey, nil
Expand Down
9 changes: 0 additions & 9 deletions pkg/integrations/cadvisor/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"time"

"github.com/grafana/agent/pkg/integrations"
"github.com/grafana/agent/pkg/integrations/config"
)

const name = "cadvisor"
Expand Down Expand Up @@ -34,8 +33,6 @@ var DefaultConfig Config = Config{

// Config controls cadvisor
type Config struct {
Common config.Common `yaml:",inline"`

// Common cadvisor config options
// StoreContainerLabels converts container labels and environment variables into labels on prometheus metrics for each container. If false, then only metrics exported are container name, first alias, and image name.
StoreContainerLabels bool `yaml:"store_container_labels,omitempty"`
Expand Down Expand Up @@ -106,12 +103,6 @@ func (c *Config) Name() string {
return name
}

// CommonConfig returns the common settings shared across all configs for
// integrations.
func (c *Config) CommonConfig() config.Common {
return c.Common
}

// InstanceKey returns the agentKey
func (c *Config) InstanceKey(agentKey string) (string, error) {
return agentKey, nil
Expand Down
8 changes: 0 additions & 8 deletions pkg/integrations/consul_exporter/consul_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"github.com/go-kit/log"
"github.com/grafana/agent/pkg/integrations"
"github.com/grafana/agent/pkg/integrations/config"
consul_api "github.com/hashicorp/consul/api"
"github.com/prometheus/consul_exporter/pkg/exporter"
)
Expand All @@ -24,8 +23,6 @@ var DefaultConfig = Config{

// Config controls the consul_exporter integration.
type Config struct {
Common config.Common `yaml:",inline"`

Server string `yaml:"server,omitempty"`
CAFile string `yaml:"ca_file,omitempty"`
CertFile string `yaml:"cert_file,omitempty"`
Expand Down Expand Up @@ -55,11 +52,6 @@ func (c *Config) Name() string {
return "consul_exporter"
}

// CommonConfig returns the common set of settings for this integration.
func (c *Config) CommonConfig() config.Common {
return c.Common
}

// InstanceKey returns the hostname:port of the Consul server.
func (c *Config) InstanceKey(agentKey string) (string, error) {
u, err := url.Parse(c.Server)
Expand Down
8 changes: 0 additions & 8 deletions pkg/integrations/dnsmasq_exporter/dnsmasq_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"github.com/go-kit/log"
"github.com/google/dnsmasq_exporter/collector"
"github.com/grafana/agent/pkg/integrations"
"github.com/grafana/agent/pkg/integrations/config"
"github.com/miekg/dns"
)

Expand All @@ -17,8 +16,6 @@ var DefaultConfig Config = Config{

// Config controls the dnsmasq_exporter integration.
type Config struct {
Common config.Common `yaml:",inline"`

// DnsmasqAddress is the address of the dnsmasq server (host:port).
DnsmasqAddress string `yaml:"dnsmasq_address,omitempty"`

Expand All @@ -31,11 +28,6 @@ func (c *Config) Name() string {
return "dnsmasq_exporter"
}

// CommonConfig returns the set of common settings shared across all integrations.
func (c *Config) CommonConfig() config.Common {
return c.Common
}

// InstanceKey returns the address of the dnsmasq server.
func (c *Config) InstanceKey(agentKey string) (string, error) {
return c.DnsmasqAddress, nil
Expand Down
11 changes: 0 additions & 11 deletions pkg/integrations/elasticsearch_exporter/elasticsearch_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/grafana/agent/pkg/integrations"
"github.com/grafana/agent/pkg/integrations/config"
"github.com/prometheus/client_golang/prometheus"

"github.com/prometheus-community/elasticsearch_exporter/collector"
Expand All @@ -30,10 +29,6 @@ var DefaultConfig = Config{

// Config controls the elasticsearch_exporter integration.
type Config struct {
Common config.Common `yaml:",inline"`

// Exporter configuration

// HTTP API address of an Elasticsearch node.
Address string `yaml:"address,omitempty"`
// Timeout for trying to get stats from Elasticsearch.
Expand Down Expand Up @@ -77,12 +72,6 @@ func (c *Config) Name() string {
return "elasticsearch_exporter"
}

// CommonConfig returns the common settings shared across all configs for
// integrations.
func (c *Config) CommonConfig() config.Common {
return c.Common
}

// InstanceKey returns the hostname:port of the elasticsearch node being queried.
func (c *Config) InstanceKey(agentKey string) (string, error) {
u, err := url.Parse(c.Address)
Expand Down
9 changes: 0 additions & 9 deletions pkg/integrations/github_exporter/github_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/grafana/agent/pkg/integrations"
"github.com/grafana/agent/pkg/integrations/config"
gh_config "github.com/infinityworks/github-exporter/config"
"github.com/infinityworks/github-exporter/exporter"
config_util "github.com/prometheus/common/config"
Expand All @@ -20,8 +19,6 @@ var DefaultConfig Config = Config{

// Config controls github_exporter
type Config struct {
Common config.Common `yaml:",inline"`

// URL for the github API
APIURL string `yaml:"api_url,omitempty"`

Expand Down Expand Up @@ -54,12 +51,6 @@ func (c *Config) Name() string {
return "github_exporter"
}

// CommonConfig returns the common settings shared across all configs for
// integrations.
func (c *Config) CommonConfig() config.Common {
return c.Common
}

// InstanceKey returns the hostname:port of the GitHub API server.
func (c *Config) InstanceKey(agentKey string) (string, error) {
u, err := url.Parse(c.APIURL)
Expand Down
8 changes: 2 additions & 6 deletions pkg/integrations/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,15 @@ type Config interface {
// 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

// 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 is only used if the common config does not have an override for
// InstanceKey.
// 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.
Expand Down
9 changes: 0 additions & 9 deletions pkg/integrations/kafka_exporter/kafka_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
kafka_exporter "github.com/davidmparrott/kafka_exporter/v2/exporter"
"github.com/go-kit/log"
"github.com/grafana/agent/pkg/integrations"
"github.com/grafana/agent/pkg/integrations/config"
)

// DefaultConfig holds the default settings for the kafka_lag_exporter
Expand All @@ -27,8 +26,6 @@ var DefaultConfig = Config{

// Config controls kafka_exporter
type Config struct {
Common config.Common `yaml:",inline"`

// Address array (host:port) of Kafka server
KafkaURIs []string `yaml:"kafka_uris,omitempty"`

Expand Down Expand Up @@ -106,12 +103,6 @@ func (c *Config) Name() string {
return "kafka_exporter"
}

// CommonConfig returns the common settings shared across all configs for
// integrations.
func (c *Config) CommonConfig() config.Common {
return c.Common
}

// InstanceKey returns the hostname:port of the first Kafka node, if any. If
// there is not exactly one Kafka node, the user must manually provide
// their own value for instance key in the common config.
Expand Down
16 changes: 8 additions & 8 deletions pkg/integrations/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ func (c *ManagerConfig) DefaultRelabelConfigs(instanceKey string) []*relabel.Con
// Prometheus configuration must have a WAL directory configured.
func (c *ManagerConfig) ApplyDefaults(cfg *metrics.Config) error {
for _, ic := range c.Integrations {
if !ic.CommonConfig().Enabled {
if !ic.Common.Enabled {
continue
}

scrapeIntegration := c.ScrapeIntegrations
if common := ic.CommonConfig(); common.ScrapeIntegration != nil {
if common := ic.Common; common.ScrapeIntegration != nil {
scrapeIntegration = *common.ScrapeIntegration
}

Expand Down Expand Up @@ -213,7 +213,7 @@ func (m *Manager) ApplyConfig(cfg ManagerConfig) error {
// Iterate over our integrations. New or changed integrations will be
// started, with their existing counterparts being shut down.
for _, ic := range cfg.Integrations {
if !ic.CommonConfig().Enabled {
if !ic.Common.Enabled {
continue
}
// Key is used to identify the instance of this integration within the
Expand Down Expand Up @@ -245,7 +245,7 @@ func (m *Manager) ApplyConfig(cfg ManagerConfig) error {

// Find what instance label should be used to represent this integration.
var instanceKey string
if kp := ic.CommonConfig().InstanceKey; kp != nil {
if kp := ic.Common.InstanceKey; kp != nil {
// Common config takes precedence.
instanceKey = strings.TrimSpace(*kp)
} else {
Expand Down Expand Up @@ -286,7 +286,7 @@ func (m *Manager) ApplyConfig(cfg ManagerConfig) error {
for _, ic := range cfg.Integrations {
if integrationKey(ic.Name()) == key {
// If this is disabled then we should delete from integrations
if !ic.CommonConfig().Enabled {
if !ic.Common.Enabled {
break
}
foundConfig = true
Expand All @@ -307,7 +307,7 @@ func (m *Manager) ApplyConfig(cfg ManagerConfig) error {
// if the configs for the integration didn't.
for key, p := range m.integrations {
shouldCollect := cfg.ScrapeIntegrations
if common := p.cfg.CommonConfig(); common.ScrapeIntegration != nil {
if common := p.cfg.Common; common.ScrapeIntegration != nil {
shouldCollect = *common.ScrapeIntegration
}

Expand Down Expand Up @@ -345,7 +345,7 @@ type integrationProcess struct {
log log.Logger
ctx context.Context
stop context.CancelFunc
cfg Config
cfg UnmarshaledConfig
instanceKey string // Value for the `instance` label
i Integration

Expand Down Expand Up @@ -386,7 +386,7 @@ func (m *Manager) instanceBackoff(cfg Config, err error) {
}

func (m *Manager) instanceConfigForIntegration(p *integrationProcess, cfg ManagerConfig) instance.Config {
common := p.cfg.CommonConfig()
common := p.cfg.Common
relabelConfigs := append(cfg.DefaultRelabelConfigs(p.instanceKey), common.RelabelConfigs...)

schema := "http"
Expand Down
Loading