use of io.strimzi.api.kafka.model.JmxPrometheusExporterMetricsBuilder in project strimzi by strimzi.
the class KafkaMirrorMakerClusterTest method testMetricsParsingFromConfigMap.
@ParallelTest
public void testMetricsParsingFromConfigMap() {
MetricsConfig metrics = new JmxPrometheusExporterMetricsBuilder().withNewValueFrom().withConfigMapKeyRef(new ConfigMapKeySelectorBuilder().withName("my-metrics-configuration").withKey("config.yaml").build()).endValueFrom().build();
KafkaMirrorMaker mirrorMaker = new KafkaMirrorMakerBuilder(this.resource).editSpec().withMetricsConfig(metrics).endSpec().build();
KafkaMirrorMakerCluster kmm = KafkaMirrorMakerCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, mirrorMaker, VERSIONS);
assertThat(kmm.isMetricsEnabled(), is(true));
assertThat(kmm.getMetricsConfigInCm(), is(metrics));
}
use of io.strimzi.api.kafka.model.JmxPrometheusExporterMetricsBuilder in project strimzi by strimzi.
the class ZookeeperClusterTest method testMetricsParsingFromConfigMap.
@ParallelTest
public void testMetricsParsingFromConfigMap() {
MetricsConfig metrics = new JmxPrometheusExporterMetricsBuilder().withNewValueFrom().withConfigMapKeyRef(new ConfigMapKeySelectorBuilder().withName("my-metrics-configuration").withKey("config.yaml").build()).endValueFrom().build();
Kafka kafkaAssembly = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout)).editSpec().editZookeeper().withMetricsConfig(metrics).endZookeeper().endSpec().build();
ZookeeperCluster zc = ZookeeperCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafkaAssembly, VERSIONS);
assertThat(zc.isMetricsEnabled(), is(true));
assertThat(zc.getMetricsConfigInCm(), is(metrics));
}
use of io.strimzi.api.kafka.model.JmxPrometheusExporterMetricsBuilder in project strimzi by strimzi.
the class KafkaClusterTest method testMetricsParsingFromConfigMap.
@ParallelTest
public void testMetricsParsingFromConfigMap() {
MetricsConfig metrics = new JmxPrometheusExporterMetricsBuilder().withNewValueFrom().withConfigMapKeyRef(new ConfigMapKeySelectorBuilder().withName("my-metrics-configuration").withKey("config.yaml").build()).endValueFrom().build();
Kafka kafkaAssembly = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout)).editSpec().editKafka().withMetricsConfig(metrics).endKafka().endSpec().build();
KafkaCluster kc = KafkaCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafkaAssembly, VERSIONS);
assertThat(kc.isMetricsEnabled(), is(true));
assertThat(kc.getMetricsConfigInCm(), is(metrics));
}
use of io.strimzi.api.kafka.model.JmxPrometheusExporterMetricsBuilder in project strimzi-kafka-operator by strimzi.
the class CruiseControlTest method testMetricsParsingFromConfigMap.
@ParallelTest
public void testMetricsParsingFromConfigMap() {
MetricsConfig metrics = new JmxPrometheusExporterMetricsBuilder().withNewValueFrom().withConfigMapKeyRef(new ConfigMapKeySelectorBuilder().withName("my-metrics-configuration").withKey("config.yaml").build()).endValueFrom().build();
CruiseControlSpec cruiseControlSpec = new CruiseControlSpecBuilder().withMetricsConfig(metrics).build();
Kafka kafkaAssembly = createKafka(cruiseControlSpec);
CruiseControl cc = createCruiseControl(kafkaAssembly);
assertThat(cc.isMetricsEnabled(), is(true));
assertThat(cc.getMetricsConfigInCm(), is(metrics));
}
use of io.strimzi.api.kafka.model.JmxPrometheusExporterMetricsBuilder in project strimzi-kafka-operator by strimzi.
the class MetricsIsolatedST method testKafkaMetricsSettings.
/**
* 1. Update metrics form whatever it is to @metricsConfigYaml in spec.kafka.metricsConfig
* 2. Check, whether the metrics ConfigMap is changed
* 3. Updates ConfigMap linked as metrics on
* 4. Check, whether the metrics ConfigMap is changed
*/
@ParallelTest
void testKafkaMetricsSettings() {
String metricsConfigJson = "{\"lowercaseOutputName\":true}";
String metricsConfigYaml = "lowercaseOutputName: true";
ObjectMapper mapper = new ObjectMapper();
mapper.configure(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS.mappedFeature(), true);
ConfigMap externalMetricsCm = new ConfigMapBuilder().withData(Collections.singletonMap(Constants.METRICS_CONFIG_YAML_NAME, metricsConfigYaml)).withNewMetadata().withName("external-metrics-cm").withNamespace(SECOND_NAMESPACE).endMetadata().build();
kubeClient().getClient().configMaps().inNamespace(SECOND_NAMESPACE).createOrReplace(externalMetricsCm);
// spec.kafka.metrics -> spec.kafka.jmxExporterMetrics
ConfigMapKeySelector cmks = new ConfigMapKeySelectorBuilder().withName("external-metrics-cm").withKey(Constants.METRICS_CONFIG_YAML_NAME).build();
JmxPrometheusExporterMetrics jmxPrometheusExporterMetrics = new JmxPrometheusExporterMetricsBuilder().withNewValueFrom().withConfigMapKeyRef(cmks).endValueFrom().build();
KafkaResource.replaceKafkaResourceInSpecificNamespace(SECOND_CLUSTER, k -> {
k.getSpec().getKafka().setMetricsConfig(jmxPrometheusExporterMetrics);
}, SECOND_NAMESPACE);
PodUtils.verifyThatRunningPodsAreStable(SECOND_NAMESPACE, SECOND_CLUSTER);
ConfigMap actualCm = kubeClient(SECOND_NAMESPACE).getConfigMap(KafkaResources.kafkaMetricsAndLogConfigMapName(SECOND_CLUSTER));
assertThat(actualCm.getData().get(Constants.METRICS_CONFIG_JSON_NAME), is(metricsConfigJson));
// update metrics
ConfigMap externalMetricsUpdatedCm = new ConfigMapBuilder().withData(Collections.singletonMap(Constants.METRICS_CONFIG_YAML_NAME, metricsConfigYaml.replace("true", "false"))).withNewMetadata().withName("external-metrics-cm").withNamespace(SECOND_NAMESPACE).endMetadata().build();
kubeClient().getClient().configMaps().inNamespace(SECOND_NAMESPACE).createOrReplace(externalMetricsUpdatedCm);
PodUtils.verifyThatRunningPodsAreStable(SECOND_NAMESPACE, SECOND_CLUSTER);
actualCm = kubeClient(SECOND_NAMESPACE).getConfigMap(KafkaResources.kafkaMetricsAndLogConfigMapName(SECOND_CLUSTER));
assertThat(actualCm.getData().get(Constants.METRICS_CONFIG_JSON_NAME), is(metricsConfigJson.replace("true", "false")));
}
Aggregations