diff --git a/command/agent/config-test-fixtures/basic.hcl b/command/agent/config-test-fixtures/basic.hcl index 459474b3c..304da9b8e 100644 --- a/command/agent/config-test-fixtures/basic.hcl +++ b/command/agent/config-test-fixtures/basic.hcl @@ -60,6 +60,8 @@ client { gc_inode_usage_threshold = 91 gc_max_allocs = 50 no_host_uuid = false + disable_tagged_metrics = true + backwards_compatible_metrics = true } server { enabled = true diff --git a/command/agent/config.go b/command/agent/config.go index 36052df18..de1580b17 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -229,6 +229,14 @@ type ClientConfig struct { // NoHostUUID disables using the host's UUID and will force generation of a // random UUID. NoHostUUID *bool `mapstructure:"no_host_uuid"` + + // DisableTaggedMetrics disables a new version of generating metrics and + // uses only the old method of displaying metrics + DisableTaggedMetrics bool `mapstructure:"disable_tagged_metrics"` + + // BackwardsCompatibleMetrics allows for generating metrics as done in older + // versions of Nomad + BackwardsCompatibleMetrics bool `mapstructure:"backwards_compatible_metrics"` } // ACLConfig is configuration specific to the ACL system @@ -576,17 +584,19 @@ func DefaultConfig() *Config { Consul: config.DefaultConsulConfig(), Vault: config.DefaultVaultConfig(), Client: &ClientConfig{ - Enabled: false, - MaxKillTimeout: "30s", - ClientMinPort: 14000, - ClientMaxPort: 14512, - Reserved: &Resources{}, - GCInterval: 1 * time.Minute, - GCParallelDestroys: 2, - GCDiskUsageThreshold: 80, - GCInodeUsageThreshold: 70, - GCMaxAllocs: 50, - NoHostUUID: helper.BoolToPtr(true), + Enabled: false, + MaxKillTimeout: "30s", + ClientMinPort: 14000, + ClientMaxPort: 14512, + Reserved: &Resources{}, + GCInterval: 1 * time.Minute, + GCParallelDestroys: 2, + GCDiskUsageThreshold: 80, + GCInodeUsageThreshold: 70, + GCMaxAllocs: 50, + NoHostUUID: helper.BoolToPtr(true), + DisableTaggedMetrics: false, + BackwardsCompatibleMetrics: false, }, Server: &ServerConfig{ Enabled: false, @@ -1097,6 +1107,14 @@ func (a *ClientConfig) Merge(b *ClientConfig) *ClientConfig { result.NoHostUUID = b.NoHostUUID } + if b.DisableTaggedMetrics { + result.DisableTaggedMetrics = b.DisableTaggedMetrics + } + + if b.BackwardsCompatibleMetrics { + result.BackwardsCompatibleMetrics = b.BackwardsCompatibleMetrics + } + // Add the servers result.Servers = append(result.Servers, b.Servers...) diff --git a/command/agent/config_parse.go b/command/agent/config_parse.go index 2894f7901..4928e48b2 100644 --- a/command/agent/config_parse.go +++ b/command/agent/config_parse.go @@ -357,6 +357,8 @@ func parseClient(result **ClientConfig, list *ast.ObjectList) error { "gc_parallel_destroys", "gc_max_allocs", "no_host_uuid", + "disable_tagged_metrics", + "backwards_compatible_metrics", } if err := checkHCLKeys(listVal, valid); err != nil { return err diff --git a/command/agent/config_parse_test.go b/command/agent/config_parse_test.go index e088926a2..e2262ac36 100644 --- a/command/agent/config_parse_test.go +++ b/command/agent/config_parse_test.go @@ -75,12 +75,14 @@ func TestConfig_Parse(t *testing.T) { ReservedPorts: "1,100,10-12", ParsedReservedPorts: []int{1, 10, 11, 12, 100}, }, - GCInterval: 6 * time.Second, - GCParallelDestroys: 6, - GCDiskUsageThreshold: 82, - GCInodeUsageThreshold: 91, - GCMaxAllocs: 50, - NoHostUUID: helper.BoolToPtr(false), + GCInterval: 6 * time.Second, + GCParallelDestroys: 6, + GCDiskUsageThreshold: 82, + GCInodeUsageThreshold: 91, + GCMaxAllocs: 50, + NoHostUUID: helper.BoolToPtr(false), + DisableTaggedMetrics: true, + BackwardsCompatibleMetrics: true, }, Server: &ServerConfig{ Enabled: true,