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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ this platform. FreeBSD builds will return in a future release.

- [ENHANCEMENT] agentctl will now be installed by the rpm and deb packages as
`grafana-agentctl`. (@rfratto)

- [BUGFIX] Integrations will now function if the HTTP listen address was set to a value other than the default.
[206](https://github.com/grafana/agent/issues/206) (@mattdurham)

# v0.9.0 (2020-12-10)

Expand Down
4 changes: 3 additions & 1 deletion pkg/client/grafanacloud/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ func TestClient_AgentConfig(t *testing.T) {
"status": "success",
"data": {
"server": {
"http_listen_port": 12345
"http_listen_port": 12345,
"http_listen_address" : "127.0.0.1"
},
"integrations": {
"agent": {
Expand All @@ -47,6 +48,7 @@ func TestClient_AgentConfig(t *testing.T) {
expect := `
server:
http_listen_port: 12345
http_listen_address: 127.0.0.1
integrations:
agent:
enabled: true
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (c *Config) ApplyDefaults() error {

if c.Integrations.Enabled {
c.Integrations.ListenPort = &c.Server.HTTPListenPort
c.Integrations.ListenHost = &c.Server.HTTPListenAddress
}

return nil
Expand Down
6 changes: 5 additions & 1 deletion pkg/integrations/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ type ManagerConfig struct {
// 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:"-"`
}

// MarshalYAML implements yaml.Marshaler for ManagerConfig.
Expand Down Expand Up @@ -252,8 +256,8 @@ func (m *Manager) instanceConfigForIntegration(cfg Config, i Integration) instan
}

func (m *Manager) scrapeServiceDiscovery() discovery.Configs {
localAddr := fmt.Sprintf("127.0.0.1:%d", *m.c.ListenPort)

Comment thread
mattdurham marked this conversation as resolved.
localAddr := fmt.Sprintf("%s:%d", *m.c.ListenHost, *m.c.ListenPort)
labels := model.LabelSet{}
if m.c.UseHostnameLabel {
labels[model.LabelName("agent_hostname")] = model.LabelValue(m.hostname)
Expand Down
10 changes: 8 additions & 2 deletions pkg/integrations/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ test:
`
var (
cfg ManagerConfig
listenPort int = 12345
listenPort int = 12345
listenHost string = "127.0.0.1"
)
require.NoError(t, yaml.Unmarshal([]byte(cfgText), &cfg))

// Listen port must be set before applying defaults. Normally applied by the
// config package.
cfg.ListenPort = &listenPort
cfg.ListenHost = &listenHost

outBytes, err := yaml.Marshal(cfg)
require.NoError(t, err)
Expand All @@ -58,13 +60,15 @@ agent:

var (
cfg ManagerConfig
listenPort int = 12345
listenPort int = 12345
listenHost string = "127.0.0.1"
)
require.NoError(t, yaml.Unmarshal([]byte(cfgText), &cfg))

// Listen port must be set before applying defaults. Normally applied by the
// config package.
cfg.ListenPort = &listenPort
cfg.ListenHost = &listenHost

relabels, err := cfg.DefaultRelabelConfigs()
require.NoError(t, err)
Expand Down Expand Up @@ -285,9 +289,11 @@ func mockInstanceFactory(_ instance.Config) (instance.ManagedInstance, error) {

func mockManagerConfig() ManagerConfig {
listenPort := 0
listenHost := "127.0.0.1"
return ManagerConfig{
ScrapeIntegrations: true,
IntegrationRestartBackoff: 0,
ListenPort: &listenPort,
ListenHost: &listenHost,
}
}