diff --git a/.changelog/17327.txt b/.changelog/17327.txt new file mode 100644 index 000000000000..24b1c28c1dfd --- /dev/null +++ b/.changelog/17327.txt @@ -0,0 +1,3 @@ +```release-note:improvement + xds: rename envoy_hcp_metrics_bind_socket_dir to envoy_telemetry_collector_bind_socket_dir to remove HCP naming references. + ``` \ No newline at end of file diff --git a/agent/proxycfg/connect_proxy.go b/agent/proxycfg/connect_proxy.go index f070eb4685f8..e56d98d090aa 100644 --- a/agent/proxycfg/connect_proxy.go +++ b/agent/proxycfg/connect_proxy.go @@ -109,8 +109,8 @@ func (s *handlerConnectProxy) initialize(ctx context.Context) (ConfigSnapshot, e return snap, err } - if err := s.maybeInitializeHCPMetricsWatches(ctx, snap); err != nil { - return snap, fmt.Errorf("failed to initialize HCP metrics watches: %w", err) + if err := s.maybeInitializeTelemetryCollectorWatches(ctx, snap); err != nil { + return snap, fmt.Errorf("failed to initialize telemetry collector watches: %w", err) } if s.proxyCfg.Mode == structs.ProxyModeTransparent { @@ -625,16 +625,17 @@ func (s *handlerConnectProxy) handleUpdate(ctx context.Context, u UpdateEvent, s return nil } -// hcpMetricsConfig represents the basic opaque config values for pushing telemetry to HCP. -type hcpMetricsConfig struct { - // HCPMetricsBindSocketDir is a string that configures the directory for a +// telemetryCollectorConfig represents the basic opaque config values for pushing telemetry to +// a consul telemetry collector. +type telemetryCollectorConfig struct { + // TelemetryCollectorBindSocketDir is a string that configures the directory for a // unix socket where Envoy will forward metrics. These metrics get pushed to - // the HCP Metrics collector to show service mesh metrics on HCP. - HCPMetricsBindSocketDir string `mapstructure:"envoy_hcp_metrics_bind_socket_dir"` + // the Consul Telemetry collector. + TelemetryCollectorBindSocketDir string `mapstructure:"envoy_telemetry_collector_bind_socket_dir"` } -func parseHCPMetricsConfig(m map[string]interface{}) (hcpMetricsConfig, error) { - var cfg hcpMetricsConfig +func parseTelemetryCollectorConfig(m map[string]interface{}) (telemetryCollectorConfig, error) { + var cfg telemetryCollectorConfig err := mapstructure.WeakDecode(m, &cfg) if err != nil { @@ -644,21 +645,21 @@ func parseHCPMetricsConfig(m map[string]interface{}) (hcpMetricsConfig, error) { return cfg, nil } -// maybeInitializeHCPMetricsWatches will initialize a synthetic upstream and discovery chain -// watch for the HCP metrics collector, if metrics collection is enabled on the proxy registration. -func (s *handlerConnectProxy) maybeInitializeHCPMetricsWatches(ctx context.Context, snap ConfigSnapshot) error { - hcpCfg, err := parseHCPMetricsConfig(s.proxyCfg.Config) +// maybeInitializeTelemetryCollectorWatches will initialize a synthetic upstream and discovery chain +// watch for the consul telemetry collector, if telemetry data collection is enabled on the proxy registration. +func (s *handlerConnectProxy) maybeInitializeTelemetryCollectorWatches(ctx context.Context, snap ConfigSnapshot) error { + cfg, err := parseTelemetryCollectorConfig(s.proxyCfg.Config) if err != nil { s.logger.Error("failed to parse connect.proxy.config", "error", err) } - if hcpCfg.HCPMetricsBindSocketDir == "" { - // Metrics collection is not enabled, return early. + if cfg.TelemetryCollectorBindSocketDir == "" { + // telemetry collection is not enabled, return early. return nil } // The path includes the proxy ID so that when multiple proxies are on the same host - // they each have a distinct path to send their metrics. + // they each have a distinct path to send their telemetry data. id := s.proxyID.NamespaceOrDefault() + "_" + s.proxyID.ID // UNIX domain sockets paths have a max length of 108, so we take a hash of the compound ID @@ -666,12 +667,12 @@ func (s *handlerConnectProxy) maybeInitializeHCPMetricsWatches(ctx context.Conte h := sha1.New() h.Write([]byte(id)) hash := base64.RawURLEncoding.EncodeToString(h.Sum(nil)) - path := path.Join(hcpCfg.HCPMetricsBindSocketDir, hash+".sock") + path := path.Join(cfg.TelemetryCollectorBindSocketDir, hash+".sock") upstream := structs.Upstream{ DestinationNamespace: acl.DefaultNamespaceName, DestinationPartition: s.proxyID.PartitionOrDefault(), - DestinationName: api.HCPMetricsCollectorName, + DestinationName: api.TelemetryCollectorName, LocalBindSocketPath: path, Config: map[string]interface{}{ "protocol": "grpc", diff --git a/agent/proxycfg/state_test.go b/agent/proxycfg/state_test.go index ad00810987b7..7093a7126580 100644 --- a/agent/proxycfg/state_test.go +++ b/agent/proxycfg/state_test.go @@ -456,18 +456,18 @@ func TestState_WatchesAndUpdates(t *testing.T) { // Used to account for differences in OSS/ent implementations of ServiceID.String() var ( - db = structs.NewServiceName("db", nil) - billing = structs.NewServiceName("billing", nil) - api = structs.NewServiceName("api", nil) - apiA = structs.NewServiceName("api-a", nil) - hcpCollector = structs.NewServiceName(apimod.HCPMetricsCollectorName, nil) - - apiUID = NewUpstreamIDFromServiceName(api) - dbUID = NewUpstreamIDFromServiceName(db) - pqUID = UpstreamIDFromString("prepared_query:query") - extApiUID = NewUpstreamIDFromServiceName(apiA) - extDBUID = NewUpstreamIDFromServiceName(db) - hcpCollectorUID = NewUpstreamIDFromServiceName(hcpCollector) + db = structs.NewServiceName("db", nil) + billing = structs.NewServiceName("billing", nil) + api = structs.NewServiceName("api", nil) + apiA = structs.NewServiceName("api-a", nil) + telemetryCollector = structs.NewServiceName(apimod.TelemetryCollectorName, nil) + + apiUID = NewUpstreamIDFromServiceName(api) + dbUID = NewUpstreamIDFromServiceName(db) + pqUID = UpstreamIDFromString("prepared_query:query") + extApiUID = NewUpstreamIDFromServiceName(apiA) + extDBUID = NewUpstreamIDFromServiceName(db) + telemetryCollectorUID = NewUpstreamIDFromServiceName(telemetryCollector) ) // TODO(peering): NewUpstreamIDFromServiceName should take a PeerName extApiUID.Peer = "peer-a" @@ -3626,7 +3626,7 @@ func TestState_WatchesAndUpdates(t *testing.T) { }, }, }, - "hcp-metrics": { + "telemetry-collector": { ns: structs.NodeService{ Kind: structs.ServiceKindConnectProxy, ID: "web-sidecar-proxy", @@ -3636,7 +3636,7 @@ func TestState_WatchesAndUpdates(t *testing.T) { Proxy: structs.ConnectProxyConfig{ DestinationServiceName: "web", Config: map[string]interface{}{ - "envoy_hcp_metrics_bind_socket_dir": "/tmp/consul/hcp-metrics/", + "envoy_telemetry_collector_bind_socket_dir": "/tmp/consul/telemetry-collector/", }, }, }, @@ -3644,8 +3644,8 @@ func TestState_WatchesAndUpdates(t *testing.T) { stages: []verificationStage{ { requiredWatches: map[string]verifyWatchRequest{ - fmt.Sprintf("discovery-chain:%s", hcpCollectorUID.String()): genVerifyDiscoveryChainWatch(&structs.DiscoveryChainRequest{ - Name: hcpCollector.Name, + fmt.Sprintf("discovery-chain:%s", telemetryCollectorUID.String()): genVerifyDiscoveryChainWatch(&structs.DiscoveryChainRequest{ + Name: telemetryCollector.Name, EvaluateInDatacenter: "dc1", EvaluateInNamespace: "default", EvaluateInPartition: "default", @@ -3686,9 +3686,9 @@ func TestState_WatchesAndUpdates(t *testing.T) { Result: &structs.ConfigEntryResponse{}, }, { - CorrelationID: fmt.Sprintf("discovery-chain:%s", hcpCollectorUID.String()), + CorrelationID: fmt.Sprintf("discovery-chain:%s", telemetryCollectorUID.String()), Result: &structs.DiscoveryChainResponse{ - Chain: discoverychain.TestCompileConfigEntries(t, hcpCollector.Name, "default", "default", "dc1", "trustdomain.consul", nil), + Chain: discoverychain.TestCompileConfigEntries(t, telemetryCollector.Name, "default", "default", "dc1", "trustdomain.consul", nil), }, Err: nil, }, @@ -3698,19 +3698,19 @@ func TestState_WatchesAndUpdates(t *testing.T) { require.Equal(t, indexedRoots, snap.Roots) require.Equal(t, issuedCert, snap.ConnectProxy.Leaf) - // An event was received with the HCP collector's discovery chain, which sets up some bookkeeping in the snapshot. + // An event was received with the telemetry collector's discovery chain, which sets up some bookkeeping in the snapshot. require.Len(t, snap.ConnectProxy.DiscoveryChain, 1, "%+v", snap.ConnectProxy.DiscoveryChain) - require.Contains(t, snap.ConnectProxy.DiscoveryChain, hcpCollectorUID) + require.Contains(t, snap.ConnectProxy.DiscoveryChain, telemetryCollectorUID) require.Len(t, snap.ConnectProxy.WatchedUpstreams, 1, "%+v", snap.ConnectProxy.WatchedUpstreams) require.Len(t, snap.ConnectProxy.WatchedUpstreamEndpoints, 1, "%+v", snap.ConnectProxy.WatchedUpstreamEndpoints) - require.Contains(t, snap.ConnectProxy.WatchedUpstreamEndpoints, hcpCollectorUID) + require.Contains(t, snap.ConnectProxy.WatchedUpstreamEndpoints, telemetryCollectorUID) expectUpstream := structs.Upstream{ DestinationNamespace: "default", DestinationPartition: "default", - DestinationName: apimod.HCPMetricsCollectorName, - LocalBindSocketPath: "/tmp/consul/hcp-metrics/gqmuzdHCUPAEY5mbF8vgkZCNI14.sock", + DestinationName: apimod.TelemetryCollectorName, + LocalBindSocketPath: "/tmp/consul/telemetry-collector/gqmuzdHCUPAEY5mbF8vgkZCNI14.sock", Config: map[string]interface{}{ "protocol": "grpc", }, @@ -3721,16 +3721,16 @@ func TestState_WatchesAndUpdates(t *testing.T) { require.Equal(t, &expectUpstream, snap.ConnectProxy.UpstreamConfig[uid]) // No endpoints have arrived yet. - require.Len(t, snap.ConnectProxy.WatchedUpstreamEndpoints[hcpCollectorUID], 0, "%+v", snap.ConnectProxy.WatchedUpstreamEndpoints) + require.Len(t, snap.ConnectProxy.WatchedUpstreamEndpoints[telemetryCollectorUID], 0, "%+v", snap.ConnectProxy.WatchedUpstreamEndpoints) }, }, { requiredWatches: map[string]verifyWatchRequest{ - fmt.Sprintf("upstream-target:%s.default.default.dc1:", apimod.HCPMetricsCollectorName) + hcpCollectorUID.String(): genVerifyServiceSpecificRequest(apimod.HCPMetricsCollectorName, "", "dc1", true), + fmt.Sprintf("upstream-target:%s.default.default.dc1:", apimod.TelemetryCollectorName) + telemetryCollectorUID.String(): genVerifyServiceSpecificRequest(apimod.TelemetryCollectorName, "", "dc1", true), }, events: []UpdateEvent{ { - CorrelationID: fmt.Sprintf("upstream-target:%s.default.default.dc1:", apimod.HCPMetricsCollectorName) + hcpCollectorUID.String(), + CorrelationID: fmt.Sprintf("upstream-target:%s.default.default.dc1:", apimod.TelemetryCollectorName) + telemetryCollectorUID.String(), Result: &structs.IndexedCheckServiceNodes{ Nodes: structs.CheckServiceNodes{ { @@ -3739,8 +3739,8 @@ func TestState_WatchesAndUpdates(t *testing.T) { Address: "10.0.0.1", }, Service: &structs.NodeService{ - ID: apimod.HCPMetricsCollectorName, - Service: apimod.HCPMetricsCollectorName, + ID: apimod.TelemetryCollectorName, + Service: apimod.TelemetryCollectorName, Port: 8080, }, }, @@ -3754,16 +3754,16 @@ func TestState_WatchesAndUpdates(t *testing.T) { require.Equal(t, indexedRoots, snap.Roots) require.Equal(t, issuedCert, snap.ConnectProxy.Leaf) - // Discovery chain for the HCP collector should still be stored in the snapshot. + // Discovery chain for the telemetry collector should still be stored in the snapshot. require.Len(t, snap.ConnectProxy.DiscoveryChain, 1, "%+v", snap.ConnectProxy.DiscoveryChain) - require.Contains(t, snap.ConnectProxy.DiscoveryChain, hcpCollectorUID) + require.Contains(t, snap.ConnectProxy.DiscoveryChain, telemetryCollectorUID) require.Len(t, snap.ConnectProxy.WatchedUpstreams, 1, "%+v", snap.ConnectProxy.WatchedUpstreams) require.Len(t, snap.ConnectProxy.WatchedUpstreamEndpoints, 1, "%+v", snap.ConnectProxy.WatchedUpstreamEndpoints) - require.Contains(t, snap.ConnectProxy.WatchedUpstreamEndpoints, hcpCollectorUID) + require.Contains(t, snap.ConnectProxy.WatchedUpstreamEndpoints, telemetryCollectorUID) - // An endpoint arrived for the HCP collector, so it should be present in the snapshot. - require.Len(t, snap.ConnectProxy.WatchedUpstreamEndpoints[hcpCollectorUID], 1, "%+v", snap.ConnectProxy.WatchedUpstreamEndpoints) + // An endpoint arrived for the telemetry collector, so it should be present in the snapshot. + require.Len(t, snap.ConnectProxy.WatchedUpstreamEndpoints[telemetryCollectorUID], 1, "%+v", snap.ConnectProxy.WatchedUpstreamEndpoints) nodes := structs.CheckServiceNodes{ { @@ -3772,14 +3772,14 @@ func TestState_WatchesAndUpdates(t *testing.T) { Address: "10.0.0.1", }, Service: &structs.NodeService{ - ID: apimod.HCPMetricsCollectorName, - Service: apimod.HCPMetricsCollectorName, + ID: apimod.TelemetryCollectorName, + Service: apimod.TelemetryCollectorName, Port: 8080, }, }, } - target := fmt.Sprintf("%s.default.default.dc1", apimod.HCPMetricsCollectorName) - require.Equal(t, nodes, snap.ConnectProxy.WatchedUpstreamEndpoints[hcpCollectorUID][target]) + target := fmt.Sprintf("%s.default.default.dc1", apimod.TelemetryCollectorName) + require.Equal(t, nodes, snap.ConnectProxy.WatchedUpstreamEndpoints[telemetryCollectorUID][target]) }, }, }, diff --git a/agent/proxycfg/testing_connect_proxy.go b/agent/proxycfg/testing_connect_proxy.go index 5624a36e647b..73c3f8cc90e3 100644 --- a/agent/proxycfg/testing_connect_proxy.go +++ b/agent/proxycfg/testing_connect_proxy.go @@ -299,19 +299,19 @@ func TestConfigSnapshotGRPCExposeHTTP1(t testing.T) *ConfigSnapshot { }) } -// TestConfigSnapshotDiscoveryChain returns a fully populated snapshot using a discovery chain -func TestConfigSnapshotHCPMetrics(t testing.T) *ConfigSnapshot { +// TestConfigSnapshotTelemetryCollector returns a fully populated snapshot using a discovery chain +func TestConfigSnapshotTelemetryCollector(t testing.T) *ConfigSnapshot { // DiscoveryChain without an UpstreamConfig should yield a // filter chain when in transparent proxy mode var ( - collector = structs.NewServiceName(api.HCPMetricsCollectorName, nil) + collector = structs.NewServiceName(api.TelemetryCollectorName, nil) collectorUID = NewUpstreamIDFromServiceName(collector) - collectorChain = discoverychain.TestCompileConfigEntries(t, api.HCPMetricsCollectorName, "default", "default", "dc1", connect.TestClusterID+".consul", nil) + collectorChain = discoverychain.TestCompileConfigEntries(t, api.TelemetryCollectorName, "default", "default", "dc1", connect.TestClusterID+".consul", nil) ) return TestConfigSnapshot(t, func(ns *structs.NodeService) { ns.Proxy.Config = map[string]interface{}{ - "envoy_hcp_metrics_bind_socket_dir": "/tmp/consul/hcp-metrics", + "envoy_telemetry_collector_bind_socket_dir": "/tmp/consul/telemetry-collector", } }, []UpdateEvent{ { @@ -327,7 +327,7 @@ func TestConfigSnapshotHCPMetrics(t testing.T) *ConfigSnapshot { }, }, { - CorrelationID: fmt.Sprintf("upstream-target:%s.default.default.dc1:", api.HCPMetricsCollectorName) + collectorUID.String(), + CorrelationID: fmt.Sprintf("upstream-target:%s.default.default.dc1:", api.TelemetryCollectorName) + collectorUID.String(), Result: &structs.IndexedCheckServiceNodes{ Nodes: []structs.CheckServiceNode{ { @@ -336,7 +336,7 @@ func TestConfigSnapshotHCPMetrics(t testing.T) *ConfigSnapshot { Datacenter: "dc1", }, Service: &structs.NodeService{ - Service: api.HCPMetricsCollectorName, + Service: api.TelemetryCollectorName, Address: "9.9.9.9", Port: 9090, }, diff --git a/agent/xds/resources_test.go b/agent/xds/resources_test.go index 1f9b99274bdd..ede737eae812 100644 --- a/agent/xds/resources_test.go +++ b/agent/xds/resources_test.go @@ -169,8 +169,8 @@ func TestAllResourcesFromSnapshot(t *testing.T) { create: proxycfg.TestConfigSnapshotPeeringLocalMeshGateway, }, { - name: "hcp-metrics", - create: proxycfg.TestConfigSnapshotHCPMetrics, + name: "telemetry-collector", + create: proxycfg.TestConfigSnapshotTelemetryCollector, }, } tests = append(tests, getConnectProxyTransparentProxyGoldenTestCases()...) diff --git a/agent/xds/testdata/clusters/hcp-metrics.latest.golden b/agent/xds/testdata/clusters/telemetry-collector.latest.golden similarity index 96% rename from agent/xds/testdata/clusters/hcp-metrics.latest.golden rename to agent/xds/testdata/clusters/telemetry-collector.latest.golden index 441763f1a925..0f936dbf4e93 100644 --- a/agent/xds/testdata/clusters/hcp-metrics.latest.golden +++ b/agent/xds/testdata/clusters/telemetry-collector.latest.golden @@ -3,8 +3,8 @@ "resources": [ { "@type": "type.googleapis.com/envoy.config.cluster.v3.Cluster", - "name": "db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", - "altStatName": "db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", + "name": "consul-telemetry-collector.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", + "altStatName": "consul-telemetry-collector.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", "type": "EDS", "edsClusterConfig": { "edsConfig": { @@ -14,6 +14,14 @@ }, "connectTimeout": "5s", "circuitBreakers": {}, + "typedExtensionProtocolOptions": { + "envoy.extensions.upstreams.http.v3.HttpProtocolOptions": { + "@type": "type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions", + "explicitHttpConfig": { + "http2ProtocolOptions": {} + } + } + }, "outlierDetection": {}, "commonLbConfig": { "healthyPanicThreshold": {} @@ -40,18 +48,19 @@ }, "matchSubjectAltNames": [ { - "exact": "spiffe://11111111-2222-3333-4444-555555555555.consul/ns/default/dc/dc1/svc/db" + "exact": "spiffe://11111111-2222-3333-4444-555555555555.consul/ns/default/dc/dc1/svc/consul-telemetry-collector" } ] } }, - "sni": "db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul" + "sni": "consul-telemetry-collector.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul" } } }, { "@type": "type.googleapis.com/envoy.config.cluster.v3.Cluster", - "name": "geo-cache.default.dc1.query.11111111-2222-3333-4444-555555555555.consul", + "name": "db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", + "altStatName": "db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", "type": "EDS", "edsClusterConfig": { "edsConfig": { @@ -62,6 +71,9 @@ "connectTimeout": "5s", "circuitBreakers": {}, "outlierDetection": {}, + "commonLbConfig": { + "healthyPanicThreshold": {} + }, "transportSocket": { "name": "tls", "typedConfig": { @@ -84,22 +96,18 @@ }, "matchSubjectAltNames": [ { - "exact": "spiffe://11111111-2222-3333-4444-555555555555.consul/ns/default/dc/dc1/svc/geo-cache-target" - }, - { - "exact": "spiffe://11111111-2222-3333-4444-555555555555.consul/ns/default/dc/dc2/svc/geo-cache-target" + "exact": "spiffe://11111111-2222-3333-4444-555555555555.consul/ns/default/dc/dc1/svc/db" } ] } }, - "sni": "geo-cache.default.dc1.query.11111111-2222-3333-4444-555555555555.consul" + "sni": "db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul" } } }, { "@type": "type.googleapis.com/envoy.config.cluster.v3.Cluster", - "name": "hcp-metrics-collector.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", - "altStatName": "hcp-metrics-collector.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", + "name": "geo-cache.default.dc1.query.11111111-2222-3333-4444-555555555555.consul", "type": "EDS", "edsClusterConfig": { "edsConfig": { @@ -109,18 +117,7 @@ }, "connectTimeout": "5s", "circuitBreakers": {}, - "typedExtensionProtocolOptions": { - "envoy.extensions.upstreams.http.v3.HttpProtocolOptions": { - "@type": "type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions", - "explicitHttpConfig": { - "http2ProtocolOptions": {} - } - } - }, "outlierDetection": {}, - "commonLbConfig": { - "healthyPanicThreshold": {} - }, "transportSocket": { "name": "tls", "typedConfig": { @@ -143,12 +140,15 @@ }, "matchSubjectAltNames": [ { - "exact": "spiffe://11111111-2222-3333-4444-555555555555.consul/ns/default/dc/dc1/svc/hcp-metrics-collector" + "exact": "spiffe://11111111-2222-3333-4444-555555555555.consul/ns/default/dc/dc1/svc/geo-cache-target" + }, + { + "exact": "spiffe://11111111-2222-3333-4444-555555555555.consul/ns/default/dc/dc2/svc/geo-cache-target" } ] } }, - "sni": "hcp-metrics-collector.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul" + "sni": "geo-cache.default.dc1.query.11111111-2222-3333-4444-555555555555.consul" } } }, diff --git a/agent/xds/testdata/endpoints/hcp-metrics.latest.golden b/agent/xds/testdata/endpoints/hcp-metrics.latest.golden deleted file mode 100644 index a19ac95f210f..000000000000 --- a/agent/xds/testdata/endpoints/hcp-metrics.latest.golden +++ /dev/null @@ -1,97 +0,0 @@ -{ - "versionInfo": "00000001", - "resources": [ - { - "@type": "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment", - "clusterName": "db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", - "endpoints": [ - { - "lbEndpoints": [ - { - "endpoint": { - "address": { - "socketAddress": { - "address": "10.10.1.1", - "portValue": 8080 - } - } - }, - "healthStatus": "HEALTHY", - "loadBalancingWeight": 1 - }, - { - "endpoint": { - "address": { - "socketAddress": { - "address": "10.10.1.2", - "portValue": 8080 - } - } - }, - "healthStatus": "HEALTHY", - "loadBalancingWeight": 1 - } - ] - } - ] - }, - { - "@type": "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment", - "clusterName": "geo-cache.default.dc1.query.11111111-2222-3333-4444-555555555555.consul", - "endpoints": [ - { - "lbEndpoints": [ - { - "endpoint": { - "address": { - "socketAddress": { - "address": "10.10.1.1", - "portValue": 8080 - } - } - }, - "healthStatus": "HEALTHY", - "loadBalancingWeight": 1 - }, - { - "endpoint": { - "address": { - "socketAddress": { - "address": "10.20.1.2", - "portValue": 8080 - } - } - }, - "healthStatus": "HEALTHY", - "loadBalancingWeight": 1 - } - ] - } - ] - }, - { - "@type": "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment", - "clusterName": "hcp-metrics-collector.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", - "endpoints": [ - { - "lbEndpoints": [ - { - "endpoint": { - "address": { - "socketAddress": { - "address": "9.9.9.9", - "portValue": 9090 - } - } - }, - "healthStatus": "HEALTHY", - "loadBalancingWeight": 1 - } - ] - } - ] - } - ], - "typeUrl": "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment", - "nonce": "00000001" -} \ No newline at end of file diff --git a/agent/xds/testdata/endpoints/telemetry-collector.latest.golden b/agent/xds/testdata/endpoints/telemetry-collector.latest.golden new file mode 100644 index 000000000000..fb14b9d3a86b --- /dev/null +++ b/agent/xds/testdata/endpoints/telemetry-collector.latest.golden @@ -0,0 +1,97 @@ +{ + "versionInfo": "00000001", + "resources": [ + { + "@type": "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment", + "clusterName": "consul-telemetry-collector.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", + "endpoints": [ + { + "lbEndpoints": [ + { + "endpoint": { + "address": { + "socketAddress": { + "address": "9.9.9.9", + "portValue": 9090 + } + } + }, + "healthStatus": "HEALTHY", + "loadBalancingWeight": 1 + } + ] + } + ] + }, + { + "@type": "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment", + "clusterName": "db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", + "endpoints": [ + { + "lbEndpoints": [ + { + "endpoint": { + "address": { + "socketAddress": { + "address": "10.10.1.1", + "portValue": 8080 + } + } + }, + "healthStatus": "HEALTHY", + "loadBalancingWeight": 1 + }, + { + "endpoint": { + "address": { + "socketAddress": { + "address": "10.10.1.2", + "portValue": 8080 + } + } + }, + "healthStatus": "HEALTHY", + "loadBalancingWeight": 1 + } + ] + } + ] + }, + { + "@type": "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment", + "clusterName": "geo-cache.default.dc1.query.11111111-2222-3333-4444-555555555555.consul", + "endpoints": [ + { + "lbEndpoints": [ + { + "endpoint": { + "address": { + "socketAddress": { + "address": "10.10.1.1", + "portValue": 8080 + } + } + }, + "healthStatus": "HEALTHY", + "loadBalancingWeight": 1 + }, + { + "endpoint": { + "address": { + "socketAddress": { + "address": "10.20.1.2", + "portValue": 8080 + } + } + }, + "healthStatus": "HEALTHY", + "loadBalancingWeight": 1 + } + ] + } + ] + } + ], + "typeUrl": "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment", + "nonce": "00000001" +} \ No newline at end of file diff --git a/agent/xds/testdata/listeners/hcp-metrics.latest.golden b/agent/xds/testdata/listeners/telemetry-collector.latest.golden similarity index 93% rename from agent/xds/testdata/listeners/hcp-metrics.latest.golden rename to agent/xds/testdata/listeners/telemetry-collector.latest.golden index c1e0d04734a3..b97f7e043854 100644 --- a/agent/xds/testdata/listeners/hcp-metrics.latest.golden +++ b/agent/xds/testdata/listeners/telemetry-collector.latest.golden @@ -3,35 +3,10 @@ "resources": [ { "@type": "type.googleapis.com/envoy.config.listener.v3.Listener", - "name": "db:127.0.0.1:9191", - "address": { - "socketAddress": { - "address": "127.0.0.1", - "portValue": 9191 - } - }, - "filterChains": [ - { - "filters": [ - { - "name": "envoy.filters.network.tcp_proxy", - "typedConfig": { - "@type": "type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy", - "statPrefix": "upstream.db.default.default.dc1", - "cluster": "db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul" - } - } - ] - } - ], - "trafficDirection": "OUTBOUND" - }, - { - "@type": "type.googleapis.com/envoy.config.listener.v3.Listener", - "name": "hcp-metrics-collector:/tmp/consul/hcp-metrics/gqmuzdHCUPAEY5mbF8vgkZCNI14.sock", + "name": "consul-telemetry-collector:/tmp/consul/telemetry-collector/gqmuzdHCUPAEY5mbF8vgkZCNI14.sock", "address": { "pipe": { - "path": "/tmp/consul/hcp-metrics/gqmuzdHCUPAEY5mbF8vgkZCNI14.sock" + "path": "/tmp/consul/telemetry-collector/gqmuzdHCUPAEY5mbF8vgkZCNI14.sock" } }, "filterChains": [ @@ -41,12 +16,12 @@ "name": "envoy.filters.network.http_connection_manager", "typedConfig": { "@type": "type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager", - "statPrefix": "upstream.hcp-metrics-collector.default.default.dc1", + "statPrefix": "upstream.consul-telemetry-collector.default.default.dc1", "routeConfig": { - "name": "hcp-metrics-collector", + "name": "consul-telemetry-collector", "virtualHosts": [ { - "name": "hcp-metrics-collector.default.default.dc1", + "name": "consul-telemetry-collector.default.default.dc1", "domains": [ "*" ], @@ -56,7 +31,7 @@ "prefix": "/" }, "route": { - "cluster": "hcp-metrics-collector.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul" + "cluster": "consul-telemetry-collector.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul" } } ] @@ -95,6 +70,31 @@ ], "trafficDirection": "OUTBOUND" }, + { + "@type": "type.googleapis.com/envoy.config.listener.v3.Listener", + "name": "db:127.0.0.1:9191", + "address": { + "socketAddress": { + "address": "127.0.0.1", + "portValue": 9191 + } + }, + "filterChains": [ + { + "filters": [ + { + "name": "envoy.filters.network.tcp_proxy", + "typedConfig": { + "@type": "type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy", + "statPrefix": "upstream.db.default.default.dc1", + "cluster": "db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul" + } + } + ] + } + ], + "trafficDirection": "OUTBOUND" + }, { "@type": "type.googleapis.com/envoy.config.listener.v3.Listener", "name": "prepared_query:geo-cache:127.10.10.10:8181", diff --git a/agent/xds/testdata/routes/hcp-metrics.latest.golden b/agent/xds/testdata/routes/telemetry-collector.latest.golden similarity index 100% rename from agent/xds/testdata/routes/hcp-metrics.latest.golden rename to agent/xds/testdata/routes/telemetry-collector.latest.golden diff --git a/agent/xds/testdata/secrets/hcp-metrics.latest.golden b/agent/xds/testdata/secrets/telemetry-collector.latest.golden similarity index 100% rename from agent/xds/testdata/secrets/hcp-metrics.latest.golden rename to agent/xds/testdata/secrets/telemetry-collector.latest.golden diff --git a/api/connect.go b/api/connect.go index a5298d81369b..1c1da9a37980 100644 --- a/api/connect.go +++ b/api/connect.go @@ -1,7 +1,7 @@ package api -// HCPMetricsCollectorName is the service name for the HCP Metrics Collector -const HCPMetricsCollectorName string = "hcp-metrics-collector" +// TelemetryCollectorName is the service name for the Consul Telemetry Collector +const TelemetryCollectorName string = "consul-telemetry-collector" // Connect can be used to work with endpoints related to Connect, the // feature for securely connecting services within Consul. diff --git a/command/connect/envoy/bootstrap_config.go b/command/connect/envoy/bootstrap_config.go index 6db0d7a11117..91ce869a0f20 100644 --- a/command/connect/envoy/bootstrap_config.go +++ b/command/connect/envoy/bootstrap_config.go @@ -52,10 +52,10 @@ type BootstrapConfig struct { // stats_config.stats_tags can be made by overriding envoy_stats_config_json. StatsTags []string `mapstructure:"envoy_stats_tags"` - // HCPMetricsBindSocketDir is a string that configures the directory for a + // TelemetryCollectorBindSocketDir is a string that configures the directory for a // unix socket where Envoy will forward metrics. These metrics get pushed to - // the HCP Metrics collector to show service mesh metrics on HCP. - HCPMetricsBindSocketDir string `mapstructure:"envoy_hcp_metrics_bind_socket_dir"` + // the telemetry collector. + TelemetryCollectorBindSocketDir string `mapstructure:"envoy_telemetry_collector_bind_socket_dir"` // PrometheusBindAddr configures an : on which the Envoy will listen // and expose a single /metrics HTTP endpoint for Prometheus to scrape. It @@ -246,9 +246,9 @@ func (c *BootstrapConfig) ConfigureArgs(args *BootstrapTplArgs, omitDeprecatedTa args.StatsFlushInterval = c.StatsFlushInterval } - // Setup HCP Metrics if needed. This MUST happen after the Static*JSON is set above - if c.HCPMetricsBindSocketDir != "" { - appendHCPMetricsConfig(args, c.HCPMetricsBindSocketDir) + // Setup telemetry collector if needed. This MUST happen after the Static*JSON is set above + if c.TelemetryCollectorBindSocketDir != "" { + appendTelemetryCollectorConfig(args, c.TelemetryCollectorBindSocketDir) } return nil @@ -809,16 +809,16 @@ func (c *BootstrapConfig) generateListenerConfig(args *BootstrapTplArgs, bindAdd return nil } -// appendHCPMetricsConfig generates config to enable a socket at path: /.sock +// appendTelemetryCollectorConfig generates config to enable a socket at path: /.sock // We take the hash of the compound proxy ID for a few reasons: // // - The proxy ID is included because this socket path must be unique per proxy. Each Envoy proxy will ship -// its metrics to HCP using its own loopback listener at this path. +// its metrics to the collector using its own loopback listener at this path. // // - The hash is needed because UNIX domain socket paths must be less than 104 characters. By using a b64 encoded // SHA1 hash we end up with 27 chars for the name, 5 chars for the extension, and the remainder is saved for // the configurable socket dir. The length of the directory's path is validated on writes to avoid going over. -func appendHCPMetricsConfig(args *BootstrapTplArgs, hcpMetricsBindSocketDir string) { +func appendTelemetryCollectorConfig(args *BootstrapTplArgs, telemetryCollectorBindSocketDir string) { // Normalize namespace to "default". This ensures we match the namespace behaviour in proxycfg package, // where a dynamic listener will be created at the same socket path via xDS. ns := args.Namespace @@ -830,7 +830,7 @@ func appendHCPMetricsConfig(args *BootstrapTplArgs, hcpMetricsBindSocketDir stri h := sha1.New() h.Write([]byte(id)) hash := base64.RawURLEncoding.EncodeToString(h.Sum(nil)) - path := path.Join(hcpMetricsBindSocketDir, hash+".sock") + path := path.Join(telemetryCollectorBindSocketDir, hash+".sock") if args.StatsSinksJSON != "" { args.StatsSinksJSON += ",\n" @@ -842,7 +842,7 @@ func appendHCPMetricsConfig(args *BootstrapTplArgs, hcpMetricsBindSocketDir stri "transport_api_version": "V3", "grpc_service": { "envoy_grpc": { - "cluster_name": "hcp_metrics_collector" + "cluster_name": "consul_telemetry_collector_loopback" } } } @@ -852,11 +852,11 @@ func appendHCPMetricsConfig(args *BootstrapTplArgs, hcpMetricsBindSocketDir stri args.StaticClustersJSON += ",\n" } args.StaticClustersJSON += fmt.Sprintf(`{ - "name": "hcp_metrics_collector", + "name": "consul_telemetry_collector_loopback", "type": "STATIC", "http2_protocol_options": {}, "loadAssignment": { - "clusterName": "hcp_metrics_collector", + "clusterName": "consul_telemetry_collector_loopback", "endpoints": [ { "lbEndpoints": [ diff --git a/command/connect/envoy/bootstrap_config_test.go b/command/connect/envoy/bootstrap_config_test.go index c7103fb1892c..7ab6a273fec5 100644 --- a/command/connect/envoy/bootstrap_config_test.go +++ b/command/connect/envoy/bootstrap_config_test.go @@ -527,25 +527,25 @@ const ( } }` - expectedHCPMetricsStatsSink = `{ + expectedTelemetryCollectorStatsSink = `{ "name": "envoy.stat_sinks.metrics_service", "typed_config": { "@type": "type.googleapis.com/envoy.config.metrics.v3.MetricsServiceConfig", "transport_api_version": "V3", "grpc_service": { "envoy_grpc": { - "cluster_name": "hcp_metrics_collector" + "cluster_name": "consul_telemetry_collector_loopback" } } } }` - expectedHCPMetricsCluster = `{ - "name": "hcp_metrics_collector", + expectedTelemetryCollectorCluster = `{ + "name": "consul_telemetry_collector_loopback", "type": "STATIC", "http2_protocol_options": {}, "loadAssignment": { - "clusterName": "hcp_metrics_collector", + "clusterName": "consul_telemetry_collector_loopback", "endpoints": [ { "lbEndpoints": [ @@ -553,7 +553,7 @@ const ( "endpoint": { "address": { "pipe": { - "path": "/tmp/consul/hcp-metrics/gqmuzdHCUPAEY5mbF8vgkZCNI14.sock" + "path": "/tmp/consul/telemetry-collector/gqmuzdHCUPAEY5mbF8vgkZCNI14.sock" } } } @@ -616,12 +616,12 @@ func TestBootstrapConfig_ConfigureArgs(t *testing.T) { }, }, { - name: "hcp-metrics-sink", + name: "telemetry-collector-sink", baseArgs: BootstrapTplArgs{ ProxyID: "web-sidecar-proxy", }, input: BootstrapConfig{ - HCPMetricsBindSocketDir: "/tmp/consul/hcp-metrics", + TelemetryCollectorBindSocketDir: "/tmp/consul/telemetry-collector", }, wantArgs: BootstrapTplArgs{ ProxyID: "web-sidecar-proxy", @@ -633,17 +633,17 @@ func TestBootstrapConfig_ConfigureArgs(t *testing.T) { "transport_api_version": "V3", "grpc_service": { "envoy_grpc": { - "cluster_name": "hcp_metrics_collector" + "cluster_name": "consul_telemetry_collector_loopback" } } } }`, StaticClustersJSON: `{ - "name": "hcp_metrics_collector", + "name": "consul_telemetry_collector_loopback", "type": "STATIC", "http2_protocol_options": {}, "loadAssignment": { - "clusterName": "hcp_metrics_collector", + "clusterName": "consul_telemetry_collector_loopback", "endpoints": [ { "lbEndpoints": [ @@ -651,7 +651,7 @@ func TestBootstrapConfig_ConfigureArgs(t *testing.T) { "endpoint": { "address": { "pipe": { - "path": "/tmp/consul/hcp-metrics/gqmuzdHCUPAEY5mbF8vgkZCNI14.sock" + "path": "/tmp/consul/telemetry-collector/gqmuzdHCUPAEY5mbF8vgkZCNI14.sock" } } } @@ -1628,7 +1628,7 @@ func TestConsulTagSpecifiers(t *testing.T) { } } -func TestAppendHCPMetrics(t *testing.T) { +func TestAppendTelemetryCollectorMetrics(t *testing.T) { tests := map[string]struct { inputArgs *BootstrapTplArgs bindSocketDir string @@ -1638,22 +1638,22 @@ func TestAppendHCPMetrics(t *testing.T) { inputArgs: &BootstrapTplArgs{ ProxyID: "web-sidecar-proxy", }, - bindSocketDir: "/tmp/consul/hcp-metrics", + bindSocketDir: "/tmp/consul/telemetry-collector", wantArgs: &BootstrapTplArgs{ ProxyID: "web-sidecar-proxy", - StatsSinksJSON: expectedHCPMetricsStatsSink, - StaticClustersJSON: expectedHCPMetricsCluster, + StatsSinksJSON: expectedTelemetryCollectorStatsSink, + StaticClustersJSON: expectedTelemetryCollectorCluster, }, }, "dir-with-trailing-slash": { inputArgs: &BootstrapTplArgs{ ProxyID: "web-sidecar-proxy", }, - bindSocketDir: "/tmp/consul/hcp-metrics", + bindSocketDir: "/tmp/consul/telemetry-collector", wantArgs: &BootstrapTplArgs{ ProxyID: "web-sidecar-proxy", - StatsSinksJSON: expectedHCPMetricsStatsSink, - StaticClustersJSON: expectedHCPMetricsCluster, + StatsSinksJSON: expectedTelemetryCollectorStatsSink, + StaticClustersJSON: expectedTelemetryCollectorCluster, }, }, "append-clusters-and-stats-sink": { @@ -1662,18 +1662,18 @@ func TestAppendHCPMetrics(t *testing.T) { StatsSinksJSON: expectedStatsdSink, StaticClustersJSON: expectedSelfAdminCluster, }, - bindSocketDir: "/tmp/consul/hcp-metrics", + bindSocketDir: "/tmp/consul/telemetry-collector", wantArgs: &BootstrapTplArgs{ ProxyID: "web-sidecar-proxy", - StatsSinksJSON: expectedStatsdSink + ",\n" + expectedHCPMetricsStatsSink, - StaticClustersJSON: expectedSelfAdminCluster + ",\n" + expectedHCPMetricsCluster, + StatsSinksJSON: expectedStatsdSink + ",\n" + expectedTelemetryCollectorStatsSink, + StaticClustersJSON: expectedSelfAdminCluster + ",\n" + expectedTelemetryCollectorCluster, }, }, } for name, tt := range tests { t.Run(name, func(t *testing.T) { - appendHCPMetricsConfig(tt.inputArgs, tt.bindSocketDir) + appendTelemetryCollectorConfig(tt.inputArgs, tt.bindSocketDir) // Some of our JSON strings are comma separated objects to be // insertedinto an array which is not valid JSON on it's own so wrap diff --git a/command/connect/envoy/envoy_test.go b/command/connect/envoy/envoy_test.go index 8366d65974ea..e24c0199cf43 100644 --- a/command/connect/envoy/envoy_test.go +++ b/command/connect/envoy/envoy_test.go @@ -196,10 +196,10 @@ func TestGenerateConfig(t *testing.T) { }, }, { - Name: "hcp-metrics", + Name: "telemetry-collector", Flags: []string{"-proxy-id", "test-proxy"}, ProxyConfig: map[string]interface{}{ - "envoy_hcp_metrics_bind_socket_dir": "/tmp/consul/hcp-metrics", + "envoy_telemetry_collector_bind_socket_dir": "/tmp/consul/telemetry-collector", }, WantArgs: BootstrapTplArgs{ ProxyCluster: "test-proxy", diff --git a/command/connect/envoy/testdata/hcp-metrics.golden b/command/connect/envoy/testdata/telemetry-collector.golden similarity index 96% rename from command/connect/envoy/testdata/hcp-metrics.golden rename to command/connect/envoy/testdata/telemetry-collector.golden index 4871c1cb6a2f..983e51633bc7 100644 --- a/command/connect/envoy/testdata/hcp-metrics.golden +++ b/command/connect/envoy/testdata/telemetry-collector.golden @@ -55,11 +55,11 @@ } }, { - "name": "hcp_metrics_collector", + "name": "consul_telemetry_collector_loopback", "type": "STATIC", "http2_protocol_options": {}, "loadAssignment": { - "clusterName": "hcp_metrics_collector", + "clusterName": "consul_telemetry_collector_loopback", "endpoints": [ { "lbEndpoints": [ @@ -67,7 +67,7 @@ "endpoint": { "address": { "pipe": { - "path": "/tmp/consul/hcp-metrics/k3bWnyJyKvjUYXrBdOX2nXzSSCQ.sock" + "path": "/tmp/consul/telemetry-collector/k3bWnyJyKvjUYXrBdOX2nXzSSCQ.sock" } } } @@ -87,7 +87,7 @@ "transport_api_version": "V3", "grpc_service": { "envoy_grpc": { - "cluster_name": "hcp_metrics_collector" + "cluster_name": "consul_telemetry_collector_loopback" } } } diff --git a/website/content/commands/connect/envoy.mdx b/website/content/commands/connect/envoy.mdx index f07d51bb7188..bb2cc5d77e81 100644 --- a/website/content/commands/connect/envoy.mdx +++ b/website/content/commands/connect/envoy.mdx @@ -75,10 +75,6 @@ Usage: `consul connect envoy [options] [-- pass-through options]` In cases where either assumption is violated this flag will prevent the command attempting to resolve config from the local agent. -- `envoy_hcp_metrics_bind_socket_dir` - Specifies the directory where Envoy creates a unix socket. - Envoy sends metrics to the socket so that HCP collectors can connect to collect them." - The socket is not configured by default. - - `-envoy-ready-bind-address` - By default the proxy does not have a readiness probe configured on it. This flag in conjunction with the `envoy-ready-bind-port` flag configures where the envoy readiness probe is configured on the proxy. A `/ready` HTTP diff --git a/website/content/docs/connect/proxies/envoy.mdx b/website/content/docs/connect/proxies/envoy.mdx index 01caad3ec0e4..b9140de44859 100644 --- a/website/content/docs/connect/proxies/envoy.mdx +++ b/website/content/docs/connect/proxies/envoy.mdx @@ -190,6 +190,10 @@ the [`sidecar_service`](/consul/docs/connect/registration/sidecar-service) block - `envoy_stats_flush_interval` - Configures Envoy's [`stats_flush_interval`](https://www.envoyproxy.io/docs/envoy/v1.17.2/api-v3/config/bootstrap/v3/bootstrap.proto#envoy-v3-api-field-config-bootstrap-v3-bootstrap-stats-flush-interval). +- `envoy_telemetry_collector_bind_socket_dir` - Specifies the directory where Envoy creates a Unix socket. + Envoy sends metrics to the socket where a Consul telemetry collector can collect them. + The socket is not configured by default. + The [Advanced Configuration](#advanced-configuration) section describes additional configurations that allow incremental or complete control over the bootstrap configuration generated. ### Bootstrap Envoy on Windows VMs