Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
Signed-off-by: giantcroc <changran.wang@intel.com>
  • Loading branch information
giantcroc committed Sep 26, 2022
1 parent ff5c635 commit b4e9a96
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ message UdpProxyConfig {
// to upstream host selected on first chunk receival for that "session" (identified by source IP/port and local IP/port).
bool use_per_packet_load_balancing = 7;

// Configuration for access logs emitted by the UDP proxy. Note that certain UDP specific data is emitted as :ref:`Dynamic Metadata <config_access_log_format_dynamic_metadata>`.
// Configuration for session access logs emitted by the UDP proxy. Note that certain UDP specific data is emitted as :ref:`Dynamic Metadata <config_access_log_format_dynamic_metadata>`.
repeated config.accesslog.v3.AccessLog sess_access_log = 8;

// Configuration for proxy access logs emitted by the UDP proxy. Note that certain UDP specific data is emitted as :ref:`Dynamic Metadata <config_access_log_format_dynamic_metadata>`.
repeated config.accesslog.v3.AccessLog proxy_access_log = 10;
}
3 changes: 3 additions & 0 deletions changelogs/current.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ new_features:
- area: grpc_json_transcoder
change: |
added support for parsing enum value case insensitively enabled by the config :ref:`case_insensitive_enum_parsing <envoy_v3_api_field_extensions.filters.http.grpc_json_transcoder.v3.GrpcJsonTranscoder.case_insensitive_enum_parsing>`.
- area: udp_proxy
change: |
added support for :ref:`proxy_access_log <envoy_v3_api_field_extensions.filters.udp.udp_proxy.v3.UdpProxyConfig.proxy_access_log>`.
deprecated:
- area: http
Expand Down
42 changes: 32 additions & 10 deletions docs/root/configuration/observability/access_log/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -650,28 +650,50 @@ The following command operators are supported:

UDP
For :ref:`UDP Proxy <config_udp_listener_filters_udp_proxy>`,
NAMESPACE should be always set to "udp.proxy", optional KEYs are as follows:
if NAMESPACE is set to "udp.proxy.session", optional KEYs are as follows:

* ``cluster_name``: Name of the cluster.
* ``bytes_sent``: Total number of downstream bytes sent to the upstream in the session.
* ``bytes_received``: Total number of downstream bytes received from the upstream in the session.
* ``errors_sent``: Number of errors that have occurred when sending datagrams to the upstream in the session.
* ``errors_received``: Number of errors that have occurred when receiving datagrams from the upstream in UDP proxy.
Since the receiving errors are counted in at the listener level (vs. the session), this counter is global to all sessions and may not be directly attributable to the session being logged.
* ``datagrams_sent``: Number of datagrams sent to the upstream successfully in the session.
* ``datagrams_received``: Number of datagrams received from the upstream successfully in the session.

Recommended access log format for UDP proxy:
Recommended session access log format for UDP proxy:

.. code-block:: none
[%START_TIME%] %DYNAMIC_METADATA(udp.proxy:cluster_name)%
%DYNAMIC_METADATA(udp.proxy:bytes_sent)%
%DYNAMIC_METADATA(udp.proxy:bytes_received)%
%DYNAMIC_METADATA(udp.proxy:errors_sent)%
%DYNAMIC_METADATA(udp.proxy:errors_received)%
%DYNAMIC_METADATA(udp.proxy:datagrams_sent)%
%DYNAMIC_METADATA(udp.proxy:datagrams_received)%\n
%DYNAMIC_METADATA(udp.proxy.session:bytes_sent)%
%DYNAMIC_METADATA(udp.proxy.session:bytes_received)%
%DYNAMIC_METADATA(udp.proxy.session:errors_sent)%
%DYNAMIC_METADATA(udp.proxy.session:datagrams_sent)%
%DYNAMIC_METADATA(udp.proxy.session:datagrams_received)%\n
if NAMESPACE is set to "udp.proxy.proxy", optional KEYs are as follows:

