// Module included in the following assemblies:
//
// metrics/assembly_metrics-kafka-exporter.adoc

[id='proc-kafka-exporter-configuring-{context}']
= Configuring Kafka Exporter

This procedure shows how to configure Kafka Exporter in the `Kafka` resource through `KafkaExporter` properties.

For more information about configuring the `Kafka` resource, see link:{BookURLUsing}#assembly-config-kafka-str[Kafka cluster configuration^] in the _Using Strimzi_ guide.

The properties relevant to the Kafka Exporter configuration are shown in this procedure.

You can configure these properties as part of a deployment or redeployment of the Kafka cluster.

.Prerequisites

* A Kubernetes cluster
* A running Cluster Operator

.Procedure

. Edit the `KafkaExporter` properties for the `Kafka` resource.
+
The properties you can configure are shown in this example configuration:
+
[source,yaml,subs="attributes+"]
----
apiVersion: {KafkaApiVersion}
kind: Kafka
metadata:
  name: my-cluster
spec:
  # ...
  kafkaExporter:
    image: my-registry.io/my-org/my-exporter-cluster:latest <1>
    groupRegex: ".*" <2>
    topicRegex: ".*" <3>
    resources: <4>
      requests:
        cpu: 200m
        memory: 64Mi
      limits:
        cpu: 500m
        memory: 128Mi
    logging: debug <5>
    enableSaramaLogging: true <6>
    template: <7>
      pod:
        metadata:
          labels:
            label1: value1
        imagePullSecrets:
          - name: my-docker-credentials
        securityContext:
          runAsUser: 1000001
          fsGroup: 0
        terminationGracePeriodSeconds: 120
    readinessProbe: <8>
      initialDelaySeconds: 15
      timeoutSeconds: 5
    livenessProbe: <9>
      initialDelaySeconds: 15
      timeoutSeconds: 5
# ...
----
<1> ADVANCED OPTION: Container image configuration, which is link:{BookURLUsing}#con-common-configuration-images-reference[recommended only in special situations].
<2> A regular expression to specify the consumer groups to include in the metrics.
<3> A regular expression to specify the topics to include in the metrics.
<4> link:{BookURLUsing}#con-common-configuration-resources-reference[CPU and memory resources to reserve].
<5> Logging configuration, to log messages with a given severity (debug, info, warn, error, fatal) or above.
<6> Boolean to enable Sarama logging, a Go client library used by Kafka Exporter.
<7> link:{BookURLUsing}#assembly-customizing-kubernetes-resources-str[Customization of deployment templates and pods].
<8> link:{BookURLUsing}#con-common-configuration-healthchecks-reference[Healthcheck readiness probes].
<9> link:{BookURLUsing}#con-common-configuration-healthchecks-reference[Healthcheck liveness probes].

. Create or update the resource:
+
[source,shell,subs="+quotes"]
----
kubectl apply -f _kafka.yaml_
----

.What to do next

After configuring and deploying Kafka Exporter, you can xref:proc-kafka-exporter-enabling-{context}[enable Grafana to present the Kafka Exporter dashboards].

.Additional resources

link:{BookURLUsing}#type-KafkaExporterTemplate-reference[`KafkaExporterTemplate` schema reference].
