このコンテンツは選択した言語では利用できません。
Chapter 3. Kafka Bridge configuration
Configure a deployment of the Kafka Bridge with Kafka-related properties and specify the HTTP connection details needed to be able to interact with Kafka. Additionally, enable metrics in Prometheus format using either the Prometheus JMX Exporter or the Streams for Apache Kafka Metrics Reporter. You can also use configuration properties to enable and use distributed tracing with the Kafka Bridge. Distributed tracing allows you to track the progress of transactions between applications in a distributed system.
Use the KafkaBridge resource to configure properties when you are running the Kafka Bridge on OpenShift.
3.1. Configuring Kafka Bridge properties リンクのコピーリンクがクリップボードにコピーされました!
This procedure describes how to configure the Kafka and HTTP connection properties used by the Kafka Bridge.
You configure the Kafka Bridge, as any other Kafka client, using appropriate prefixes for Kafka-related properties.
-
kafka.for general configuration that applies to producers and consumers, such as server connection and security. -
kafka.consumer.for consumer-specific configuration passed only to the consumer. -
kafka.producer.for producer-specific configuration passed only to the producer.
As well as enabling HTTP access to a Kafka cluster, HTTP properties provide the capability to enable and define access control for the Kafka Bridge through Cross-Origin Resource Sharing (CORS). CORS is a HTTP mechanism that allows browser access to selected resources from more than one origin. To configure CORS, you define a list of allowed resource origins and HTTP methods to access them. Additional HTTP headers in requests describe the CORS origins that are permitted access to the Kafka cluster.
Prerequisites
Procedure
Edit the
application.propertiesfile provided with the Kafka Bridge installation archive.Use the properties file to specify Kafka and HTTP-related properties.
Configure standard Kafka-related properties, including properties specific to the Kafka consumers and producers.
Use:
-
kafka.bootstrap.serversto define the host/port connections to the Kafka cluster -
kafka.producer.acksto provide acknowledgments to the HTTP client kafka.consumer.auto.offset.resetto determine how to manage reset of the offset in KafkaFor more information on configuration of Kafka properties, see the Apache Kafka website
-
Configure HTTP-related properties to enable HTTP access to the Kafka cluster.
For example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
- Save the configuration file.
3.2. Configuring Prometheus JMX Exporter metrics リンクのコピーリンクがクリップボードにコピーされました!
Enable the Prometheus JMX Exporter to collect Kafka Bridge metrics by setting the bridge.metrics option to jmxPrometheusExporter.
Prerequisites
Procedure
Set the
bridge.metricsconfiguration tojmxPrometheusExporter.Configuration for enabling metrics
bridge.metrics=jmxPrometheusExporter
bridge.metrics=jmxPrometheusExporterCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optionally, you can add a custom Prometheus JMX Exporter configuration using the
bridge.metrics.exporter.config.pathproperty. If not configured, a default embedded configuration file is used.Run the Kafka Bridge run script.
Running the Kafka Bridge
./bin/kafka_bridge_run.sh --config-file=<path>/application.properties
./bin/kafka_bridge_run.sh --config-file=<path>/application.propertiesCopy to Clipboard Copied! Toggle word wrap Toggle overflow With metrics enabled, you can scrape metrics in Prometheus format from the
/metricsendpoint of the Kafka Bridge.
3.3. Configuring Streams for Apache Kafka Metrics Reporter metrics リンクのコピーリンクがクリップボードにコピーされました!
This feature is a technology preview and not intended for a production environment. For more information see the release notes.
Enable the Streams for Apache Kafka Metrics Reporter to collect Kafka Bridge metrics by setting the bridge.metrics option to strimziMetricsReporter.
Prerequisites
Procedure
Set the
bridge.metricsconfiguration tostrimziMetricsReporter.Configuration for enabling metrics
bridge.metrics=strimziMetricsReporter
bridge.metrics=strimziMetricsReporterCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optionally, you can configure a comma-separated list of regular expressions to filter exposed metrics using the
kafka.prometheus.metrics.reporter.allowlistproperty. If not configured, a default set of metrics is exposed.When needed, it is possible to configure the
allowlistper client type. For example, by using thekafka.adminprefix and settingkafka.admin.prometheus.metrics.reporter.allowlist=, all admin client metrics are excluded.You can add any plugin configuration to the Kafka Bridge properties file using
kafka.,kafka.admin.,kafka.producer., andkafka.consumer.prefixes. In the event that the same property is configured with multiple prefixes, the most specific prefix takes precedence. For example,kafka.producer.prometheus.metrics.reporter.allowlisttakes precedence overkafka.prometheus.metrics.reporter.allowlist.Run the Kafka Bridge run script.
Running the Kafka Bridge
./bin/kafka_bridge_run.sh --config-file=<path>/application.properties
./bin/kafka_bridge_run.sh --config-file=<path>/application.propertiesCopy to Clipboard Copied! Toggle word wrap Toggle overflow With metrics enabled, you can scrape metrics in Prometheus format from the
/metricsendpoint of the Kafka Bridge.
3.4. Configuring distributed tracing リンクのコピーリンクがクリップボードにコピーされました!
Enable distributed tracing to trace messages consumed and produced by the Kafka Bridge, and HTTP requests from client applications.
Properties to enable tracing are present in the application.properties file. To enable distributed tracing, do the following:
-
Set the
bridge.tracingproperty value to enable the tracing you want to use. The only possible value isopentelemetry. - Set environment variables for tracing.
With the default configuration, OpenTelemetry tracing uses OTLP as the exporter protocol. By configuring the OTLP endpoint, you can still use a Jaeger backend instance to get traces.
Jaeger has supported the OTLP protocol since version 1.35. Older Jaeger versions cannot get traces using the OTLP protocol.
OpenTelemetry defines an API specification for collecting tracing data as spans of metrics data. Spans represent a specific operation. A trace is a collection of one or more spans.
Traces are generated when the Kafka Bridge does the following:
- Sends messages from Kafka to consumer HTTP clients
- Receives messages from producer HTTP clients to send to Kafka
Jaeger implements the required APIs and presents visualizations of the trace data in its user interface for analysis.
To have end-to-end tracing, you must configure tracing in your HTTP clients.
Streams for Apache Kafka no longer supports OpenTracing. If you were previously using OpenTracing with the bridge.tracing=jaeger option, we encourage you to transition to using OpenTelemetry instead.
Prerequisites
Procedure
Edit the
application.propertiesfile provided with the Kafka Bridge installation archive.Use the
bridge.tracingproperty to enable the tracing you want to use.Example configuration to enable OpenTelemetry
bridge.tracing=opentelemetry
bridge.tracing=opentelemetry1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The property for enabling OpenTelemetry is uncommented by removing the
#at the beginning of the line.
With tracing enabled, you initialize tracing when you run the Kafka Bridge script.
- Save the configuration file.
Set the environment variables for tracing.
Environment variables for OpenTelemetry
OTEL_SERVICE_NAME=my-tracing-service OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
OTEL_SERVICE_NAME=my-tracing-service1 OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:43172 Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the Kafka Bridge script with the property enabled for tracing.
Running the Kafka Bridge with OpenTelemetry enabled
./bin/kafka_bridge_run.sh --config-file=<path>/application.properties
./bin/kafka_bridge_run.sh --config-file=<path>/application.propertiesCopy to Clipboard Copied! Toggle word wrap Toggle overflow The internal consumers and producers of the Kafka Bridge are now enabled for tracing.
3.4.1. Specifying tracing systems with OpenTelemetry リンクのコピーリンクがクリップボードにコピーされました!
Instead of the default OTLP tracing system, you can specify other tracing systems that are supported by OpenTelemetry.
If you want to use another tracing system with OpenTelemetry, do the following:
- Add the library of the tracing system to the Kafka classpath.
Add the name of the tracing system as an additional exporter environment variable.
Additional environment variable when not using OTLP
OTEL_SERVICE_NAME=my-tracing-service OTEL_TRACES_EXPORTER=zipkin OTEL_EXPORTER_ZIPKIN_ENDPOINT=http://localhost:9411/api/v2/spans
OTEL_SERVICE_NAME=my-tracing-service OTEL_TRACES_EXPORTER=zipkin1 OTEL_EXPORTER_ZIPKIN_ENDPOINT=http://localhost:9411/api/v2/spans2 Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.4.2. Supported Span attributes リンクのコピーリンクがクリップボードにコピーされました!
The Kafka Bridge adds, in addition to the standard OpenTelemetry attributes, the following attributes from the OpenTelemetry standard conventions for HTTP to its spans.
| Attribute key | Attribute value |
|
|
Hardcoded to |
|
| The http method used to make the request |
|
| The URI scheme component |
|
| The URI path component |
|
| The URI query component |
|
| The name of the Kafka topic being produced to or read from |
|
|
Hardcoded to |
|
|
|