Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Valeri <[email protected]>
  • Loading branch information
fvaleri committed Dec 20, 2024
1 parent fec982f commit 5ffcbc9
Showing 1 changed file with 36 additions and 32 deletions.
68 changes: 36 additions & 32 deletions 090-integrate-bridge-with-metrics-reporter.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@ This is a Kafka `MetricsReporter` plugin that directly exposes metrics in Promet

## Current situation

The Cluster Operator exposes Kafka metrics through the [Prometheus JMX Exporter](https://github.com/prometheus/jmx_exporter), which can be configured using the shared `metricsConfig` schema.
The HTTP Bridge allow users to enable or disable the metrics endpoint using the `KAFKA_BRIDGE_METRICS_ENABLED` environment variable.
When this variable is set to true, the Bridge creates the JMX Exporter's `JmxCollector` class with hard coded configuration.
This configuration is a JMX metrics exporter YAML distributed as an embedded resource within the Bridge JAR file.

When deploying the Bridge through the Cluster Operator, a similar configuration is available in the `KafkaBridge` CRD.

```sh
spec:
enableMetrics: true
```

This is different from how the metrics endpoint is enabled in all the other major components deployed bu the Cluster Operator.
The Cluster Operator exposes metrics through the [Prometheus JMX Exporter](https://github.com/prometheus/jmx_exporter), which can be configured using the shared `metricsConfig` schema.
This schema has a `type` property that only allows the `jmxPrometheusExporter` value, and a reference to a `ConfigMap` containing its configuration.

```sh
Expand All @@ -20,41 +32,20 @@ metricsConfig:
At runtime, this configuration enables a Java agent that exposes Kafka JMX metrics in Prometheus format through an HTTP endpoint on port 9404.
Note that this agent depends on the [Kafka JMX Reporter](https://github.com/apache/kafka/blob/3.9.0/clients/src/main/java/org/apache/kafka/common/metrics/JmxReporter.java) plugin, which is enabled by default.

The only major component not using the `metricsConfig` schema is the [HTTP Bridge](https://github.com/strimzi/strimzi-kafka-bridge), as it directly instantiates the JMX Exporter's `JmxCollector` class with hard coded configuration.
The `KafkaBridge` CRD does not support a type system for metrics configuration, but a simple boolean configuration to enable/disable metrics.

```sh
spec:
enableMetrics: true
```

## Motivation

We want to support the Strimzi Metrics Reporter as an alternative way of configuring metrics across all components.
In order to provide a consistent user experience, the HTTP Bridge should align with all the other components in terms of metrics configuration.
When deploying configuring major components through the Cluster Operator, we want to provide a consistent user experience, so the HTTP Bridge should also support the `metricsConfig` schema.

## Proposal

As specified in SIP-064, a new metrics config type called `strimziMetricsReporter` will be added to `metricsConfig` schema along with its configuration.
Only the Strimzi Metrics Reporter's `prometheus.metrics.reporter.allowlist` property will be configurable by users when using the Cluster Operator.
This configuration is a comma separated list of regex patterns that is used by the plugin to filter metrics to collect.
All other plugin configuration properties will be locked down, including the port that will be set to 9404 to avoid conflicts with other ports.

```sh
spec:
kafka:
metricsConfig:
type: strimziMetricsReporter
values:
allowList:
- "kafka_log.*"
- "kafka_network.*"
```
The Bridge will support both JMX Exporter and Strimzi Reporter as metrics configuration types.
It will also provide new configurations for the integration with the Cluster Operator.

### HTTP Bridge
### Metrics configuration types

The HTTP Bridge project will be updated to support multiple types of metrics configurations.
A new `bridge.metrics` property will be available, and will only accept `jmxPrometheusExporter` and `strimziMetricsReporter`.
A new `bridge.metrics` property will be available within the `application.properties` configuration file, and will only accept `jmxPrometheusExporter` and `strimziMetricsReporter`.
Any other value will raise an error and the application will fail to start with an appropriate error message.

When running in standalone mode with `strimziMetricsReporter`, the user will be able to configure any Strimzi Metrics Reporter property using the `kafka.` prefix.
Expand All @@ -81,11 +72,23 @@ This script will be updated to also include `bridge.metrics` and related configu
The Bridge will also try to load the JMX Exporter configuration file from the path specified by the `bridge.metrics.jmx.exporter.config.path` property.
If not specified or not found, it will fall back to the hard coded configuration.

### Cluster Operator
### Cluster Operator deploy

Like for all the other major components, the `KafkaBridge` CRD will also include `metricsConfig` with support for `strimziMetricsReporter` type.

Three new environment variables will be introduced to pass the metrics configuration in the HTTP Bridge container:
This is how the Strimzi Metrics Reporter configuration will look like:

```sh
spec:
metricsConfig:
type: strimziMetricsReporter
values:
allowList:
- "kafka_log.*"
- "kafka_network.*"
```

Three new environment variables will be introduced to pass the metrics configuration to the Bridge's container:

1. `STRIMZI_METRICS`: This will contain the `metricsConfig` types to enable (one of `jmxPrometheusExporter` and `strimziMetricsReporter`).
2. `KAFKA_BRIDGE_METRICS_JMX_CONFIG`: Used with `STRIMZI_METRICS=jmxPrometheusExporter` to pass the configuration file path.
Expand All @@ -94,10 +97,11 @@ Three new environment variables will be introduced to pass the metrics configura
The `enableMetrics` property will be deprecated and removed in a future release.
In case they are both set, `metricsConfig` will take precedence over `enableMetrics`.

All Strimzi Metrics Reporter configurations will be locked down with the exception of `allowList`.
Unlike the other major components, the metrics endpoint port will be set to 8080, which is the one already used to expose the REST API.
The JMX Exporter configuration file will be stored in a `ConfigMap` and mounted in the Bridge container under `/opt/strimzi/custom-config`.
The full configuration file passed to the Bridge container will be `/opt/strimzi/custom-config/metrics-config.yml`.

The JMX Exporter configuration file contained in a `ConfigMap` will be mounted in the HTTP Bridge container under `/opt/strimzi/custom-config/` to be loaded at runtime.
Metrics will be exposed through the Bridge HTTP server, so the reporter's listener will be disabled with `kafka.prometheus.metrics.reporter.listener.enable=false`.
The Strimzi Metrics Reporter configurations will be locked down with the exception of the `allowlist` property.

## Affected/not affected projects

Expand Down

0 comments on commit 5ffcbc9

Please sign in to comment.