diff --git a/agent/xds/sni.go b/agent/xds/sni.go index dc886feaae..1730797d88 100644 --- a/agent/xds/sni.go +++ b/agent/xds/sni.go @@ -50,7 +50,7 @@ func CustomizeClusterName(sni string, chain *structs.CompiledDiscoveryChain) str if chain == nil || chain.CustomizationHash == "" { return sni } - // Use a colon to delimit this prefix instead of a dot to avoid a + // Use a tilde to delimit this prefix instead of a dot to avoid a // theoretical collision problem with subsets. - return fmt.Sprintf("%s:%s", chain.CustomizationHash, sni) + return fmt.Sprintf("%s~%s", chain.CustomizationHash, sni) } diff --git a/agent/xds/testdata/clusters/connect-proxy-with-chain-and-overrides.golden b/agent/xds/testdata/clusters/connect-proxy-with-chain-and-overrides.golden index 7af4313cd1..c97b21eece 100644 --- a/agent/xds/testdata/clusters/connect-proxy-with-chain-and-overrides.golden +++ b/agent/xds/testdata/clusters/connect-proxy-with-chain-and-overrides.golden @@ -3,8 +3,8 @@ "resources": [ { "@type": "type.googleapis.com/envoy.api.v2.Cluster", - "name": "a236e964:db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", - "altStatName": "a236e964:db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", + "name": "a236e964~db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", + "altStatName": "a236e964~db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", "type": "EDS", "edsClusterConfig": { "edsConfig": { diff --git a/agent/xds/testdata/endpoints/connect-proxy-with-chain-and-overrides.golden b/agent/xds/testdata/endpoints/connect-proxy-with-chain-and-overrides.golden index ee46d0933a..def02b3599 100644 --- a/agent/xds/testdata/endpoints/connect-proxy-with-chain-and-overrides.golden +++ b/agent/xds/testdata/endpoints/connect-proxy-with-chain-and-overrides.golden @@ -3,7 +3,7 @@ "resources": [ { "@type": "type.googleapis.com/envoy.api.v2.ClusterLoadAssignment", - "clusterName": "a236e964:db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", + "clusterName": "a236e964~db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", "endpoints": [ { "lbEndpoints": [ diff --git a/agent/xds/testdata/routes/connect-proxy-with-chain-and-overrides.golden b/agent/xds/testdata/routes/connect-proxy-with-chain-and-overrides.golden index b07e87e3ad..357c4a3c35 100644 --- a/agent/xds/testdata/routes/connect-proxy-with-chain-and-overrides.golden +++ b/agent/xds/testdata/routes/connect-proxy-with-chain-and-overrides.golden @@ -16,7 +16,7 @@ "prefix": "/" }, "route": { - "cluster": "a236e964:db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul" + "cluster": "a236e964~db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul" } } ] diff --git a/command/connect/envoy/bootstrap_config.go b/command/connect/envoy/bootstrap_config.go index fea581dcf1..75bdb2dd31 100644 --- a/command/connect/envoy/bootstrap_config.go +++ b/command/connect/envoy/bootstrap_config.go @@ -2,6 +2,7 @@ package envoy import ( "bytes" + "encoding/json" "fmt" "net" "net/url" @@ -149,7 +150,13 @@ func (c *BootstrapConfig) GenerateJSON(args *BootstrapTplArgs) ([]byte, error) { return nil, err } - return buf.Bytes(), nil + // Pretty print the JSON. + var buf2 bytes.Buffer + if err := json.Indent(&buf2, buf.Bytes(), "", " "); err != nil { + return nil, err + } + + return buf2.Bytes(), nil } // ConfigureArgs takes the basic template arguments generated from the command @@ -265,6 +272,49 @@ func (c *BootstrapConfig) generateStatsSinkJSON(name string, addr string) (strin }`, nil } +var sniTagJSONs []string + +func init() { + // ......consul + // - cluster.pong.default.dc2.internal.e5b08d03-bfc3-c870-1833-baddb116e648.consul.bind_errors: 0 + // - cluster.f8f8f8f8~pong.default.dc2.internal.e5b08d03-bfc3-c870-1833-baddb116e648.consul.bind_errors: 0 + // - cluster.v2.pong.default.dc2.internal.e5b08d03-bfc3-c870-1833-baddb116e648.consul.bind_errors: 0 + // - cluster.f8f8f8f8~v2.pong.default.dc2.internal.e5b08d03-bfc3-c870-1833-baddb116e648.consul.bind_errors: 0 + const PART = `[^.]+` + rules := [][]string{ + {"consul.custom_hash", + fmt.Sprintf(`^cluster\.((?:(%s)~)?(?:%s\.)?%s\.%s\.%s\.%s\.%s\.consul\.)`, PART, PART, PART, PART, PART, PART, PART)}, + {"consul.service_subset", + fmt.Sprintf(`^cluster\.((?:%s~)?(?:(%s)\.)?%s\.%s\.%s\.%s\.%s\.consul\.)`, PART, PART, PART, PART, PART, PART, PART)}, + {"consul.service", + fmt.Sprintf(`^cluster\.((?:%s~)?(?:%s\.)?(%s)\.%s\.%s\.%s\.%s\.consul\.)`, PART, PART, PART, PART, PART, PART, PART)}, + {"consul.namespace", + fmt.Sprintf(`^cluster\.((?:%s~)?(?:%s\.)?%s\.(%s)\.%s\.%s\.%s\.consul\.)`, PART, PART, PART, PART, PART, PART, PART)}, + {"consul.datacenter", + fmt.Sprintf(`^cluster\.((?:%s~)?(?:%s\.)?%s\.%s\.(%s)\.%s\.%s\.consul\.)`, PART, PART, PART, PART, PART, PART, PART)}, + {"consul.routing_type", + fmt.Sprintf(`^cluster\.((?:%s~)?(?:%s\.)?%s\.%s\.%s\.(%s)\.%s\.consul\.)`, PART, PART, PART, PART, PART, PART, PART)}, // internal:true/false would be idea + {"consul.trust_domain", + fmt.Sprintf(`^cluster\.((?:%s~)?(?:%s\.)?%s\.%s\.%s\.%s\.(%s)\.consul\.)`, PART, PART, PART, PART, PART, PART, PART)}, + {"consul.target", + fmt.Sprintf(`^cluster\.(((?:%s~)?(?:%s\.)?%s\.%s\.%s)\.%s\.%s\.consul\.)`, PART, PART, PART, PART, PART, PART, PART)}, + {"consul.full_target", + fmt.Sprintf(`^cluster\.(((?:%s~)?(?:%s\.)?%s\.%s\.%s\.%s\.%s)\.consul\.)`, PART, PART, PART, PART, PART, PART, PART)}, + } + + for _, rule := range rules { + m := map[string]string{ + "tag_name": rule[0], + "regex": rule[1], + } + d, err := json.Marshal(m) + if err != nil { + panic("error pregenerating SNI envoy tags: " + err.Error()) + } + sniTagJSONs = append(sniTagJSONs, string(d)) + } +} + func (c *BootstrapConfig) generateStatsConfig(args *BootstrapTplArgs) error { var tagJSONs []string @@ -273,6 +323,9 @@ func (c *BootstrapConfig) generateStatsConfig(args *BootstrapTplArgs) error { "local_cluster": args.ProxyCluster, } + // Explode SNI portions. + tagJSONs = append(tagJSONs, sniTagJSONs...) + for _, tag := range c.StatsTags { parts := strings.SplitN(tag, "=", 2) // If there is no equals, treat it as a boolean tag and just assign value of diff --git a/command/connect/envoy/bootstrap_config_test.go b/command/connect/envoy/bootstrap_config_test.go index 6064671f61..d8db181c13 100644 --- a/command/connect/envoy/bootstrap_config_test.go +++ b/command/connect/envoy/bootstrap_config_test.go @@ -83,6 +83,13 @@ const ( ) func TestBootstrapConfig_ConfigureArgs(t *testing.T) { + sniTagJSON := strings.Join(sniTagJSONs, ",\n") + defaultStatsConfigJSON := `{ + "stats_tags": [ + ` + sniTagJSON + ` + ], + "use_all_default_tags": true + }` tests := []struct { name string @@ -93,10 +100,12 @@ func TestBootstrapConfig_ConfigureArgs(t *testing.T) { wantErr bool }{ { - name: "defaults", - input: BootstrapConfig{}, - wantArgs: BootstrapTplArgs{}, - wantErr: false, + name: "defaults", + input: BootstrapConfig{}, + wantArgs: BootstrapTplArgs{ + StatsConfigJSON: defaultStatsConfigJSON, + }, + wantErr: false, }, { name: "extra-stats-sinks", @@ -109,6 +118,7 @@ func TestBootstrapConfig_ConfigureArgs(t *testing.T) { }`, }, wantArgs: BootstrapTplArgs{ + StatsConfigJSON: defaultStatsConfigJSON, StatsSinksJSON: `[{ "name": "envoy.custom_exciting_sink", "config": { @@ -123,6 +133,7 @@ func TestBootstrapConfig_ConfigureArgs(t *testing.T) { StatsdURL: "udp://127.0.0.1:9125", }, wantArgs: BootstrapTplArgs{ + StatsConfigJSON: defaultStatsConfigJSON, StatsSinksJSON: `[{ "name": "envoy.statsd", "config": { @@ -149,6 +160,7 @@ func TestBootstrapConfig_ConfigureArgs(t *testing.T) { }`, }, wantArgs: BootstrapTplArgs{ + StatsConfigJSON: defaultStatsConfigJSON, StatsSinksJSON: `[{ "name": "envoy.statsd", "config": { @@ -176,6 +188,7 @@ func TestBootstrapConfig_ConfigureArgs(t *testing.T) { }, env: []string{"MY_STATSD_URL=udp://127.0.0.1:9125"}, wantArgs: BootstrapTplArgs{ + StatsConfigJSON: defaultStatsConfigJSON, StatsSinksJSON: `[{ "name": "envoy.statsd", "config": { @@ -196,6 +209,7 @@ func TestBootstrapConfig_ConfigureArgs(t *testing.T) { DogstatsdURL: "udp://127.0.0.1:9125", }, wantArgs: BootstrapTplArgs{ + StatsConfigJSON: defaultStatsConfigJSON, StatsSinksJSON: `[{ "name": "envoy.dog_statsd", "config": { @@ -216,6 +230,7 @@ func TestBootstrapConfig_ConfigureArgs(t *testing.T) { DogstatsdURL: "unix:///var/run/dogstatsd.sock", }, wantArgs: BootstrapTplArgs{ + StatsConfigJSON: defaultStatsConfigJSON, StatsSinksJSON: `[{ "name": "envoy.dog_statsd", "config": { @@ -237,6 +252,7 @@ func TestBootstrapConfig_ConfigureArgs(t *testing.T) { }, env: []string{"MY_STATSD_URL=udp://127.0.0.1:9125"}, wantArgs: BootstrapTplArgs{ + StatsConfigJSON: defaultStatsConfigJSON, StatsSinksJSON: `[{ "name": "envoy.dog_statsd", "config": { @@ -273,6 +289,7 @@ func TestBootstrapConfig_ConfigureArgs(t *testing.T) { wantArgs: BootstrapTplArgs{ StatsConfigJSON: `{ "stats_tags": [ + ` + sniTagJSON + `, { "tag_name": "canary", "fixed_value": "1" @@ -307,6 +324,7 @@ func TestBootstrapConfig_ConfigureArgs(t *testing.T) { StaticClustersJSON: expectedPromCluster, // Should add a static http listener too StaticListenersJSON: expectedPromListener, + StatsConfigJSON: defaultStatsConfigJSON, }, wantErr: false, }, @@ -328,6 +346,7 @@ func TestBootstrapConfig_ConfigureArgs(t *testing.T) { StaticClustersJSON: `{"foo":"bar"},` + expectedPromCluster, // Should add a static http listener too StaticListenersJSON: `{"baz":"qux"},` + expectedPromListener, + StatsConfigJSON: defaultStatsConfigJSON, }, wantErr: false, }, @@ -337,6 +356,7 @@ func TestBootstrapConfig_ConfigureArgs(t *testing.T) { StatsFlushInterval: `10s`, }, wantArgs: BootstrapTplArgs{ + StatsConfigJSON: defaultStatsConfigJSON, StatsFlushInterval: `10s`, }, wantErr: false, @@ -347,6 +367,7 @@ func TestBootstrapConfig_ConfigureArgs(t *testing.T) { TracingConfigJSON: `{"foo": "bar"}`, }, wantArgs: BootstrapTplArgs{ + StatsConfigJSON: defaultStatsConfigJSON, TracingConfigJSON: `{"foo": "bar"}`, }, wantErr: false, diff --git a/command/connect/envoy/envoy_test.go b/command/connect/envoy/envoy_test.go index 6e8ecba651..21af7e7aa2 100644 --- a/command/connect/envoy/envoy_test.go +++ b/command/connect/envoy/envoy_test.go @@ -283,7 +283,7 @@ func TestGenerateConfig(t *testing.T) { "cluster": "{{ .ProxyCluster }}", "id": "{{ .ProxyID }}" }, - custom_field = "foo" + "custom_field": "foo" }`, }, WantArgs: BootstrapTplArgs{ diff --git a/command/connect/envoy/testdata/access-log-path.golden b/command/connect/envoy/testdata/access-log-path.golden index 4ce76d3529..741ad87e89 100644 --- a/command/connect/envoy/testdata/access-log-path.golden +++ b/command/connect/envoy/testdata/access-log-path.golden @@ -19,27 +19,69 @@ "connect_timeout": "1s", "type": "STATIC", "http2_protocol_options": {}, - "hosts": [{ + "hosts": [ + { "socket_address": { "address": "127.0.0.1", "port_value": 8502 } - }] + } + ] } ] }, "stats_config": { - "stats_tags": [ - { - "tag_name": "local_cluster", - "fixed_value": "test-proxy" - } - ], - "use_all_default_tags": true - }, + "stats_tags": [ + { + "regex": "^cluster\\.((?:([^.]+)~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.custom_hash" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:([^.]+)\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service_subset" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.namespace" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.datacenter" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.consul\\.)", + "tag_name": "consul.routing_type" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.consul\\.)", + "tag_name": "consul.trust_domain" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.target" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+)\\.consul\\.)", + "tag_name": "consul.full_target" + }, + { + "tag_name": "local_cluster", + "fixed_value": "test-proxy" + } + ], + "use_all_default_tags": true + }, "dynamic_resources": { - "lds_config": { "ads": {} }, - "cds_config": { "ads": {} }, + "lds_config": { + "ads": {} + }, + "cds_config": { + "ads": {} + }, "ads_config": { "api_type": "GRPC", "grpc_services": { diff --git a/command/connect/envoy/testdata/custom-bootstrap.golden b/command/connect/envoy/testdata/custom-bootstrap.golden index 5032f22344..98746ead1e 100644 --- a/command/connect/envoy/testdata/custom-bootstrap.golden +++ b/command/connect/envoy/testdata/custom-bootstrap.golden @@ -1,17 +1,16 @@ - - { - "admin": { - "access_log_path": "/dev/null", - "address": { - "socket_address": { - "address": "127.0.0.1", - "port_value": 19000 - } - } - }, - "node": { - "cluster": "test-proxy", - "id": "test-proxy" - }, - custom_field = "foo" - } \ No newline at end of file +{ + "admin": { + "access_log_path": "/dev/null", + "address": { + "socket_address": { + "address": "127.0.0.1", + "port_value": 19000 + } + } + }, + "node": { + "cluster": "test-proxy", + "id": "test-proxy" + }, + "custom_field": "foo" +} \ No newline at end of file diff --git a/command/connect/envoy/testdata/defaults.golden b/command/connect/envoy/testdata/defaults.golden index 32c0240c28..261e6abb28 100644 --- a/command/connect/envoy/testdata/defaults.golden +++ b/command/connect/envoy/testdata/defaults.golden @@ -19,27 +19,69 @@ "connect_timeout": "1s", "type": "STATIC", "http2_protocol_options": {}, - "hosts": [{ + "hosts": [ + { "socket_address": { "address": "127.0.0.1", "port_value": 8502 } - }] + } + ] } ] }, "stats_config": { - "stats_tags": [ - { - "tag_name": "local_cluster", - "fixed_value": "test-proxy" - } - ], - "use_all_default_tags": true - }, + "stats_tags": [ + { + "regex": "^cluster\\.((?:([^.]+)~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.custom_hash" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:([^.]+)\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service_subset" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.namespace" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.datacenter" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.consul\\.)", + "tag_name": "consul.routing_type" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.consul\\.)", + "tag_name": "consul.trust_domain" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.target" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+)\\.consul\\.)", + "tag_name": "consul.full_target" + }, + { + "tag_name": "local_cluster", + "fixed_value": "test-proxy" + } + ], + "use_all_default_tags": true + }, "dynamic_resources": { - "lds_config": { "ads": {} }, - "cds_config": { "ads": {} }, + "lds_config": { + "ads": {} + }, + "cds_config": { + "ads": {} + }, "ads_config": { "api_type": "GRPC", "grpc_services": { diff --git a/command/connect/envoy/testdata/extra_-multiple.golden b/command/connect/envoy/testdata/extra_-multiple.golden index 9f9ca8cea5..a2f592789f 100644 --- a/command/connect/envoy/testdata/extra_-multiple.golden +++ b/command/connect/envoy/testdata/extra_-multiple.golden @@ -19,48 +19,91 @@ "connect_timeout": "1s", "type": "STATIC", "http2_protocol_options": {}, - "hosts": [{ + "hosts": [ + { "socket_address": { "address": "127.0.0.1", "port_value": 8502 } - }] + } + ] }, - - { - "name": "fake_cluster_1" - }, - { - "name": "fake_cluster_2" - } + { + "name": "fake_cluster_1" + }, + { + "name": "fake_cluster_2" + } ], "listeners": [ - - { - "name": "fake_listener_1" - },{ - "name": "fake_listener_2" - } + { + "name": "fake_listener_1" + }, + { + "name": "fake_listener_2" + } ] }, "stats_sinks": [ - - { - "name": "fake_sink_1" - } , { "name": "fake_sink_2" } -], + { + "name": "fake_sink_1" + }, + { + "name": "fake_sink_2" + } + ], "stats_config": { - "stats_tags": [ - { - "tag_name": "local_cluster", - "fixed_value": "test-proxy" - } - ], - "use_all_default_tags": true - }, + "stats_tags": [ + { + "regex": "^cluster\\.((?:([^.]+)~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.custom_hash" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:([^.]+)\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service_subset" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.namespace" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.datacenter" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.consul\\.)", + "tag_name": "consul.routing_type" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.consul\\.)", + "tag_name": "consul.trust_domain" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.target" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+)\\.consul\\.)", + "tag_name": "consul.full_target" + }, + { + "tag_name": "local_cluster", + "fixed_value": "test-proxy" + } + ], + "use_all_default_tags": true + }, "dynamic_resources": { - "lds_config": { "ads": {} }, - "cds_config": { "ads": {} }, + "lds_config": { + "ads": {} + }, + "cds_config": { + "ads": {} + }, "ads_config": { "api_type": "GRPC", "grpc_services": { diff --git a/command/connect/envoy/testdata/extra_-single.golden b/command/connect/envoy/testdata/extra_-single.golden index bb20d2ddd9..4fc78113ec 100644 --- a/command/connect/envoy/testdata/extra_-single.golden +++ b/command/connect/envoy/testdata/extra_-single.golden @@ -19,43 +19,82 @@ "connect_timeout": "1s", "type": "STATIC", "http2_protocol_options": {}, - "hosts": [{ + "hosts": [ + { "socket_address": { "address": "127.0.0.1", "port_value": 8502 } - }] + } + ] }, - - { - "name": "fake_cluster_1" - } + { + "name": "fake_cluster_1" + } ], "listeners": [ - - { - "name": "fake_listener_1" - } + { + "name": "fake_listener_1" + } ] }, "stats_sinks": [ - - { - "name": "fake_sink_1" - } -], + { + "name": "fake_sink_1" + } + ], "stats_config": { - "stats_tags": [ - { - "tag_name": "local_cluster", - "fixed_value": "test-proxy" - } - ], - "use_all_default_tags": true - }, + "stats_tags": [ + { + "regex": "^cluster\\.((?:([^.]+)~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.custom_hash" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:([^.]+)\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service_subset" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.namespace" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.datacenter" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.consul\\.)", + "tag_name": "consul.routing_type" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.consul\\.)", + "tag_name": "consul.trust_domain" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.target" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+)\\.consul\\.)", + "tag_name": "consul.full_target" + }, + { + "tag_name": "local_cluster", + "fixed_value": "test-proxy" + } + ], + "use_all_default_tags": true + }, "dynamic_resources": { - "lds_config": { "ads": {} }, - "cds_config": { "ads": {} }, + "lds_config": { + "ads": {} + }, + "cds_config": { + "ads": {} + }, "ads_config": { "api_type": "GRPC", "grpc_services": { diff --git a/command/connect/envoy/testdata/grpc-addr-config.golden b/command/connect/envoy/testdata/grpc-addr-config.golden index 3a686b03b1..43810ee3dd 100644 --- a/command/connect/envoy/testdata/grpc-addr-config.golden +++ b/command/connect/envoy/testdata/grpc-addr-config.golden @@ -19,27 +19,69 @@ "connect_timeout": "1s", "type": "STATIC", "http2_protocol_options": {}, - "hosts": [{ + "hosts": [ + { "socket_address": { "address": "127.0.0.1", "port_value": 9999 } - }] + } + ] } ] }, "stats_config": { - "stats_tags": [ - { - "tag_name": "local_cluster", - "fixed_value": "test-proxy" - } - ], - "use_all_default_tags": true - }, + "stats_tags": [ + { + "regex": "^cluster\\.((?:([^.]+)~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.custom_hash" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:([^.]+)\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service_subset" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.namespace" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.datacenter" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.consul\\.)", + "tag_name": "consul.routing_type" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.consul\\.)", + "tag_name": "consul.trust_domain" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.target" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+)\\.consul\\.)", + "tag_name": "consul.full_target" + }, + { + "tag_name": "local_cluster", + "fixed_value": "test-proxy" + } + ], + "use_all_default_tags": true + }, "dynamic_resources": { - "lds_config": { "ads": {} }, - "cds_config": { "ads": {} }, + "lds_config": { + "ads": {} + }, + "cds_config": { + "ads": {} + }, "ads_config": { "api_type": "GRPC", "grpc_services": { diff --git a/command/connect/envoy/testdata/grpc-addr-env.golden b/command/connect/envoy/testdata/grpc-addr-env.golden index 3a686b03b1..43810ee3dd 100644 --- a/command/connect/envoy/testdata/grpc-addr-env.golden +++ b/command/connect/envoy/testdata/grpc-addr-env.golden @@ -19,27 +19,69 @@ "connect_timeout": "1s", "type": "STATIC", "http2_protocol_options": {}, - "hosts": [{ + "hosts": [ + { "socket_address": { "address": "127.0.0.1", "port_value": 9999 } - }] + } + ] } ] }, "stats_config": { - "stats_tags": [ - { - "tag_name": "local_cluster", - "fixed_value": "test-proxy" - } - ], - "use_all_default_tags": true - }, + "stats_tags": [ + { + "regex": "^cluster\\.((?:([^.]+)~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.custom_hash" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:([^.]+)\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service_subset" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.namespace" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.datacenter" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.consul\\.)", + "tag_name": "consul.routing_type" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.consul\\.)", + "tag_name": "consul.trust_domain" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.target" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+)\\.consul\\.)", + "tag_name": "consul.full_target" + }, + { + "tag_name": "local_cluster", + "fixed_value": "test-proxy" + } + ], + "use_all_default_tags": true + }, "dynamic_resources": { - "lds_config": { "ads": {} }, - "cds_config": { "ads": {} }, + "lds_config": { + "ads": {} + }, + "cds_config": { + "ads": {} + }, "ads_config": { "api_type": "GRPC", "grpc_services": { diff --git a/command/connect/envoy/testdata/grpc-addr-flag.golden b/command/connect/envoy/testdata/grpc-addr-flag.golden index 3a686b03b1..43810ee3dd 100644 --- a/command/connect/envoy/testdata/grpc-addr-flag.golden +++ b/command/connect/envoy/testdata/grpc-addr-flag.golden @@ -19,27 +19,69 @@ "connect_timeout": "1s", "type": "STATIC", "http2_protocol_options": {}, - "hosts": [{ + "hosts": [ + { "socket_address": { "address": "127.0.0.1", "port_value": 9999 } - }] + } + ] } ] }, "stats_config": { - "stats_tags": [ - { - "tag_name": "local_cluster", - "fixed_value": "test-proxy" - } - ], - "use_all_default_tags": true - }, + "stats_tags": [ + { + "regex": "^cluster\\.((?:([^.]+)~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.custom_hash" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:([^.]+)\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service_subset" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.namespace" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.datacenter" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.consul\\.)", + "tag_name": "consul.routing_type" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.consul\\.)", + "tag_name": "consul.trust_domain" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.target" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+)\\.consul\\.)", + "tag_name": "consul.full_target" + }, + { + "tag_name": "local_cluster", + "fixed_value": "test-proxy" + } + ], + "use_all_default_tags": true + }, "dynamic_resources": { - "lds_config": { "ads": {} }, - "cds_config": { "ads": {} }, + "lds_config": { + "ads": {} + }, + "cds_config": { + "ads": {} + }, "ads_config": { "api_type": "GRPC", "grpc_services": { diff --git a/command/connect/envoy/testdata/grpc-addr-unix.golden b/command/connect/envoy/testdata/grpc-addr-unix.golden index 260fae8fda..01c37ee8d1 100644 --- a/command/connect/envoy/testdata/grpc-addr-unix.golden +++ b/command/connect/envoy/testdata/grpc-addr-unix.golden @@ -19,26 +19,68 @@ "connect_timeout": "1s", "type": "STATIC", "http2_protocol_options": {}, - "hosts": [{ + "hosts": [ + { "pipe": { "path": "/var/run/consul.sock" } - }] + } + ] } ] }, "stats_config": { - "stats_tags": [ - { - "tag_name": "local_cluster", - "fixed_value": "test-proxy" - } - ], - "use_all_default_tags": true - }, + "stats_tags": [ + { + "regex": "^cluster\\.((?:([^.]+)~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.custom_hash" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:([^.]+)\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service_subset" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.namespace" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.datacenter" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.consul\\.)", + "tag_name": "consul.routing_type" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.consul\\.)", + "tag_name": "consul.trust_domain" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.target" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+)\\.consul\\.)", + "tag_name": "consul.full_target" + }, + { + "tag_name": "local_cluster", + "fixed_value": "test-proxy" + } + ], + "use_all_default_tags": true + }, "dynamic_resources": { - "lds_config": { "ads": {} }, - "cds_config": { "ads": {} }, + "lds_config": { + "ads": {} + }, + "cds_config": { + "ads": {} + }, "ads_config": { "api_type": "GRPC", "grpc_services": { diff --git a/command/connect/envoy/testdata/stats-config-override.golden b/command/connect/envoy/testdata/stats-config-override.golden index 2375727748..5830b0228f 100644 --- a/command/connect/envoy/testdata/stats-config-override.golden +++ b/command/connect/envoy/testdata/stats-config-override.golden @@ -19,22 +19,27 @@ "connect_timeout": "1s", "type": "STATIC", "http2_protocol_options": {}, - "hosts": [{ + "hosts": [ + { "socket_address": { "address": "127.0.0.1", "port_value": 8502 } - }] + } + ] } ] }, - "stats_config": - { - "name": "fake_config" - }, + "stats_config": { + "name": "fake_config" + }, "dynamic_resources": { - "lds_config": { "ads": {} }, - "cds_config": { "ads": {} }, + "lds_config": { + "ads": {} + }, + "cds_config": { + "ads": {} + }, "ads_config": { "api_type": "GRPC", "grpc_services": { diff --git a/command/connect/envoy/testdata/token-arg.golden b/command/connect/envoy/testdata/token-arg.golden index 75014d50b5..13c803cc73 100644 --- a/command/connect/envoy/testdata/token-arg.golden +++ b/command/connect/envoy/testdata/token-arg.golden @@ -19,27 +19,69 @@ "connect_timeout": "1s", "type": "STATIC", "http2_protocol_options": {}, - "hosts": [{ + "hosts": [ + { "socket_address": { "address": "127.0.0.1", "port_value": 8502 } - }] + } + ] } ] }, "stats_config": { - "stats_tags": [ - { - "tag_name": "local_cluster", - "fixed_value": "test-proxy" - } - ], - "use_all_default_tags": true - }, + "stats_tags": [ + { + "regex": "^cluster\\.((?:([^.]+)~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.custom_hash" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:([^.]+)\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service_subset" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.namespace" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.datacenter" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.consul\\.)", + "tag_name": "consul.routing_type" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.consul\\.)", + "tag_name": "consul.trust_domain" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.target" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+)\\.consul\\.)", + "tag_name": "consul.full_target" + }, + { + "tag_name": "local_cluster", + "fixed_value": "test-proxy" + } + ], + "use_all_default_tags": true + }, "dynamic_resources": { - "lds_config": { "ads": {} }, - "cds_config": { "ads": {} }, + "lds_config": { + "ads": {} + }, + "cds_config": { + "ads": {} + }, "ads_config": { "api_type": "GRPC", "grpc_services": { diff --git a/command/connect/envoy/testdata/token-env.golden b/command/connect/envoy/testdata/token-env.golden index 75014d50b5..13c803cc73 100644 --- a/command/connect/envoy/testdata/token-env.golden +++ b/command/connect/envoy/testdata/token-env.golden @@ -19,27 +19,69 @@ "connect_timeout": "1s", "type": "STATIC", "http2_protocol_options": {}, - "hosts": [{ + "hosts": [ + { "socket_address": { "address": "127.0.0.1", "port_value": 8502 } - }] + } + ] } ] }, "stats_config": { - "stats_tags": [ - { - "tag_name": "local_cluster", - "fixed_value": "test-proxy" - } - ], - "use_all_default_tags": true - }, + "stats_tags": [ + { + "regex": "^cluster\\.((?:([^.]+)~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.custom_hash" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:([^.]+)\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service_subset" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.namespace" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.datacenter" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.consul\\.)", + "tag_name": "consul.routing_type" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.consul\\.)", + "tag_name": "consul.trust_domain" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.target" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+)\\.consul\\.)", + "tag_name": "consul.full_target" + }, + { + "tag_name": "local_cluster", + "fixed_value": "test-proxy" + } + ], + "use_all_default_tags": true + }, "dynamic_resources": { - "lds_config": { "ads": {} }, - "cds_config": { "ads": {} }, + "lds_config": { + "ads": {} + }, + "cds_config": { + "ads": {} + }, "ads_config": { "api_type": "GRPC", "grpc_services": { diff --git a/command/connect/envoy/testdata/token-file-arg.golden b/command/connect/envoy/testdata/token-file-arg.golden index 75014d50b5..13c803cc73 100644 --- a/command/connect/envoy/testdata/token-file-arg.golden +++ b/command/connect/envoy/testdata/token-file-arg.golden @@ -19,27 +19,69 @@ "connect_timeout": "1s", "type": "STATIC", "http2_protocol_options": {}, - "hosts": [{ + "hosts": [ + { "socket_address": { "address": "127.0.0.1", "port_value": 8502 } - }] + } + ] } ] }, "stats_config": { - "stats_tags": [ - { - "tag_name": "local_cluster", - "fixed_value": "test-proxy" - } - ], - "use_all_default_tags": true - }, + "stats_tags": [ + { + "regex": "^cluster\\.((?:([^.]+)~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.custom_hash" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:([^.]+)\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service_subset" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.namespace" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.datacenter" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.consul\\.)", + "tag_name": "consul.routing_type" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.consul\\.)", + "tag_name": "consul.trust_domain" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.target" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+)\\.consul\\.)", + "tag_name": "consul.full_target" + }, + { + "tag_name": "local_cluster", + "fixed_value": "test-proxy" + } + ], + "use_all_default_tags": true + }, "dynamic_resources": { - "lds_config": { "ads": {} }, - "cds_config": { "ads": {} }, + "lds_config": { + "ads": {} + }, + "cds_config": { + "ads": {} + }, "ads_config": { "api_type": "GRPC", "grpc_services": { diff --git a/command/connect/envoy/testdata/token-file-env.golden b/command/connect/envoy/testdata/token-file-env.golden index 75014d50b5..13c803cc73 100644 --- a/command/connect/envoy/testdata/token-file-env.golden +++ b/command/connect/envoy/testdata/token-file-env.golden @@ -19,27 +19,69 @@ "connect_timeout": "1s", "type": "STATIC", "http2_protocol_options": {}, - "hosts": [{ + "hosts": [ + { "socket_address": { "address": "127.0.0.1", "port_value": 8502 } - }] + } + ] } ] }, "stats_config": { - "stats_tags": [ - { - "tag_name": "local_cluster", - "fixed_value": "test-proxy" - } - ], - "use_all_default_tags": true - }, + "stats_tags": [ + { + "regex": "^cluster\\.((?:([^.]+)~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.custom_hash" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:([^.]+)\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service_subset" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.namespace" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.datacenter" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.consul\\.)", + "tag_name": "consul.routing_type" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.consul\\.)", + "tag_name": "consul.trust_domain" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.target" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+)\\.consul\\.)", + "tag_name": "consul.full_target" + }, + { + "tag_name": "local_cluster", + "fixed_value": "test-proxy" + } + ], + "use_all_default_tags": true + }, "dynamic_resources": { - "lds_config": { "ads": {} }, - "cds_config": { "ads": {} }, + "lds_config": { + "ads": {} + }, + "cds_config": { + "ads": {} + }, "ads_config": { "api_type": "GRPC", "grpc_services": { diff --git a/command/connect/envoy/testdata/zipkin-tracing-config.golden b/command/connect/envoy/testdata/zipkin-tracing-config.golden index 71cdf2ec7d..fbff4b3e84 100644 --- a/command/connect/envoy/testdata/zipkin-tracing-config.golden +++ b/command/connect/envoy/testdata/zipkin-tracing-config.golden @@ -19,60 +19,102 @@ "connect_timeout": "1s", "type": "STATIC", "http2_protocol_options": {}, - "hosts": [{ + "hosts": [ + { "socket_address": { "address": "127.0.0.1", "port_value": 8502 } - }] + } + ] }, { - "name": "zipkin", - "type": "STRICT_DNS", - "connect_timeout": "5s", - "load_assignment": { - "cluster_name": "zipkin", - "endpoints": [ - { - "lb_endpoints": [ - { - "endpoint": { - "address": { - "socket_address": { - "address": "zipkin.service.consul", - "port_value": 9411 - } - } - } - } - ] - } - ] - } - } + "name": "zipkin", + "type": "STRICT_DNS", + "connect_timeout": "5s", + "load_assignment": { + "cluster_name": "zipkin", + "endpoints": [ + { + "lb_endpoints": [ + { + "endpoint": { + "address": { + "socket_address": { + "address": "zipkin.service.consul", + "port_value": 9411 + } + } + } + } + ] + } + ] + } + } ] }, "stats_config": { - "stats_tags": [ - { - "tag_name": "local_cluster", - "fixed_value": "test-proxy" - } - ], - "use_all_default_tags": true - }, + "stats_tags": [ + { + "regex": "^cluster\\.((?:([^.]+)~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.custom_hash" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:([^.]+)\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service_subset" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.service" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.namespace" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.datacenter" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.[^.]+\\.consul\\.)", + "tag_name": "consul.routing_type" + }, + { + "regex": "^cluster\\.((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.([^.]+)\\.consul\\.)", + "tag_name": "consul.trust_domain" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+)\\.[^.]+\\.[^.]+\\.consul\\.)", + "tag_name": "consul.target" + }, + { + "regex": "^cluster\\.(((?:[^.]+~)?(?:[^.]+\\.)?[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+)\\.consul\\.)", + "tag_name": "consul.full_target" + }, + { + "tag_name": "local_cluster", + "fixed_value": "test-proxy" + } + ], + "use_all_default_tags": true + }, "tracing": { - "http": { - "name": "envoy.zipkin", - "config": { - "collector_cluster": "zipkin", - "collector_endpoint": "/api/v1/spans" - } - } - }, + "http": { + "name": "envoy.zipkin", + "config": { + "collector_cluster": "zipkin", + "collector_endpoint": "/api/v1/spans" + } + } + }, "dynamic_resources": { - "lds_config": { "ads": {} }, - "cds_config": { "ads": {} }, + "lds_config": { + "ads": {} + }, + "cds_config": { + "ads": {} + }, "ads_config": { "api_type": "GRPC", "grpc_services": { diff --git a/test/integration/connect/envoy/case-dogstatsd-udp/verify.bats b/test/integration/connect/envoy/case-dogstatsd-udp/verify.bats index 9afca9cedb..463f146b2b 100644 --- a/test/integration/connect/envoy/case-dogstatsd-udp/verify.bats +++ b/test/integration/connect/envoy/case-dogstatsd-udp/verify.bats @@ -16,7 +16,7 @@ load helpers @test "s1 upstream should have healthy endpoints for s2" { # protocol is configured in an upstream override so the cluster name is customized here - assert_upstream_has_endpoints_in_status 127.0.0.1:19000 1a47f6e1:s2.default.primary HEALTHY 1 + assert_upstream_has_endpoints_in_status 127.0.0.1:19000 1a47f6e1~s2.default.primary HEALTHY 1 } @test "s1 upstream should be able to connect to s2" { @@ -48,7 +48,7 @@ load helpers } @test "s1 proxy should be adding cluster name as a tag" { - run retry_default must_match_in_statsd_logs '[#,]envoy.cluster_name:1a47f6e1_s2(,|$)' primary + run retry_default must_match_in_statsd_logs '[#,]envoy.cluster_name:1a47f6e1~s2(,|$)' primary echo "OUTPUT: $output" diff --git a/test/integration/connect/envoy/case-gateways-local/primary/verify.bats b/test/integration/connect/envoy/case-gateways-local/primary/verify.bats index 82face1364..aa156efa64 100644 --- a/test/integration/connect/envoy/case-gateways-local/primary/verify.bats +++ b/test/integration/connect/envoy/case-gateways-local/primary/verify.bats @@ -20,7 +20,7 @@ load helpers @test "s1 upstream should have healthy endpoints for s2" { # mesh gateway mode is configured in an upstream override so the cluster name is customized here - assert_upstream_has_endpoints_in_status 127.0.0.1:19000 c225dc1c:s2.default.secondary HEALTHY 1 + assert_upstream_has_endpoints_in_status 127.0.0.1:19000 c225dc1c~s2.default.secondary HEALTHY 1 } @test "gateway-primary should have healthy endpoints for secondary" { @@ -34,7 +34,7 @@ load helpers } @test "s1 upstream made 1 connection" { - assert_envoy_metric 127.0.0.1:19000 "cluster.c225dc1c_s2.default.secondary.*cx_total" 1 + assert_envoy_metric 127.0.0.1:19000 "cluster.c225dc1c~s2.default.secondary.*cx_total" 1 } @test "gateway-primary is used for the upstream connection" { diff --git a/test/integration/connect/envoy/case-gateways-remote/primary/verify.bats b/test/integration/connect/envoy/case-gateways-remote/primary/verify.bats index ce4b64dba0..0b901781ee 100644 --- a/test/integration/connect/envoy/case-gateways-remote/primary/verify.bats +++ b/test/integration/connect/envoy/case-gateways-remote/primary/verify.bats @@ -16,7 +16,7 @@ load helpers @test "s1 upstream should have healthy endpoints for s2" { # mesh gateway mode is configured in an upstream override so the cluster name is customized here - assert_upstream_has_endpoints_in_status 127.0.0.1:19000 dd412229:s2.default.secondary HEALTHY 1 + assert_upstream_has_endpoints_in_status 127.0.0.1:19000 dd412229~s2.default.secondary HEALTHY 1 } @test "s1 upstream should be able to connect to s2" { @@ -26,5 +26,5 @@ load helpers } @test "s1 upstream made 1 connection" { - assert_envoy_metric 127.0.0.1:19000 "cluster.dd412229_s2.default.secondary.*cx_total" 1 + assert_envoy_metric 127.0.0.1:19000 "cluster.dd412229~s2.default.secondary.*cx_total" 1 } diff --git a/test/integration/connect/envoy/case-grpc/verify.bats b/test/integration/connect/envoy/case-grpc/verify.bats index 1c9acde879..7d0e900c0e 100644 --- a/test/integration/connect/envoy/case-grpc/verify.bats +++ b/test/integration/connect/envoy/case-grpc/verify.bats @@ -16,7 +16,7 @@ load helpers @test "s1 upstream should have healthy endpoints for s2" { # protocol is configured in an upstream override so the cluster name is customized here - assert_upstream_has_endpoints_in_status 127.0.0.1:19000 ef15b5b5:s2.default.primary HEALTHY 1 + assert_upstream_has_endpoints_in_status 127.0.0.1:19000 ef15b5b5~s2.default.primary HEALTHY 1 } @test "s1 upstream should be able to connect to s2 via grpc" { @@ -28,7 +28,7 @@ load helpers } @test "s1 proxy should be sending gRPC metrics to statsd" { - run retry_default must_match_in_statsd_logs 'envoy.cluster.default.primary.internal.*.consul.grpc.PingServer.total' + run retry_default must_match_in_statsd_logs 'envoy.cluster.grpc.PingServer.total.*[#,]local_cluster:s1(,|$)' echo "OUTPUT: $output" [ "$status" == 0 ] diff --git a/test/integration/connect/envoy/case-http-badauthz/verify.bats b/test/integration/connect/envoy/case-http-badauthz/verify.bats index d622698499..825a3ea0ec 100644 --- a/test/integration/connect/envoy/case-http-badauthz/verify.bats +++ b/test/integration/connect/envoy/case-http-badauthz/verify.bats @@ -24,7 +24,7 @@ load helpers @test "s1 upstream should have healthy endpoints for s2" { # protocol is configured in an upstream override so the cluster name is customized here - assert_upstream_has_endpoints_in_status 127.0.0.1:19000 1a47f6e1:s2.default.primary HEALTHY 1 + assert_upstream_has_endpoints_in_status 127.0.0.1:19000 1a47f6e1~s2.default.primary HEALTHY 1 } @test "s1 upstream should NOT be able to connect to s2" { diff --git a/test/integration/connect/envoy/case-http/verify.bats b/test/integration/connect/envoy/case-http/verify.bats index e0a75ca0bc..dfcdecb4f3 100644 --- a/test/integration/connect/envoy/case-http/verify.bats +++ b/test/integration/connect/envoy/case-http/verify.bats @@ -24,7 +24,7 @@ load helpers @test "s1 upstream should have healthy endpoints for s2" { # protocol is configured in an upstream override so the cluster name is customized here - assert_upstream_has_endpoints_in_status 127.0.0.1:19000 1a47f6e1:s2.default.primary HEALTHY 1 + assert_upstream_has_endpoints_in_status 127.0.0.1:19000 1a47f6e1~s2.default.primary HEALTHY 1 } @test "s1 upstream should be able to connect to s2 with http/1.1" { diff --git a/test/integration/connect/envoy/case-http2/verify.bats b/test/integration/connect/envoy/case-http2/verify.bats index 7062c487bd..ee2b7f8a23 100644 --- a/test/integration/connect/envoy/case-http2/verify.bats +++ b/test/integration/connect/envoy/case-http2/verify.bats @@ -24,7 +24,7 @@ load helpers @test "s1 upstream should have healthy endpoints for s2" { # protocol is configured in an upstream override so the cluster name is customized here - assert_upstream_has_endpoints_in_status 127.0.0.1:19000 49c19fe6:s2.default.primary HEALTHY 1 + assert_upstream_has_endpoints_in_status 127.0.0.1:19000 49c19fe6~s2.default.primary HEALTHY 1 } @test "s1 upstream should be able to connect to s2 via http2" { diff --git a/test/integration/connect/envoy/case-prometheus/verify.bats b/test/integration/connect/envoy/case-prometheus/verify.bats index ffa4fcf7e2..9c4606169d 100644 --- a/test/integration/connect/envoy/case-prometheus/verify.bats +++ b/test/integration/connect/envoy/case-prometheus/verify.bats @@ -24,7 +24,7 @@ load helpers @test "s1 upstream should have healthy endpoints for s2" { # protocol is configured in an upstream override so the cluster name is customized here - assert_upstream_has_endpoints_in_status 127.0.0.1:19000 1a47f6e1:s2.default.primary HEALTHY 1 + assert_upstream_has_endpoints_in_status 127.0.0.1:19000 1a47f6e1~s2.default.primary HEALTHY 1 } @test "s1 upstream should be able to connect to s2 with http/1.1" { diff --git a/test/integration/connect/envoy/case-statsd-udp/verify.bats b/test/integration/connect/envoy/case-statsd-udp/verify.bats index 093eb38195..05d37614a3 100644 --- a/test/integration/connect/envoy/case-statsd-udp/verify.bats +++ b/test/integration/connect/envoy/case-statsd-udp/verify.bats @@ -16,7 +16,7 @@ load helpers @test "s1 upstream should have healthy endpoints for s2" { # protocol is configured in an upstream override so the cluster name is customized here - assert_upstream_has_endpoints_in_status 127.0.0.1:19000 1a47f6e1:s2.default.primary HEALTHY 1 + assert_upstream_has_endpoints_in_status 127.0.0.1:19000 1a47f6e1~s2.default.primary HEALTHY 1 } @test "s1 upstream should be able to connect to s2" { diff --git a/test/integration/connect/envoy/case-zipkin/verify.bats b/test/integration/connect/envoy/case-zipkin/verify.bats index d56c3f1903..98f11056ef 100644 --- a/test/integration/connect/envoy/case-zipkin/verify.bats +++ b/test/integration/connect/envoy/case-zipkin/verify.bats @@ -24,7 +24,7 @@ load helpers @test "s1 upstream should have healthy endpoints for s2" { # protocol is configured in an upstream override so the cluster name is customized here - assert_upstream_has_endpoints_in_status 127.0.0.1:19000 1a47f6e1:s2.default.primary HEALTHY 1 + assert_upstream_has_endpoints_in_status 127.0.0.1:19000 1a47f6e1~s2.default.primary HEALTHY 1 } @test "s1 upstream should be able to connect to s2" {