diff --git a/command/agent/config.go b/command/agent/config.go index b332888028..e8bdccc63f 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -193,7 +193,7 @@ type Telemetry struct { // should be used based on *where* this particular instance is running. // (e.g. a specific geo location or datacenter, dc:sfo) // Default: none - CirconusBrokerSelectTag string `mapstructure:"circonus_broker_search_tag"` + CirconusBrokerSelectTag string `mapstructure:"circonus_broker_select_tag"` } // Config is the configuration that can be set for an Agent. @@ -754,47 +754,6 @@ func DecodeConfig(r io.Reader) (*Config, error) { result.Telemetry.DogStatsdTags[i] = sub[i].(string) } } - - if sub, ok := obj["circonus_api_token"]; ok && result.Telemetry.CirconusAPIToken == "" { - result.Telemetry.CirconusAPIToken = sub.(string) - } - - if sub, ok := obj["circonus_api_app"]; ok && result.Telemetry.CirconusAPIApp == "" { - result.Telemetry.CirconusAPIApp = sub.(string) - } - - if sub, ok := obj["circonus_api_url"]; ok && result.Telemetry.CirconusAPIURL == "" { - result.Telemetry.CirconusAPIURL = sub.(string) - } - - if sub, ok := obj["circonus_submission_url"]; ok && result.Telemetry.CirconusCheckSubmissionURL == "" { - result.Telemetry.CirconusCheckSubmissionURL = sub.(string) - } - - if sub, ok := obj["circonus_submission_interval"]; ok && result.Telemetry.CirconusSubmissionInterval == "" { - result.Telemetry.CirconusSubmissionInterval = sub.(string) - } - - if sub, ok := obj["circonus_check_id"]; ok && result.Telemetry.CirconusCheckID == "" { - result.Telemetry.CirconusCheckID = sub.(string) - } - if sub, ok := obj["circonus_check_force_metric_activation"]; ok && result.Telemetry.CirconusCheckForceMetricActivation == "" { - result.Telemetry.CirconusCheckForceMetricActivation = sub.(string) - } - if sub, ok := obj["circonus_check_instance_id"]; ok && result.Telemetry.CirconusCheckInstanceID == "" { - result.Telemetry.CirconusCheckInstanceID = sub.(string) - } - if sub, ok := obj["circonus_check_search_tag"]; ok && result.Telemetry.CirconusCheckSearchTag == "" { - result.Telemetry.CirconusCheckSearchTag = sub.(string) - } - - if sub, ok := obj["circonus_broker_id"]; ok && result.Telemetry.CirconusBrokerID == "" { - result.Telemetry.CirconusBrokerID = sub.(string) - } - - if sub, ok := obj["circonus_broker_select_tag"]; ok && result.Telemetry.CirconusBrokerSelectTag == "" { - result.Telemetry.CirconusBrokerSelectTag = sub.(string) - } } // Decode @@ -813,14 +772,12 @@ func DecodeConfig(r io.Reader) (*Config, error) { // Check unused fields and verify that no bad configuration options were // passed to Consul. There are a few additional fields which don't directly - // use mapstructure decoding, so we need to account for those as well. + // use mapstructure decoding, so we need to account for those as well. These + // telemetry-related fields used to be available as top-level keys, so they + // are here for backward compatibility with the old format. allowedKeys := []string{ "service", "services", "check", "checks", "statsd_addr", "statsite_addr", "statsite_prefix", "dogstatsd_addr", "dogstatsd_tags", - "circonus_api_token", "circonus_api_app", - "circonus_api_url", "circonus_submission_url", "circonus_submission_interval", - "circonus_check_id", "circonus_check_force_metric_activation", "circonus_check_instance_id", - "circonus_check_search_tag", "circonus_broker_id", "circonus_broker_select_tag", } var unused []string diff --git a/command/agent/config_test.go b/command/agent/config_test.go index df17f89bf1..06e5d85427 100644 --- a/command/agent/config_test.go +++ b/command/agent/config_test.go @@ -726,12 +726,12 @@ func TestDecodeConfig(t *testing.T) { } // Circonus settings - input = `{"circonus_api_token": "12345678-1234-1234-12345678", "circonus_api_app": "testApp", + input = `{"telemetry": {"circonus_api_token": "12345678-1234-1234-12345678", "circonus_api_app": "testApp", "circonus_api_url": "https://api.host.foo/v2", "circonus_submission_interval": "15s", "circonus_submission_url": "https://submit.host.bar:123/one/two/three", "circonus_check_id": "12345", "circonus_check_force_metric_activation": "true", "circonus_check_instance_id": "a:b", "circonus_check_search_tag": "c:d", - "circonus_broker_id": "6789", "circonus_broker_select_tag": "e:f"}` + "circonus_broker_id": "6789", "circonus_broker_select_tag": "e:f"} }` config, err = DecodeConfig(bytes.NewReader([]byte(input))) if err != nil { t.Fatalf("err: %s", err)