diff --git a/command/agent/command.go b/command/agent/command.go index 53139eeea..0dc677b64 100644 --- a/command/agent/command.go +++ b/command/agent/command.go @@ -663,9 +663,11 @@ func (c *Command) setupTelemetry(config *Config) (*metrics.InmemSink, error) { } // Configure the prometheus sink - promSink, err := prometheus.NewPrometheusSink() - if err != nil { - fanout = append(fanout, promSink) + if telConfig.PrometheusMetrics { + promSink, err := prometheus.NewPrometheusSink() + if err != nil { + fanout = append(fanout, promSink) + } } // Configure the datadog sink diff --git a/command/agent/config-test-fixtures/basic.hcl b/command/agent/config-test-fixtures/basic.hcl index 2e451932e..237b8c86f 100644 --- a/command/agent/config-test-fixtures/basic.hcl +++ b/command/agent/config-test-fixtures/basic.hcl @@ -92,6 +92,7 @@ acl { telemetry { statsite_address = "127.0.0.1:1234" statsd_address = "127.0.0.1:2345" + prometheus_metrics = true disable_hostname = true collection_interval = "3s" publish_allocation_metrics = true diff --git a/command/agent/config.go b/command/agent/config.go index 8b2818ced..1ab766d27 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -356,6 +356,7 @@ type Telemetry struct { StatsiteAddr string `mapstructure:"statsite_address"` StatsdAddr string `mapstructure:"statsd_address"` DataDogAddr string `mapstructure:"datadog_address"` + PrometheusMetrics bool `mapstructure:"prometheus_metrics"` DisableHostname bool `mapstructure:"disable_hostname"` UseNodeName bool `mapstructure:"use_node_name"` CollectionInterval string `mapstructure:"collection_interval"` @@ -1148,6 +1149,9 @@ func (a *Telemetry) Merge(b *Telemetry) *Telemetry { if b.DataDogAddr != "" { result.DataDogAddr = b.DataDogAddr } + if b.PrometheusMetrics { + result.PrometheusMetrics = b.PrometheusMetrics + } if b.DisableHostname { result.DisableHostname = true } diff --git a/command/agent/config_parse.go b/command/agent/config_parse.go index 91d0158c2..0722679e9 100644 --- a/command/agent/config_parse.go +++ b/command/agent/config_parse.go @@ -620,6 +620,7 @@ func parseTelemetry(result **Telemetry, list *ast.ObjectList) error { "publish_allocation_metrics", "publish_node_metrics", "datadog_address", + "prometheus_metrics", "circonus_api_token", "circonus_api_app", "circonus_api_url", diff --git a/command/agent/config_parse_test.go b/command/agent/config_parse_test.go index e85680476..ce54bb908 100644 --- a/command/agent/config_parse_test.go +++ b/command/agent/config_parse_test.go @@ -113,6 +113,7 @@ func TestConfig_Parse(t *testing.T) { Telemetry: &Telemetry{ StatsiteAddr: "127.0.0.1:1234", StatsdAddr: "127.0.0.1:2345", + PrometheusMetrics: true, DisableHostname: true, UseNodeName: false, CollectionInterval: "3s", diff --git a/command/agent/config_test.go b/command/agent/config_test.go index 0927e47bd..a2fe8efda 100644 --- a/command/agent/config_test.go +++ b/command/agent/config_test.go @@ -54,6 +54,7 @@ func TestConfig_Merge(t *testing.T) { StatsiteAddr: "127.0.0.1:8125", StatsdAddr: "127.0.0.1:8125", DataDogAddr: "127.0.0.1:8125", + PrometheusMetrics: true, DisableHostname: false, DisableTaggedMetrics: true, BackwardsCompatibleMetrics: true, @@ -182,6 +183,7 @@ func TestConfig_Merge(t *testing.T) { StatsiteAddr: "127.0.0.2:8125", StatsdAddr: "127.0.0.2:8125", DataDogAddr: "127.0.0.1:8125", + PrometheusMetrics: true, DisableHostname: true, PublishNodeMetrics: true, PublishAllocationMetrics: true,