use of io.strimzi.api.kafka.model.JmxPrometheusExporterMetrics in project strimzi by strimzi.
the class KafkaTemplates method kafkaWithMetricsAndCruiseControlWithMetrics.
public static KafkaBuilder kafkaWithMetricsAndCruiseControlWithMetrics(String name, int kafkaReplicas, int zookeeperReplicas) {
Kafka kafka = getKafkaFromYaml(Constants.PATH_TO_KAFKA_METRICS_CONFIG);
ConfigMap kafkaMetricsCm = TestUtils.configMapFromYaml(Constants.PATH_TO_KAFKA_METRICS_CONFIG, "kafka-metrics");
KubeClusterResource.kubeClient().getClient().configMaps().inNamespace(kubeClient().getNamespace()).createOrReplace(kafkaMetricsCm);
ConfigMap zkMetricsCm = TestUtils.configMapFromYaml(Constants.PATH_TO_KAFKA_METRICS_CONFIG, "kafka-metrics");
KubeClusterResource.kubeClient().getClient().configMaps().inNamespace(kubeClient().getNamespace()).createOrReplace(zkMetricsCm);
ConfigMap ccCm = new ConfigMapBuilder().withApiVersion("v1").withNewMetadata().withName("cruise-control-metrics-test").withLabels(Collections.singletonMap("app", "strimzi")).endMetadata().withData(Collections.singletonMap("metrics-config.yml", "lowercaseOutputName: true\n" + "rules:\n" + "- pattern: kafka.cruisecontrol<name=(.+)><>(\\w+)\n" + " name: kafka_cruisecontrol_$1_$2\n" + " type: GAUGE")).build();
KubeClusterResource.kubeClient().getClient().configMaps().inNamespace(kubeClient().getNamespace()).createOrReplace(ccCm);
ConfigMapKeySelector cmks = new ConfigMapKeySelectorBuilder().withName("cruise-control-metrics-test").withKey("metrics-config.yml").build();
JmxPrometheusExporterMetrics jmxPrometheusExporterMetrics = new JmxPrometheusExporterMetricsBuilder().withNewValueFrom().withConfigMapKeyRef(cmks).endValueFrom().build();
return defaultKafka(kafka, name, kafkaReplicas, zookeeperReplicas).editSpec().withNewKafkaExporter().endKafkaExporter().withNewCruiseControl().withMetricsConfig(jmxPrometheusExporterMetrics).endCruiseControl().endSpec();
}
use of io.strimzi.api.kafka.model.JmxPrometheusExporterMetrics in project strimzi-kafka-operator by strimzi.
the class KafkaTemplates method kafkaWithMetricsAndCruiseControlWithMetrics.
public static KafkaBuilder kafkaWithMetricsAndCruiseControlWithMetrics(String name, int kafkaReplicas, int zookeeperReplicas) {
Kafka kafka = getKafkaFromYaml(Constants.PATH_TO_KAFKA_METRICS_CONFIG);
ConfigMap kafkaMetricsCm = TestUtils.configMapFromYaml(Constants.PATH_TO_KAFKA_METRICS_CONFIG, "kafka-metrics");
KubeClusterResource.kubeClient().getClient().configMaps().inNamespace(kubeClient().getNamespace()).createOrReplace(kafkaMetricsCm);
ConfigMap zkMetricsCm = TestUtils.configMapFromYaml(Constants.PATH_TO_KAFKA_METRICS_CONFIG, "kafka-metrics");
KubeClusterResource.kubeClient().getClient().configMaps().inNamespace(kubeClient().getNamespace()).createOrReplace(zkMetricsCm);
ConfigMap ccCm = new ConfigMapBuilder().withApiVersion("v1").withNewMetadata().withName("cruise-control-metrics-test").withLabels(Collections.singletonMap("app", "strimzi")).endMetadata().withData(Collections.singletonMap("metrics-config.yml", "lowercaseOutputName: true\n" + "rules:\n" + "- pattern: kafka.cruisecontrol<name=(.+)><>(\\w+)\n" + " name: kafka_cruisecontrol_$1_$2\n" + " type: GAUGE")).build();
KubeClusterResource.kubeClient().getClient().configMaps().inNamespace(kubeClient().getNamespace()).createOrReplace(ccCm);
ConfigMapKeySelector cmks = new ConfigMapKeySelectorBuilder().withName("cruise-control-metrics-test").withKey("metrics-config.yml").build();
JmxPrometheusExporterMetrics jmxPrometheusExporterMetrics = new JmxPrometheusExporterMetricsBuilder().withNewValueFrom().withConfigMapKeyRef(cmks).endValueFrom().build();
return defaultKafka(kafka, name, kafkaReplicas, zookeeperReplicas).editSpec().withNewKafkaExporter().endKafkaExporter().withNewCruiseControl().withMetricsConfig(jmxPrometheusExporterMetrics).endCruiseControl().endSpec();
}
Aggregations