common.proto 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. syntax = "proto3";
  2. package envoy.config.tap.v3;
  3. import "envoy/config/common/matcher/v3/matcher.proto";
  4. import "envoy/config/core/v3/base.proto";
  5. import "envoy/config/core/v3/grpc_service.proto";
  6. import "envoy/config/route/v3/route_components.proto";
  7. import "google/protobuf/wrappers.proto";
  8. import "envoy/annotations/deprecation.proto";
  9. import "udpa/annotations/status.proto";
  10. import "udpa/annotations/versioning.proto";
  11. import "validate/validate.proto";
  12. option java_package = "io.envoyproxy.envoy.config.tap.v3";
  13. option java_outer_classname = "CommonProto";
  14. option java_multiple_files = true;
  15. option go_package = "github.com/envoyproxy/go-control-plane/envoy/config/tap/v3;tapv3";
  16. option (udpa.annotations.file_status).package_version_status = ACTIVE;
  17. // [#protodoc-title: Common tap configuration]
  18. // Tap configuration.
  19. message TapConfig {
  20. // [#comment:TODO(mattklein123): Rate limiting]
  21. option (udpa.annotations.versioning).previous_message_type =
  22. "envoy.service.tap.v2alpha.TapConfig";
  23. // The match configuration. If the configuration matches the data source being tapped, a tap will
  24. // occur, with the result written to the configured output.
  25. // Exactly one of :ref:`match <envoy_v3_api_field_config.tap.v3.TapConfig.match>` and
  26. // :ref:`match_config <envoy_v3_api_field_config.tap.v3.TapConfig.match_config>` must be set. If both
  27. // are set, the :ref:`match <envoy_v3_api_field_config.tap.v3.TapConfig.match>` will be used.
  28. MatchPredicate match_config = 1
  29. [deprecated = true, (envoy.annotations.deprecated_at_minor_version) = "3.0"];
  30. // The match configuration. If the configuration matches the data source being tapped, a tap will
  31. // occur, with the result written to the configured output.
  32. // Exactly one of :ref:`match <envoy_v3_api_field_config.tap.v3.TapConfig.match>` and
  33. // :ref:`match_config <envoy_v3_api_field_config.tap.v3.TapConfig.match_config>` must be set. If both
  34. // are set, the :ref:`match <envoy_v3_api_field_config.tap.v3.TapConfig.match>` will be used.
  35. common.matcher.v3.MatchPredicate match = 4;
  36. // The tap output configuration. If a match configuration matches a data source being tapped,
  37. // a tap will occur and the data will be written to the configured output.
  38. OutputConfig output_config = 2 [(validate.rules).message = {required: true}];
  39. // [#not-implemented-hide:] Specify if Tap matching is enabled. The % of requests\connections for
  40. // which the tap matching is enabled. When not enabled, the request\connection will not be
  41. // recorded.
  42. //
  43. // .. note::
  44. //
  45. // This field defaults to 100/:ref:`HUNDRED
  46. // <envoy_v3_api_enum_type.v3.FractionalPercent.DenominatorType>`.
  47. core.v3.RuntimeFractionalPercent tap_enabled = 3;
  48. }
  49. // Tap match configuration. This is a recursive structure which allows complex nested match
  50. // configurations to be built using various logical operators.
  51. // [#next-free-field: 11]
  52. message MatchPredicate {
  53. option (udpa.annotations.versioning).previous_message_type =
  54. "envoy.service.tap.v2alpha.MatchPredicate";
  55. // A set of match configurations used for logical operations.
  56. message MatchSet {
  57. option (udpa.annotations.versioning).previous_message_type =
  58. "envoy.service.tap.v2alpha.MatchPredicate.MatchSet";
  59. // The list of rules that make up the set.
  60. repeated MatchPredicate rules = 1 [(validate.rules).repeated = {min_items: 2}];
  61. }
  62. oneof rule {
  63. option (validate.required) = true;
  64. // A set that describes a logical OR. If any member of the set matches, the match configuration
  65. // matches.
  66. MatchSet or_match = 1;
  67. // A set that describes a logical AND. If all members of the set match, the match configuration
  68. // matches.
  69. MatchSet and_match = 2;
  70. // A negation match. The match configuration will match if the negated match condition matches.
  71. MatchPredicate not_match = 3;
  72. // The match configuration will always match.
  73. bool any_match = 4 [(validate.rules).bool = {const: true}];
  74. // HTTP request headers match configuration.
  75. HttpHeadersMatch http_request_headers_match = 5;
  76. // HTTP request trailers match configuration.
  77. HttpHeadersMatch http_request_trailers_match = 6;
  78. // HTTP response headers match configuration.
  79. HttpHeadersMatch http_response_headers_match = 7;
  80. // HTTP response trailers match configuration.
  81. HttpHeadersMatch http_response_trailers_match = 8;
  82. // HTTP request generic body match configuration.
  83. HttpGenericBodyMatch http_request_generic_body_match = 9;
  84. // HTTP response generic body match configuration.
  85. HttpGenericBodyMatch http_response_generic_body_match = 10;
  86. }
  87. }
  88. // HTTP headers match configuration.
  89. message HttpHeadersMatch {
  90. option (udpa.annotations.versioning).previous_message_type =
  91. "envoy.service.tap.v2alpha.HttpHeadersMatch";
  92. // HTTP headers to match.
  93. repeated route.v3.HeaderMatcher headers = 1;
  94. }
  95. // HTTP generic body match configuration.
  96. // List of text strings and hex strings to be located in HTTP body.
  97. // All specified strings must be found in the HTTP body for positive match.
  98. // The search may be limited to specified number of bytes from the body start.
  99. //
  100. // .. attention::
  101. //
  102. // Searching for patterns in HTTP body is potentially cpu intensive. For each specified pattern, http body is scanned byte by byte to find a match.
  103. // If multiple patterns are specified, the process is repeated for each pattern. If location of a pattern is known, ``bytes_limit`` should be specified
  104. // to scan only part of the http body.
  105. message HttpGenericBodyMatch {
  106. message GenericTextMatch {
  107. oneof rule {
  108. option (validate.required) = true;
  109. // Text string to be located in HTTP body.
  110. string string_match = 1 [(validate.rules).string = {min_len: 1}];
  111. // Sequence of bytes to be located in HTTP body.
  112. bytes binary_match = 2 [(validate.rules).bytes = {min_len: 1}];
  113. }
  114. }
  115. // Limits search to specified number of bytes - default zero (no limit - match entire captured buffer).
  116. uint32 bytes_limit = 1;
  117. // List of patterns to match.
  118. repeated GenericTextMatch patterns = 2 [(validate.rules).repeated = {min_items: 1}];
  119. }
  120. // Tap output configuration.
  121. message OutputConfig {
  122. option (udpa.annotations.versioning).previous_message_type =
  123. "envoy.service.tap.v2alpha.OutputConfig";
  124. // Output sinks for tap data. Currently a single sink is allowed in the list. Once multiple
  125. // sink types are supported this constraint will be relaxed.
  126. repeated OutputSink sinks = 1 [(validate.rules).repeated = {min_items: 1 max_items: 1}];
  127. // For buffered tapping, the maximum amount of received body that will be buffered prior to
  128. // truncation. If truncation occurs, the :ref:`truncated
  129. // <envoy_v3_api_field_data.tap.v3.Body.truncated>` field will be set. If not specified, the
  130. // default is 1KiB.
  131. google.protobuf.UInt32Value max_buffered_rx_bytes = 2;
  132. // For buffered tapping, the maximum amount of transmitted body that will be buffered prior to
  133. // truncation. If truncation occurs, the :ref:`truncated
  134. // <envoy_v3_api_field_data.tap.v3.Body.truncated>` field will be set. If not specified, the
  135. // default is 1KiB.
  136. google.protobuf.UInt32Value max_buffered_tx_bytes = 3;
  137. // Indicates whether taps produce a single buffered message per tap, or multiple streamed
  138. // messages per tap in the emitted :ref:`TraceWrapper
  139. // <envoy_v3_api_msg_data.tap.v3.TraceWrapper>` messages. Note that streamed tapping does not
  140. // mean that no buffering takes place. Buffering may be required if data is processed before a
  141. // match can be determined. See the HTTP tap filter :ref:`streaming
  142. // <config_http_filters_tap_streaming>` documentation for more information.
  143. bool streaming = 4;
  144. }
  145. // Tap output sink configuration.
  146. message OutputSink {
  147. option (udpa.annotations.versioning).previous_message_type =
  148. "envoy.service.tap.v2alpha.OutputSink";
  149. // Output format. All output is in the form of one or more :ref:`TraceWrapper
  150. // <envoy_v3_api_msg_data.tap.v3.TraceWrapper>` messages. This enumeration indicates
  151. // how those messages are written. Note that not all sinks support all output formats. See
  152. // individual sink documentation for more information.
  153. enum Format {
  154. // Each message will be written as JSON. Any :ref:`body <envoy_v3_api_msg_data.tap.v3.Body>`
  155. // data will be present in the :ref:`as_bytes
  156. // <envoy_v3_api_field_data.tap.v3.Body.as_bytes>` field. This means that body data will be
  157. // base64 encoded as per the `proto3 JSON mappings
  158. // <https://developers.google.com/protocol-buffers/docs/proto3#json>`_.
  159. JSON_BODY_AS_BYTES = 0;
  160. // Each message will be written as JSON. Any :ref:`body <envoy_v3_api_msg_data.tap.v3.Body>`
  161. // data will be present in the :ref:`as_string
  162. // <envoy_v3_api_field_data.tap.v3.Body.as_string>` field. This means that body data will be
  163. // string encoded as per the `proto3 JSON mappings
  164. // <https://developers.google.com/protocol-buffers/docs/proto3#json>`_. This format type is
  165. // useful when it is known that that body is human readable (e.g., JSON over HTTP) and the
  166. // user wishes to view it directly without being forced to base64 decode the body.
  167. JSON_BODY_AS_STRING = 1;
  168. // Binary proto format. Note that binary proto is not self-delimiting. If a sink writes
  169. // multiple binary messages without any length information the data stream will not be
  170. // useful. However, for certain sinks that are self-delimiting (e.g., one message per file)
  171. // this output format makes consumption simpler.
  172. PROTO_BINARY = 2;
  173. // Messages are written as a sequence tuples, where each tuple is the message length encoded
  174. // as a `protobuf 32-bit varint
  175. // <https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.io.coded_stream>`_
  176. // followed by the binary message. The messages can be read back using the language specific
  177. // protobuf coded stream implementation to obtain the message length and the message.
  178. PROTO_BINARY_LENGTH_DELIMITED = 3;
  179. // Text proto format.
  180. PROTO_TEXT = 4;
  181. }
  182. // Sink output format.
  183. Format format = 1 [(validate.rules).enum = {defined_only: true}];
  184. oneof output_sink_type {
  185. option (validate.required) = true;
  186. // Tap output will be streamed out the :http:post:`/tap` admin endpoint.
  187. //
  188. // .. attention::
  189. //
  190. // It is only allowed to specify the streaming admin output sink if the tap is being
  191. // configured from the :http:post:`/tap` admin endpoint. Thus, if an extension has
  192. // been configured to receive tap configuration from some other source (e.g., static
  193. // file, XDS, etc.) configuring the streaming admin output type will fail.
  194. StreamingAdminSink streaming_admin = 2;
  195. // Tap output will be written to a file per tap sink.
  196. FilePerTapSink file_per_tap = 3;
  197. // [#not-implemented-hide:]
  198. // GrpcService to stream data to. The format argument must be PROTO_BINARY.
  199. // [#comment: TODO(samflattery): remove cleanup in uber_per_filter.cc once implemented]
  200. StreamingGrpcSink streaming_grpc = 4;
  201. }
  202. }
  203. // Streaming admin sink configuration.
  204. message StreamingAdminSink {
  205. option (udpa.annotations.versioning).previous_message_type =
  206. "envoy.service.tap.v2alpha.StreamingAdminSink";
  207. }
  208. // The file per tap sink outputs a discrete file for every tapped stream.
  209. message FilePerTapSink {
  210. option (udpa.annotations.versioning).previous_message_type =
  211. "envoy.service.tap.v2alpha.FilePerTapSink";
  212. // Path prefix. The output file will be of the form <path_prefix>_<id>.pb, where <id> is an
  213. // identifier distinguishing the recorded trace for stream instances (the Envoy
  214. // connection ID, HTTP stream ID, etc.).
  215. string path_prefix = 1 [(validate.rules).string = {min_len: 1}];
  216. }
  217. // [#not-implemented-hide:] Streaming gRPC sink configuration sends the taps to an external gRPC
  218. // server.
  219. message StreamingGrpcSink {
  220. option (udpa.annotations.versioning).previous_message_type =
  221. "envoy.service.tap.v2alpha.StreamingGrpcSink";
  222. // Opaque identifier, that will be sent back to the streaming grpc server.
  223. string tap_id = 1;
  224. // The gRPC server that hosts the Tap Sink Service.
  225. core.v3.GrpcService grpc_service = 2 [(validate.rules).message = {required: true}];
  226. }