-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add support for the Strimzi Metrics Reporter to Kafka brokers/controllers components #11051
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
base: main
Are you sure you want to change the base?
Add support for the Strimzi Metrics Reporter to Kafka brokers/controllers components #11051
Conversation
e569be2
to
1180ee2
Compare
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 left some comments after an initial pass. You should also update the names / description / CHANGELOG to make it clear what this really does. Kafka compoenents are brokers/controllers, Connect and MM2. You add this only for brokers/controllers. It should be clear from the CHANGELOG and PR name / desc.
packaging/examples/metrics/grafana-dashboards/strimzi-kafka.json
Outdated
Show resolved
Hide resolved
packaging/examples/metrics/grafana-dashboards/strimzi-kraft.json
Outdated
Show resolved
Hide resolved
api/src/main/java/io/strimzi/api/kafka/model/kafka/KafkaClusterSpec.java
Outdated
Show resolved
Hide resolved
cluster-operator/src/main/java/io/strimzi/operator/cluster/model/ConfigMapUtils.java
Outdated
Show resolved
Hide resolved
cluster-operator/src/main/java/io/strimzi/operator/cluster/model/CruiseControl.java
Outdated
Show resolved
Hide resolved
cluster-operator/src/main/java/io/strimzi/operator/cluster/model/KafkaCluster.java
Outdated
Show resolved
Hide resolved
...perator/src/main/java/io/strimzi/operator/cluster/model/KafkaBrokerConfigurationBuilder.java
Outdated
Show resolved
Hide resolved
cluster-operator/src/main/java/io/strimzi/operator/cluster/model/KafkaCluster.java
Outdated
Show resolved
Hide resolved
1180ee2
to
f943007
Compare
@scholzj I am currently working on the changes I did not comment on yet. |
api/src/main/java/io/strimzi/api/kafka/model/common/metrics/StrimziMetricsReporterValues.java
Outdated
Show resolved
Hide resolved
api/src/main/java/io/strimzi/api/kafka/model/common/metrics/JmxPrometheusExporterMetrics.java
Show resolved
Hide resolved
84fb016
to
8f5b28f
Compare
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 left some more comments. There also seem to be many unaddressed older comments. Not sure if that was intentional or not at this point.
cluster-operator/src/main/java/io/strimzi/operator/cluster/model/CruiseControl.java
Outdated
Show resolved
Hide resolved
cluster-operator/src/main/java/io/strimzi/operator/cluster/model/CruiseControl.java
Outdated
Show resolved
Hide resolved
...tor/src/main/java/io/strimzi/operator/cluster/model/metrics/StrimziMetricsReporterModel.java
Outdated
Show resolved
Hide resolved
...ator/src/main/java/io/strimzi/operator/cluster/model/metrics/JmxPrometheusExporterModel.java
Show resolved
Hide resolved
cluster-operator/src/main/java/io/strimzi/operator/cluster/model/metrics/MetricsModel.java
Show resolved
Hide resolved
@scholzj I'm supporting Owen with this feature. He is working on and will eventually address all comments. |
@scholzj I know progress is going quite slowly. I will address the previous comments shortly. I'm currently working on the CEL validation. When that is committed, I'll go back and tackle the older comments and work through them. |
No worries Owen, I was just unsure what the expected state is. I did not intend to put any pressure on your. Sorry. |
ece3b1f
to
75a829f
Compare
The build failed with the following tests: |
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.
Hi @OwenCorrigan76, we still need to do some changes and address the remaining comments, but it works fine.
For the KafkaCrdIT.testKafkaWithNullMaintenance
failure, I think we simply need to update the expected error messages removing the invalid:
prefix. Now, you get invalid: [
, rather than invalid:
. With CEL validation rules, we get the additional error message "validation rules were not checked".
api/src/main/java/io/strimzi/api/kafka/model/kafka/KafkaClusterSpec.java
Outdated
Show resolved
Hide resolved
api/src/main/java/io/strimzi/api/kafka/model/common/metrics/JmxPrometheusExporterMetrics.java
Outdated
Show resolved
Hide resolved
api/src/main/java/io/strimzi/api/kafka/model/common/metrics/StrimziMetricsReporterValues.java
Outdated
Show resolved
Hide resolved
cluster-operator/src/main/java/io/strimzi/operator/cluster/model/CruiseControl.java
Outdated
Show resolved
Hide resolved
cluster-operator/src/main/java/io/strimzi/operator/cluster/model/CruiseControl.java
Outdated
Show resolved
Hide resolved
...perator/src/main/java/io/strimzi/operator/cluster/model/KafkaBrokerConfigurationBuilder.java
Outdated
Show resolved
Hide resolved
cluster-operator/src/main/java/io/strimzi/operator/cluster/model/KafkaConnectCluster.java
Show resolved
Hide resolved
packaging/examples/metrics/strimzi-metrics-reporter/kafka-metrics.yaml
Outdated
Show resolved
Hide resolved
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.
@OwenCorrigan76 I was wrong on the "Unsupported metrics type", please correct.
api/src/main/java/io/strimzi/api/kafka/model/common/metrics/JmxPrometheusExporterMetrics.java
Show resolved
Hide resolved
cluster-operator/src/main/java/io/strimzi/operator/cluster/model/KafkaCluster.java
Outdated
Show resolved
Hide resolved
cluster-operator/src/main/java/io/strimzi/operator/cluster/model/KafkaConnectCluster.java
Outdated
Show resolved
Hide resolved
...perator/src/main/java/io/strimzi/operator/cluster/model/KafkaBrokerConfigurationBuilder.java
Outdated
Show resolved
Hide resolved
4304607
to
f88ec2c
Compare
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.
Changes looks good to me for now, but we still have some comments to address.
3c94f43
to
3969049
Compare
I guess this will need a rebase after #11379. |
@OwenCorrigan76 before having another review pass, this PR should be rebased, let us know when it's ready again. Thanks! |
6af487c
to
d4a8609
Compare
Squashed commits for rebasing. I will deal with conflicts now. |
d4a8609
to
b89fa8d
Compare
@strimzi/maintainers can one of you trigger the ST pipeline? Thanks. |
/azp run regression |
Azure Pipelines successfully started running 1 pipeline(s). |
@ppatierno looks like failing tests hit timeout and seems to be unrelated. |
/packit test --labels regression,upgrade |
TF failures are caused by TF outage. I will restart the jobs once the outage will be resolved. |
/packit test --labels regression,upgrade |
TF failed again. |
I am afraid they are still experiencing the outage. In case it is blocking you, feel free to ignore it. I will try to restart it tomorrow and hope everything will be fine that time. |
This is ready for another review, when you get a chance. Thanks a mil. |
b89fa8d
to
b28fde7
Compare
@@ -471,9 +502,9 @@ public void testNullUserConfiguration() { | |||
} | |||
|
|||
@ParallelTest | |||
public void testNullUserConfigurationAndCCReporter() { | |||
public void testNullUserConfigurationWithCruiseControlMetricsReporter() { |
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.
What if you add the new tests at the end rather than to the middle and mess up the diff and GitHub history?
...tor/src/test/java/io/strimzi/operator/cluster/model/KafkaBrokerConfigurationBuilderTest.java
Show resolved
Hide resolved
spec: | ||
kafka: | ||
version: 4.0.0 | ||
metadataVersion: 4.0-IV0 |
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.
Should this be IV3
as in the regular example (https://github.com/strimzi/strimzi-kafka-operator/blob/main/packaging/examples/metrics/kafka-metrics.yaml)?
* @param values List configuration values. | ||
*/ | ||
public static void createOrAddListConfig(AbstractConfiguration kafkaConfig, String key, String values) { | ||
if (kafkaConfig != null && key != null && !key.isBlank() && values != null && !values.isBlank()) { |
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.
Not 100% sure, but is this missing some else branch?
The Javadc says Append list configuration values or create a new list configuration if missing.
-> So I would expect that you need to handle the situation when the things are not set?
Or maybe you know they are always set and do not need this check?
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.
@OwenCorrigan76 this method should have private visibility.
@scholzj null/blank checks are there because this will become a shared utility and move to ModelUtils a soon as the KC/MM2 PR will be ready. Currently, we simply ignore invalid input, but we could raise and exception or log a warning. Wdyt?
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'm not sure what PR you're referring to. But I think the comment stands. If you really need to do the check, there really needs to be error handling for it.
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.
Yep, I agree on adding error handling.
Arrays.stream(existingConfig.split(",")) | ||
.map(String::trim) | ||
.filter(s -> !s.isEmpty()) | ||
.collect(Collectors.toCollection(LinkedHashSet::new)); | ||
Set<String> newValues = Arrays.stream(values.split(",")) | ||
.map(String::trim) | ||
.filter(s -> !s.isEmpty()) | ||
.collect(Collectors.toCollection(LinkedHashSet::new)); |
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.
Should we use something like asList(namespacesList.trim().split("\\s*,+\\s*"))
? We already use that in ConfigParameterParser to parse namespace list. But to be honest, I have no idea which way would be faster.
Also, why do you use LinkedHashSet
? Does the order really matter here? If it does, a comment explaining that might be useful.
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.
@scholzj list would be probably faster, but it hardly makes a difference with few configuration values. Once this method becomes a shared utility, values could potentially be user-provided values, so we thought it's nice to preserve ordering.
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.
With the speed, I was more referring to the splitting than list versus set.
As for the ordering, if it matters, fine. But it should be explained in the comment as I suggest.
b28fde7
to
22dd7a2
Compare
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.
Few more nits. But hopefully that will be it.
if (kafkaConfig == null) throw new IllegalArgumentException("Configuration is required"); | ||
if (key == null || key.isBlank()) throw new IllegalArgumentException("Configuration key is required"); | ||
if (values == null || values.isBlank()) throw new IllegalArgumentException("Configuration values are required"); |
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 think if you properly format it with {
/ }
, it would be more readable and clearer what exactly are you doing there. I do not think we use this form in many parts of the code base, if somewhere at all.
.map(key -> assertThrows(IllegalArgumentException.class, () -> KafkaBrokerConfigurationBuilder.createOrAddListConfig(config, key, "test-value-3"))) | ||
.forEach(e -> assertThat(e.getMessage(), is("Configuration key is required") | ||
)); | ||
|
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.
Empty line not needed.
/packit test --labels regression,upgrade |
This patch adds support for the Strimzi Metrics Reporter to brokers and controllers as described by the following proposal: https://github.com/strimzi/proposals/blob/main/064-prometheus-metrics-reporter.md Signed-off-by: ocorriga <ocorriga@redhat.com> Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Squash commits Address initial feedback Signed-off-by: ocorriga <ocorriga@redhat.com> Reverse dashboards and fix build issue Signed-off-by: ocorriga <ocorriga@redhat.com> Update derived resources Signed-off-by: ocorriga <ocorriga@redhat.com> Trigger build Signed-off-by: Federico Valeri <fedevaleri@gmail.com> Add MetricsModel interface and refactor affected classes Signed-off-by: ocorriga <ocorriga@redhat.com> Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Add CEL validation and address comments Signed-off-by: ocorriga <ocorriga@redhat.com> Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Addressing latest comments Signed-off-by: ocorriga <ocorriga@redhat.com> Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> add TODO in withStrimziMetricsReporter Signed-off-by: ocorriga <ocorriga@redhat.com> Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> address latest comments Signed-off-by: ocorriga <ocorriga@redhat.com> Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Add StrimziMetricsReporterConfig class Signed-off-by: ocorriga <ocorriga@redhat.com> Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Add defaults for allowlist Signed-off-by: ocorriga <ocorriga@redhat.com> Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Refactor withUserConfiguration and add tests Signed-off-by: ocorriga <ocorriga@redhat.com> Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Address Comments Signed-off-by: ocorriga <ocorriga@redhat.com> Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Revert Connect script ENV VAR Signed-off-by: ocorriga <ocorriga@redhat.com> Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Address Comments on common-configuration doc and fix typos Signed-off-by: ocorriga <ocorriga@redhat.com> Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Fix ConfigMap naming for tests Signed-off-by: ocorriga <ocorriga@redhat.com> Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Address additional Comments Signed-off-by: ocorriga <ocorriga@redhat.com> Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Address Jakub's and Tina's Comments Signed-off-by: ocorriga <ocorriga@redhat.com> Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Add comments to distinguish between kafka and yammer metrics Signed-off-by: ocorriga <ocorriga@redhat.com> Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Address Paolo's comments Signed-off-by: ocorriga <ocorriga@redhat.com> Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Remove added comment writer.println Signed-off-by: ocorriga <ocorriga@redhat.com> Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Refactor behaviour of user config in KafkaBrokerConfigurationBuilder Signed-off-by: ocorriga <ocorriga@redhat.com> Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Address Fede's comments Signed-off-by: ocorriga <ocorriga@redhat.com> Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Address Mickael's comments Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Fix Kafka dashboard Signed-off-by: Federico Valeri <fedevaleri@gmail.com> Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Update API doc Signed-off-by: Federico Valeri <fedevaleri@gmail.com> Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Add system test Signed-off-by: Federico Valeri <fedevaleri@gmail.com> Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Minor ST improvements Signed-off-by: Federico Valeri <fedevaleri@gmail.com> Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Address Kate's and Paolo's comments Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Remove jayway-json-path dependency from kafka-thirdparty-libs and add listener.enabed=true Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Address nit and move prometheus-jmx-exporter examples into it's own directory Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Address ST comments Signed-off-by: Federico Valeri <fedevaleri@gmail.com> Address Jakub's latest comments Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Address comments on KafkaBrokerConfigurationBuilder Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com> Address comments from Jakub Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com>
Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com>
Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com>
Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com>
Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com>
Signed-off-by: OwenCorrigan76 <owencorrigan76@gmail.com>
ec69460
to
2215a9b
Compare
Thanks @scholzj Nits addressed |
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.
Just a couple of nits but overall LGTM! Thanks for the effort @OwenCorrigan76 (and @fvaleri) ;-)
createOrAddListConfig(userConfig, "metric.reporters", CruiseControlMetricsReporter.CRUISE_CONTROL_METRIC_REPORTER); | ||
} | ||
if (injectKafkaJmxReporter) { | ||
createOrAddListConfig(userConfig, "metric.reporters", "org.apache.kafka.common.metrics.JmxReporter"); |
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.
What about having a constant for "org.apache.kafka.common.metrics.JmxReporter" within the JmxPrometheusExporterModel
class?
} | ||
if (injectStrimziMetricsReporter) { | ||
createOrAddListConfig(userConfig, "metric.reporters", "io.strimzi.kafka.metrics.KafkaPrometheusMetricsReporter"); |
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.
Ditto as above, maybe a constant for "io.strimzi.kafka.metrics.KafkaPrometheusMetricsReporter" within the StrimziMetricsReporterModel
class?
*/ | ||
private void maybeAddYammerMetricsReporters(KafkaConfiguration userConfig, boolean injectStrimziMetricsReporter) { | ||
if (injectStrimziMetricsReporter) { | ||
createOrAddListConfig(userConfig, "kafka.metrics.reporters", "io.strimzi.kafka.metrics.YammerPrometheusMetricsReporter"); |
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.
Maybe we can have a constant for "io.strimzi.kafka.metrics.YammerPrometheusMetricsReporter" within the StrimziMetricsReporterModel
class because it's anyway set in related to the Strimzi Metrics Reporter.
Type of change
Description
This patch adds support for the Strimzi Metrics Reporter to Kafka brokers/controllers components as described by the following proposal:
https://github.com/strimzi/proposals/blob/main/064-prometheus-metrics-reporter.md
Related to #10753
Support for Kafka Connect and MirrorMaker2 and Strimzi Kafka Bridge will be added in subsequent PRs.
CEL Validation has been added to the MetricsConfig and CruiseControl API in this PR.
CEL Validation was introduced to Strimzi in this PR:
#11068
We won’t initially support the CruiseControl component. To make it work, CC should be changed to expose metrics through its HTTP endpoint.
Checklist