Search in sources :

Example 11 with JmxPrometheusExporterMetrics

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();
}
Also used : JmxPrometheusExporterMetrics(io.strimzi.api.kafka.model.JmxPrometheusExporterMetrics) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) ConfigMapKeySelectorBuilder(io.fabric8.kubernetes.api.model.ConfigMapKeySelectorBuilder) JmxPrometheusExporterMetricsBuilder(io.strimzi.api.kafka.model.JmxPrometheusExporterMetricsBuilder) ConfigMapBuilder(io.fabric8.kubernetes.api.model.ConfigMapBuilder) Kafka(io.strimzi.api.kafka.model.Kafka) ConfigMapKeySelector(io.fabric8.kubernetes.api.model.ConfigMapKeySelector)

Example 12 with JmxPrometheusExporterMetrics

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();
}
Also used : JmxPrometheusExporterMetrics(io.strimzi.api.kafka.model.JmxPrometheusExporterMetrics) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) ConfigMapKeySelectorBuilder(io.fabric8.kubernetes.api.model.ConfigMapKeySelectorBuilder) JmxPrometheusExporterMetricsBuilder(io.strimzi.api.kafka.model.JmxPrometheusExporterMetricsBuilder) ConfigMapBuilder(io.fabric8.kubernetes.api.model.ConfigMapBuilder) Kafka(io.strimzi.api.kafka.model.Kafka) ConfigMapKeySelector(io.fabric8.kubernetes.api.model.ConfigMapKeySelector)

Aggregations

JmxPrometheusExporterMetrics (io.strimzi.api.kafka.model.JmxPrometheusExporterMetrics)12 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)6 ConfigMapBuilder (io.fabric8.kubernetes.api.model.ConfigMapBuilder)6 ConfigMapKeySelectorBuilder (io.fabric8.kubernetes.api.model.ConfigMapKeySelectorBuilder)6 JmxPrometheusExporterMetricsBuilder (io.strimzi.api.kafka.model.JmxPrometheusExporterMetricsBuilder)6 Kafka (io.strimzi.api.kafka.model.Kafka)6 YAMLFactory (com.fasterxml.jackson.dataformat.yaml.YAMLFactory)4 ConfigMapKeySelector (io.fabric8.kubernetes.api.model.ConfigMapKeySelector)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)2 LabelSelector (io.fabric8.kubernetes.api.model.LabelSelector)2 KafkaBuilder (io.strimzi.api.kafka.model.KafkaBuilder)2 KafkaExporterSpec (io.strimzi.api.kafka.model.KafkaExporterSpec)2 IsolatedTest (io.strimzi.systemtest.annotations.IsolatedTest)2 ParallelTest (io.strimzi.systemtest.annotations.ParallelTest)2 MetricsCollector (io.strimzi.systemtest.metrics.MetricsCollector)2 Checkpoint (io.vertx.junit5.Checkpoint)2 HashMap (java.util.HashMap)2 Matchers.emptyString (org.hamcrest.Matchers.emptyString)2