Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the Strimzi Metrics Reporter #954

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
* Dropped support for OpenAPI v2 Swagger specification.
* The `/openapi/v2` endpoint returns HTTP 410 Gone.
* Both the `/openapi` and `/openapi/v3` endpoints return the OpenAPI v3 definition of the bridge REST API.
* Added support for the [Strimzi Metrics Reporter](https://github.com/strimzi/metrics-reporter) metrics.
* This is a Kafka plugin that directly exports metrics in Prometheus format without passing through JMX, and can be enabled by setting `bridge.metrics=strimziMetricsReporter`.
* The JMX Exporter metrics can still be enabled by setting `bridge.metrics=jmxPrometheusExporter`.

### Changes, deprecations and removals

* `KAFKA_BRIDGE_METRICS_ENABLED` configuration has been deprecated.
In order to keep the current behaviour and use JMX Exporter, the `bridge.metrics` property has to be set to `jmxPrometheusExporter`.

## 0.31.1

Expand Down
24 changes: 24 additions & 0 deletions bin/docker/kafka_bridge_config_generator.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
#!/usr/bin/env bash

if [ -n "$STRIMZI_METRICS" ]; then
BRIDGE_METRICS="bridge.metrics=${STRIMZI_METRICS}"
fi

if [ -n "$STRIMZI_TRACING" ]; then
BRIDGE_TRACING="bridge.tracing=${STRIMZI_TRACING}"
fi

BRIDGE_PROPERTIES=$(cat <<-EOF
#Bridge configuration
bridge.id=${KAFKA_BRIDGE_ID}
${BRIDGE_METRICS}
${BRIDGE_TRACING}
EOF
)

if [ -n "$KAFKA_BRIDGE_METRICS_JMX_CONFIG" ]; then
METRICS_JMX_PROPERTIES=$(cat <<EOF
#JMX Exporter configuration
bridge.metrics.jmx.exporter.config.path=${KAFKA_BRIDGE_METRICS_JMX_CONFIG}
EOF
)
fi

if [ -n "$KAFKA_BRIDGE_METRICS_SMR_CONFIG" ]; then
METRICS_SMR_PROPERTIES=$(cat <<EOF
#Strimzi Reporter configuration
${KAFKA_BRIDGE_METRICS_SMR_CONFIG}
EOF
)
fi

SECURITY_PROTOCOL=PLAINTEXT

if [ "$KAFKA_BRIDGE_TLS" = "true" ]; then
Expand Down Expand Up @@ -163,6 +184,9 @@ EOF
PROPERTIES=$(cat <<EOF
$BRIDGE_PROPERTIES

$METRICS_JMX_PROPERTIES
$METRICS_SMR_PROPERTIES

$KAFKA_PROPERTIES

$ADMIN_CLIENT_PROPERTIES
Expand Down
12 changes: 12 additions & 0 deletions config/application.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
#Bridge related settings
bridge.id=my-bridge

# uncomment the following line to enable JMX Exporter metrics, check the documentation for more details
#bridge.metrics=jmxPrometheusExporter
# optionally, you can also set a custom configuration file
#bridge.metrics.jmx.exporter.config.path=/path/to/my-jmx-exporter-config.yaml

# uncomment the following lines to enable Strimzi Reporter metrics, check the documentation for more details
#bridge.metrics=strimziMetricsReporter
fvaleri marked this conversation as resolved.
Show resolved Hide resolved
#kafka.metric.reporters=io.strimzi.kafka.metrics.KafkaPrometheusMetricsReporter
#kafka.prometheus.metrics.reporter.listener.enable=false
#kafka.prometheus.metrics.reporter.allowlist=.*

# uncomment the following line (bridge.tracing) to enable OpenTelemetry tracing, check the documentation for more details
#bridge.tracing=opentelemetry

Expand Down
6 changes: 4 additions & 2 deletions documentation/assemblies/assembly-kafka-bridge-config.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
[role="_abstract"]
Configure a deployment of the Kafka Bridge using configuration properties.
Configure Kafka and specify the HTTP connection details needed to be able to interact with Kafka.
It is possible to enable metrics in Prometheus format with JMX Prometheus Exporter or Strimzi 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.

NOTE: Use the `KafkaBridge` resource to configure properties when you are xref:overview-components-running-kafka-bridge-cluster-{context}[running the Kafka Bridge on Kubernetes].

include::modules/proc-configuring-kafka-bridge.adoc[leveloffset=+1]
include::modules/proc-configuring-kafka-bridge-metrics.adoc[leveloffset=+1]
include::modules/proc-configuring-kafka-bridge-tracing.adoc[leveloffset=+1]
include::modules/proc-configuring-kafka-bridge-jmx-metrics.adoc[leveloffset=+1]
include::modules/proc-configuring-kafka-bridge-smr-metrics.adoc[leveloffset=+1]
include::modules/proc-configuring-kafka-bridge-tracing.adoc[leveloffset=+1]
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[id='proc-configuring-kafka-bridge-jmx-metrics-{context}']
fvaleri marked this conversation as resolved.
Show resolved Hide resolved
= Configuring JMX Exporter metrics

[role="_abstract"]
Enable metrics for the Kafka Bridge by setting the `bridge.metrics` configuration.

.Prerequisites

* xref:proc-downloading-kafka-bridge-{context}[The Kafka Bridge installation archive is downloaded].

.Procedure

. Set the `bridge.metrics` configuration to `jmxPrometheusExporter`.
+
.Configuration for enabling metrics

[source,properties]
----
bridge.metrics=jmxPrometheusExporter
----
+
Optionally, you can set a custom JMX Exporter configuration file using the `bridge.metrics.jmx.exporter.config.path` property.
If this is not set, a default configuration will be applied.

. Run the Kafka Bridge script to enable metrics.
+
.Running the Kafka Bridge to enable metrics
[source,shell]
----
./bin/kafka_bridge_run.sh --config-file=<path>/application.properties
----
+
With metrics enabled, you can use `GET /metrics` with the `/metrics` endpoint to retrieve Kafka Bridge metrics in Prometheus format.
30 changes: 0 additions & 30 deletions documentation/modules/proc-configuring-kafka-bridge-metrics.adoc

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[id='proc-configuring-kafka-bridge-smr-metrics-{context}']
fvaleri marked this conversation as resolved.
Show resolved Hide resolved
= Configuring Strimzi Metrics Reporter metrics

[role="_abstract"]
Enable metrics for the Kafka Bridge by setting the `bridge.metrics` configuration.

.Prerequisites

* xref:proc-downloading-kafka-bridge-{context}[The Kafka Bridge installation archive is downloaded].

.Procedure

. Set the `bridge.metrics` configuration to `strimziMetricsReporter` and related configuration.
+
.Configuration for enabling metrics

[source,properties]
----
bridge.metrics=strimziMetricsReporter
kafka.metric.reporters=io.strimzi.kafka.metrics.KafkaPrometheusMetricsReporter
kafka.prometheus.metrics.reporter.listener.enable=false
kafka.prometheus.metrics.reporter.allowlist=.*
----
+
You can add any plugin configuration to the Bridge properties file using the `kafka.` prefix.
See the https://github.com/strimzi/metrics-reporter[Strimzi Metrics Reporter documentation] for more details.

. Run the Kafka Bridge script to enable metrics.
+
.Running the Kafka Bridge to enable metrics
[source,shell]
----
./bin/kafka_bridge_run.sh --config-file=<path>/application.properties
----
+
With metrics enabled, you can use `GET /metrics` with the `/metrics` endpoint to retrieve Kafka Bridge metrics in Prometheus format.
27 changes: 27 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
<checkstyle.version>10.12.2</checkstyle.version>
<hamcrest.version>2.2</hamcrest.version>
fvaleri marked this conversation as resolved.
Show resolved Hide resolved
<junit.version>5.8.2</junit.version>
<mockito.version>4.11.0</mockito.version>
<maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
<maven-surefire-plugin.version>3.0.0-M7</maven-surefire-plugin.version>
<maven-failsafe-plugin.version>3.0.0-M7</maven-failsafe-plugin.version>
Expand All @@ -131,6 +132,7 @@
<spotbugs.version>4.7.3</spotbugs.version>
<maven.spotbugs.version>4.7.3.0</maven.spotbugs.version>
<strimzi-oauth.version>0.15.0</strimzi-oauth.version>
<strimzi-metrics-reporter.version>0.1.0</strimzi-metrics-reporter.version>
<opentelemetry.version>1.34.1</opentelemetry.version>
<opentelemetry-alpha.version>1.34.1-alpha</opentelemetry-alpha.version>
<opentelemetry.instrumentation.version>1.32.0-alpha</opentelemetry.instrumentation.version>
Expand Down Expand Up @@ -295,6 +297,11 @@
<artifactId>micrometer-registry-prometheus</artifactId>
<version>${micrometer.version}</version>
</dependency>
<dependency>
<groupId>io.strimzi</groupId>
<artifactId>metrics-reporter</artifactId>
<version>${strimzi-metrics-reporter.version}</version>
</dependency>
<dependency>
<groupId>io.prometheus.jmx</groupId>
<artifactId>collector</artifactId>
Expand All @@ -305,6 +312,16 @@
<artifactId>prometheus-metrics-model</artifactId>
<version>${prometheus-client.version}</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>prometheus-metrics-instrumentation-jvm</artifactId>
<version>${prometheus-client.version}</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>prometheus-metrics-exporter-httpserver</artifactId>
<version>${prometheus-client.version}</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>prometheus-metrics-exposition-textformats</artifactId>
Expand Down Expand Up @@ -421,6 +438,12 @@
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.strimzi</groupId>
<artifactId>strimzi-test-container</artifactId>
Expand Down Expand Up @@ -584,6 +607,10 @@
<!-- OpenTelemetry - used via classpath configuration opentelemetry-exporter-sender-grpc is required at runtime to replace OKHTTP -->
<ignoredUnusedDeclaredDependency>io.grpc:grpc-netty-shaded:jar</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>com.google.guava:guava</ignoredUnusedDeclaredDependency>
<!-- Strimzi Metrics Reporter - used via classpath configuration -->
<ignoredUnusedDeclaredDependency>io.strimzi:metrics-reporter</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>io.prometheus:prometheus-metrics-instrumentation-jvm</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>io.prometheus:prometheus-metrics-exporter-httpserver</ignoredUnusedDeclaredDependency>
</ignoredUnusedDeclaredDependencies>
</configuration>
</execution>
Expand Down
Loading
Loading