* ``bytes_sent``: Total number of downstream bytes sent to the upstream in UDP proxy.
* ``bytes_received``: Total number of downstream bytes received from the upstream in UDP proxy.
* ``errors_sent``: Number of errors that have occurred when sending datagrams to the upstream in UDP proxy.
* ``errors_received``: Number of errors that have occurred when receiving datagrams from the upstream in UDP proxy.
* ``datagrams_sent``: Number of datagrams sent to the upstream successfully in UDP proxy.
* ``datagrams_received``: Number of datagrams received from the upstream successfully in UDP proxy.
* ``no_route``: Number of times that no upstream cluster found in UDP proxy.
* ``sess_total``: Total number of sessions in UDP proxy.
* ``idle_timeout``: Number of times that sessions idle timeout occurred in UDP proxy.

Recommended proxy access log format for UDP proxy:

.. code-block:: none
[%START_TIME%]
%DYNAMIC_METADATA(udp.proxy.proxy:bytes_sent)%
%DYNAMIC_METADATA(udp.proxy.proxy:bytes_received)%
%DYNAMIC_METADATA(udp.proxy.proxy:errors_sent)%
%DYNAMIC_METADATA(udp.proxy.proxy:errors_received)%
%DYNAMIC_METADATA(udp.proxy.proxy:datagrams_sent)%
%DYNAMIC_METADATA(udp.proxy.proxy:datagrams_received)%
%DYNAMIC_METADATA(udp.proxy.proxy:sess_total)%\n
THRIFT
For :ref:`Thrift Proxy <config_network_filters_thrift_proxy>`,
Expand Down
2 changes: 0 additions & 2 deletions source/extensions/filters/udp/udp_proxy/udp_proxy_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,6 @@ void UdpProxyFilter::ActiveSession::fillSessionStreamInfo() {
fields_map["bytes_sent"] = ValueUtil::numberValue(session_stats_.downstream_sess_tx_bytes_);
fields_map["bytes_received"] = ValueUtil::numberValue(session_stats_.downstream_sess_rx_bytes_);
fields_map["errors_sent"] = ValueUtil::numberValue(session_stats_.downstream_sess_tx_errors_);
fields_map["errors_received"] =
ValueUtil::numberValue(cluster_.filter_.config_->stats().downstream_sess_rx_errors_.value());
fields_map["datagrams_sent"] =
ValueUtil::numberValue(session_stats_.downstream_sess_tx_datagrams_);
fields_map["datagrams_received"] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,11 +536,11 @@ TEST_F(UdpProxyFilterTest, SendReceiveErrorHandling) {
"%DYNAMIC_METADATA(udp.proxy.session:bytes_sent)% "
"%DYNAMIC_METADATA(udp.proxy.session:bytes_received)% "
"%DYNAMIC_METADATA(udp.proxy.session:errors_sent)% "
"%DYNAMIC_METADATA(udp.proxy.session:errors_received)% "
"%DYNAMIC_METADATA(udp.proxy.session:datagrams_sent)% "
"%DYNAMIC_METADATA(udp.proxy.session:datagrams_received)%";

const std::string proxy_access_log_format = "%DYNAMIC_METADATA(udp.proxy.proxy:no_route)% "
const std::string proxy_access_log_format = "%DYNAMIC_METADATA(udp.proxy.proxy:errors_received)% "
"%DYNAMIC_METADATA(udp.proxy.proxy:no_route)% "
"%DYNAMIC_METADATA(udp.proxy.proxy:sess_total)% "
"%DYNAMIC_METADATA(udp.proxy.proxy:idle_timeout)%";

Expand Down Expand Up @@ -595,8 +595,8 @@ stat_prefix: foo

filter_.reset();
EXPECT_EQ(output_.size(), 2);
EXPECT_EQ(output_.front(), "0 1 0");
EXPECT_EQ(output_.back(), "fake_cluster 0 10 1 1 0 2");
EXPECT_EQ(output_.front(), "1 0 1 0");
EXPECT_EQ(output_.back(), "fake_cluster 0 10 1 0 2");
}

// No upstream host handling.
Expand Down

0 comments on commit b4e9a96

Please sign in to comment.