-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 to Kafka brokers/controllers components #11051
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
package io.strimzi.api.kafka.model.common.metrics; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
import io.strimzi.api.kafka.model.common.Constants; | ||
import io.strimzi.api.kafka.model.common.ExternalConfigurationReference; | ||
|
@@ -31,7 +30,6 @@ public class JmxPrometheusExporterMetrics extends MetricsConfig { | |
private ExternalConfigurationReference valueFrom; | ||
|
||
@Description("ConfigMap entry where the Prometheus JMX Exporter configuration is stored. ") | ||
@JsonProperty(required = true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC, you had to make it optional because of how the API is constructed. But it is required. So, we have to make sure:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI: I opened #11068 for the CEL validation. Once/if merged, you would need to add the corresponding rule here. |
||
public ExternalConfigurationReference getValueFrom() { | ||
return valueFrom; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright Strimzi authors. | ||
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html). | ||
*/ | ||
package io.strimzi.api.kafka.model.common.metrics; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
import io.strimzi.api.kafka.model.common.Constants; | ||
import io.strimzi.crdgenerator.annotations.Description; | ||
import io.sundr.builder.annotations.Buildable; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.ToString; | ||
|
||
/** | ||
* Strimzi Metrics Reporter. | ||
*/ | ||
@Buildable( | ||
editableEnabled = false, | ||
builderPackage = Constants.FABRIC8_KUBERNETES_API | ||
) | ||
@JsonPropertyOrder({"type", "values"}) | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@EqualsAndHashCode(callSuper = true) | ||
@ToString(callSuper = true) | ||
public class StrimziMetricsReporter extends MetricsConfig { | ||
public static final String TYPE_STRIMZI_METRICS_REPORTER = "strimziMetricsReporter"; | ||
|
||
private StrimziMetricsReporterValues values; | ||
|
||
@Description("Must be `" + TYPE_STRIMZI_METRICS_REPORTER + "`") | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@Override | ||
public String getType() { | ||
return TYPE_STRIMZI_METRICS_REPORTER; | ||
} | ||
|
||
@Description("Configuration values for the Strimzi Metrics Reporter.") | ||
public StrimziMetricsReporterValues getValues() { | ||
return values; | ||
} | ||
|
||
public void setValues(StrimziMetricsReporterValues values) { | ||
this.values = values; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright Strimzi authors. | ||
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html). | ||
*/ | ||
package io.strimzi.api.kafka.model.common.metrics; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
import io.strimzi.api.kafka.model.common.Constants; | ||
import io.strimzi.api.kafka.model.common.UnknownPropertyPreserving; | ||
import io.strimzi.crdgenerator.annotations.Description; | ||
import io.sundr.builder.annotations.Buildable; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.ToString; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* Strimzi Metrics Reporter configuration. | ||
*/ | ||
@Buildable( | ||
editableEnabled = false, | ||
builderPackage = Constants.FABRIC8_KUBERNETES_API | ||
) | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@JsonPropertyOrder({"allowList"}) | ||
@EqualsAndHashCode() | ||
@ToString | ||
public class StrimziMetricsReporterValues implements UnknownPropertyPreserving { | ||
private static final String DEFAULT_REGEX = ".*"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should have the default tailor-made for each component. (Or it should be required) And the allow list should default to null to allow you to distinguish between not set and set to |
||
|
||
private List<String> allowList = List.of(DEFAULT_REGEX); | ||
private Map<String, Object> additionalProperties; | ||
|
||
@Description("A comma separated list of regex patterns to specify the metrics to collect. Default: `" + DEFAULT_REGEX + "`.") | ||
@JsonInclude(value = JsonInclude.Include.NON_NULL) | ||
public List<String> getAllowList() { | ||
return allowList; | ||
} | ||
|
||
public void setAllowList(List<String> allowList) { | ||
this.allowList = allowList; | ||
} | ||
|
||
@Override | ||
public Map<String, Object> getAdditionalProperties() { | ||
return this.additionalProperties != null ? this.additionalProperties : Map.of(); | ||
} | ||
|
||
@Override | ||
public void setAdditionalProperty(String name, Object value) { | ||
if (this.additionalProperties == null) { | ||
this.additionalProperties = new HashMap<>(2); | ||
} | ||
this.additionalProperties.put(name, value); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,7 +62,8 @@ public class KafkaClusterSpec implements HasConfigurableMetrics, HasConfigurable | |
+ "cruise.control.metrics.topic, cruise.control.metrics.reporter.bootstrap.servers, " | ||
+ "node.id, process.roles, controller., metadata.log.dir, zookeeper.metadata.migration.enable, " // KRaft options | ||
+ "client.quota.callback.static.kafka.admin., client.quota.callback.static.produce, client.quota.callback.static.fetch, " | ||
+ "client.quota.callback.static.storage.per.volume.limit.min.available., client.quota.callback.static.excluded.principal.name.list"; | ||
+ "client.quota.callback.static.storage.per.volume.limit.min.available., client.quota.callback.static.excluded.principal.name.list, " | ||
+ "kafka.metric.reporters, prometheus.metrics.reporter."; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we disabling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The naming here is a little unfortunate. We are not disabling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no option From the Kafka docs, |
||
|
||
public static final String FORBIDDEN_PREFIX_EXCEPTIONS = "zookeeper.connection.timeout.ms, sasl.server.max.receive.size, " | ||
+ "ssl.cipher.suites, ssl.protocol, ssl.enabled.protocols, ssl.secure.random.implementation, " | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,7 @@ public static Map<String, String> generateMetricsAndLogConfigMapData(Reconciliat | |
data.put(supportsLogging.logging().configMapKey(), supportsLogging.logging().loggingConfiguration(reconciliation, metricsAndLogging.loggingCm())); | ||
} | ||
|
||
if (model instanceof SupportsMetrics supportMetrics) { | ||
if (model instanceof SupportsMetrics supportMetrics && supportMetrics.metrics() != null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this? |
||
String parseResult = supportMetrics.metrics().metricsJson(reconciliation, metricsAndLogging.metricsCm()); | ||
if (parseResult != null) { | ||
data.put(MetricsModel.CONFIG_MAP_KEY, parseResult); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would leave this sentence out. It is confusing.