From 74530dc3ee0da9cf2a001d1de1b7b7461d9cb619 Mon Sep 17 00:00:00 2001 From: "data-plane-api(Azure Pipelines)" Date: Mon, 25 Oct 2021 15:38:14 +0000 Subject: [PATCH] Add transport socket wrapper to collect OS-level TCP stats and export as envoy metrics (#17682) This adds a new transport socket wrapper for collecting OS-level TCP stats and publishing them as envoy metrics, in either the cluster or listener stats namespace (depending on upstream or downstream use). This allows attributing the TCP stats to specific listeners and clusters. Signed-off-by: Greg Greenway Mirrored from https://github.com/envoyproxy/envoy @ b959a46661ec87bba8268a1750506695125f2b06 --- BUILD | 1 + .../transport_sockets/tcp_stats/v3/BUILD | 12 +++++++ .../tcp_stats/v3/tcp_stats.proto | 34 +++++++++++++++++++ versioning/BUILD | 1 + 4 files changed, 48 insertions(+) create mode 100644 envoy/extensions/transport_sockets/tcp_stats/v3/BUILD create mode 100644 envoy/extensions/transport_sockets/tcp_stats/v3/tcp_stats.proto diff --git a/BUILD b/BUILD index 0f60195f..f814a6d0 100644 --- a/BUILD +++ b/BUILD @@ -221,6 +221,7 @@ proto_library( "//envoy/extensions/transport_sockets/s2a/v3:pkg", "//envoy/extensions/transport_sockets/starttls/v3:pkg", "//envoy/extensions/transport_sockets/tap/v3:pkg", + "//envoy/extensions/transport_sockets/tcp_stats/v3:pkg", "//envoy/extensions/transport_sockets/tls/v3:pkg", "//envoy/extensions/upstreams/http/generic/v3:pkg", "//envoy/extensions/upstreams/http/http/v3:pkg", diff --git a/envoy/extensions/transport_sockets/tcp_stats/v3/BUILD b/envoy/extensions/transport_sockets/tcp_stats/v3/BUILD new file mode 100644 index 00000000..1c1a6f6b --- /dev/null +++ b/envoy/extensions/transport_sockets/tcp_stats/v3/BUILD @@ -0,0 +1,12 @@ +# DO NOT EDIT. This file is generated by tools/proto_format/proto_sync.py. + +load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package") + +licenses(["notice"]) # Apache 2 + +api_proto_package( + deps = [ + "//envoy/config/core/v3:pkg", + "@com_github_cncf_udpa//udpa/annotations:pkg", + ], +) diff --git a/envoy/extensions/transport_sockets/tcp_stats/v3/tcp_stats.proto b/envoy/extensions/transport_sockets/tcp_stats/v3/tcp_stats.proto new file mode 100644 index 00000000..cd729e27 --- /dev/null +++ b/envoy/extensions/transport_sockets/tcp_stats/v3/tcp_stats.proto @@ -0,0 +1,34 @@ +syntax = "proto3"; + +package envoy.extensions.transport_sockets.tcp_stats.v3; + +import "envoy/config/core/v3/base.proto"; + +import "google/protobuf/duration.proto"; + +import "udpa/annotations/status.proto"; +import "validate/validate.proto"; + +option java_package = "io.envoyproxy.envoy.extensions.transport_sockets.tcp_stats.v3"; +option java_outer_classname = "TcpStatsProto"; +option java_multiple_files = true; +option (udpa.annotations.file_status).package_version_status = ACTIVE; + +// [#protodoc-title: TCP Stats Transport Socket wrapper] +// [#extension: envoy.transport_sockets.tcp_stats] + +// Configuration for the TCP Stats transport socket wrapper, which wraps another transport socket for +// all communication, but emits stats about the underlying TCP connection. +// +// The stats are documented :ref:`here ` for listeners and +// :ref:`here ` for clusters. +// +// This transport socket is currently only supported on Linux. +message Config { + // The underlying transport socket being wrapped. + config.core.v3.TransportSocket transport_socket = 1 [(validate.rules).message = {required: true}]; + + // Period to update stats while the connection is open. If unset, updates only happen when the + // connection is closed. Stats are always updated one final time when the connection is closed. + google.protobuf.Duration update_period = 2 [(validate.rules).duration = {gte {nanos: 1000000}}]; +} diff --git a/versioning/BUILD b/versioning/BUILD index c0bbd3bc..8eeb536f 100644 --- a/versioning/BUILD +++ b/versioning/BUILD @@ -173,6 +173,7 @@ proto_library( "//envoy/extensions/transport_sockets/s2a/v3:pkg", "//envoy/extensions/transport_sockets/starttls/v3:pkg", "//envoy/extensions/transport_sockets/tap/v3:pkg", + "//envoy/extensions/transport_sockets/tcp_stats/v3:pkg", "//envoy/extensions/transport_sockets/tls/v3:pkg", "//envoy/extensions/upstreams/http/generic/v3:pkg", "//envoy/extensions/upstreams/http/http/v3:pkg",