-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kafka: Add broker-level metrics-collecting filter (#8188)
Signed-off-by: Adam Kotwasinski <adam.kotwasinski@gmail.com>
- Loading branch information
1 parent
215983a
commit a60f685
Showing
62 changed files
with
2,754 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# DO NOT EDIT. This file is generated by tools/proto_sync.py. | ||
|
||
load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package") | ||
|
||
licenses(["notice"]) # Apache 2 | ||
|
||
api_proto_package( | ||
deps = ["@com_github_cncf_udpa//udpa/annotations:pkg"], | ||
) |
21 changes: 21 additions & 0 deletions
21
api/envoy/config/filter/network/kafka_broker/v2alpha1/kafka_broker.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
syntax = "proto3"; | ||
|
||
package envoy.config.filter.network.kafka_broker.v2alpha1; | ||
|
||
import "udpa/annotations/migrate.proto"; | ||
import "validate/validate.proto"; | ||
|
||
option java_package = "io.envoyproxy.envoy.config.filter.network.kafka_broker.v2alpha1"; | ||
option java_outer_classname = "KafkaBrokerProto"; | ||
option java_multiple_files = true; | ||
option (udpa.annotations.file_migrate).move_to_package = | ||
"envoy.extensions.filters.network.kafka_broker.v3alpha"; | ||
|
||
// [#protodoc-title: Kafka Broker] | ||
// Kafka Broker :ref:`configuration overview <config_network_filters_kafka_broker>`. | ||
// [#extension: envoy.filters.network.kafka_broker] | ||
|
||
message KafkaBroker { | ||
// The prefix to use when emitting :ref:`statistics <config_network_filters_kafka_broker_stats>`. | ||
string stat_prefix = 1 [(validate.rules).string = {min_bytes: 1}]; | ||
} |
12 changes: 12 additions & 0 deletions
12
api/envoy/extensions/filters/network/kafka_broker/v3alpha/BUILD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# DO NOT EDIT. This file is generated by tools/proto_sync.py. | ||
|
||
load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package") | ||
|
||
licenses(["notice"]) # Apache 2 | ||
|
||
api_proto_package( | ||
deps = [ | ||
"//envoy/config/filter/network/kafka_broker/v2alpha1:pkg", | ||
"@com_github_cncf_udpa//udpa/annotations:pkg", | ||
], | ||
) |
23 changes: 23 additions & 0 deletions
23
api/envoy/extensions/filters/network/kafka_broker/v3alpha/kafka_broker.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
syntax = "proto3"; | ||
|
||
package envoy.extensions.filters.network.kafka_broker.v3alpha; | ||
|
||
import "udpa/annotations/versioning.proto"; | ||
|
||
import "validate/validate.proto"; | ||
|
||
option java_package = "io.envoyproxy.envoy.extensions.filters.network.kafka_broker.v3alpha"; | ||
option java_outer_classname = "KafkaBrokerProto"; | ||
option java_multiple_files = true; | ||
|
||
// [#protodoc-title: Kafka Broker] | ||
// Kafka Broker :ref:`configuration overview <config_network_filters_kafka_broker>`. | ||
// [#extension: envoy.filters.network.kafka_broker] | ||
|
||
message KafkaBroker { | ||
option (udpa.annotations.versioning).previous_message_type = | ||
"envoy.config.filter.network.kafka_broker.v2alpha1.KafkaBroker"; | ||
|
||
// The prefix to use when emitting :ref:`statistics <config_network_filters_kafka_broker_stats>`. | ||
string stat_prefix = 1 [(validate.rules).string = {min_bytes: 1}]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -370,3 +370,8 @@ alias( | |
}, | ||
), | ||
) | ||
|
||
alias( | ||
name = "remote_jdk11", | ||
actual = "@bazel_tools//tools/jdk:remote_jdk11", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
docs/root/configuration/listeners/network_filters/kafka_broker_filter.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
.. _config_network_filters_kafka_broker: | ||
|
||
Kafka Broker filter | ||
=================== | ||
|
||
The Apache Kafka broker filter decodes the client protocol for | ||
`Apache Kafka <https://kafka.apache.org/>`_, both the requests and responses in the payload. | ||
The message versions in `Kafka 2.0 <http://kafka.apache.org/20/protocol.html#protocol_api_keys>`_ | ||
are supported. | ||
The filter attempts not to influence the communication between client and brokers, so the messages | ||
that could not be decoded (due to Kafka client or broker running a newer version than supported by | ||
this filter) are forwarded as-is. | ||
|
||
* :ref:`v2 API reference <envoy_api_msg_config.filter.network.kafka_broker.v2alpha1.KafkaBroker>` | ||
* This filter should be configured with the name *envoy.filters.network.kafka_broker*. | ||
|
||
.. attention:: | ||
|
||
The kafka_broker filter is experimental and is currently under active development. | ||
Capabilities will be expanded over time and the configuration structures are likely to change. | ||
|
||
.. _config_network_filters_kafka_broker_config: | ||
|
||
Configuration | ||
------------- | ||
|
||
The Kafka Broker filter should be chained with the TCP proxy filter as shown | ||
in the configuration snippet below: | ||
|
||
.. code-block:: yaml | ||
listeners: | ||
- address: | ||
socket_address: | ||
address: 127.0.0.1 # Host that Kafka clients should connect to. | ||
port_value: 19092 # Port that Kafka clients should connect to. | ||
filter_chains: | ||
- filters: | ||
- name: envoy.filters.network.kafka_broker | ||
config: | ||
stat_prefix: exampleprefix | ||
- name: envoy.tcp_proxy | ||
config: | ||
stat_prefix: tcp | ||
cluster: localkafka | ||
clusters: | ||
- name: localkafka | ||
connect_timeout: 0.25s | ||
type: strict_dns | ||
lb_policy: round_robin | ||
hosts: | ||
- socket_address: | ||
address: 127.0.0.1 # Kafka broker's host. | ||
port_value: 9092 # Kafka broker's port. | ||
The Kafka broker needs to advertise the Envoy listener port instead of its own. | ||
|
||
.. code-block:: text | ||
# Listener value needs to be equal to cluster value in Envoy config | ||
# (will receive payloads from Envoy). | ||
listeners=PLAINTEXT://127.0.0.1:9092 | ||
# Advertised listener value needs to be equal to Envoy's listener | ||
# (will make clients discovering this broker talk to it through Envoy). | ||
advertised.listeners=PLAINTEXT://127.0.0.1:19092 | ||
.. _config_network_filters_kafka_broker_stats: | ||
|
||
Statistics | ||
---------- | ||
|
||
Every configured Kafka Broker filter has statistics rooted at *kafka.<stat_prefix>.*, with multiple | ||
statistics per message type. | ||
|
||
.. csv-table:: | ||
:header: Name, Type, Description | ||
:widths: 1, 1, 2 | ||
|
||
request.TYPE, Counter, Number of times a request of particular type was received from Kafka client | ||
request.unknown, Counter, Number of times a request with format not recognized by this filter was received | ||
request.failure, Counter, Number of times a request with invalid format was received or other processing exception occurred | ||
response.TYPE, Counter, Number of times a response of particular type was received from Kafka broker | ||
response.TYPE_duration, Histogram, Response generation time in milliseconds | ||
response.unknown, Counter, Number of times a response with format not recognized by this filter was received | ||
response.failure, Counter, Number of times a response with invalid format was received or other processing exception occurred |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.