// This assembly is included in the following assemblies:
//
// deploying/deploying.adoc

[id='assembly-metrics-{context}']
= Introducing metrics

[role="_abstract"]
Collecting metrics is critical for understanding the health and performance of your Kafka deployment. 
By monitoring metrics, you can actively identify issues before they become critical and make informed decisions about resource allocation and capacity planning. Without metrics, you may be left with limited visibility into the behavior of your Kafka deployment, which can make troubleshooting more difficult and time-consuming. Setting up metrics can save you time and resources in the long run, and help ensure the reliability of your Kafka deployment.

Metrics are available for each Strimzi component, allowing you to gain insights into their individual performance. 
Additionally, you can collect metrics specific to `oauth` authentication and `opa` or `keycloak` authorization by enabling the `enableMetrics` property in the listener or authorization configuration of the `Kafka` resource.
Similarly, you can enable metrics for `oauth` authentication in custom resources such as `KafkaBridge`, `KafkaConnect`, `KafkaMirrorMaker`, and `KafkaMirrorMaker2`.

You can use Prometheus and Grafana to monitor Strimzi.
Prometheus consumes metrics from the running pods in your cluster when configured with Prometheus rules. 
Grafana visualizes these metrics on dashboards, providing an intuitive interface for monitoring. 

To facilitate metrics integration, Strimzi provides example Prometheus rules and Grafana dashboards for Strimzi components. 
You can customize the example Grafana dashboards to suit your specific deployment requirements.
You can use rules to define conditions that trigger alerts based on specific metrics.

Depending on your monitoring requirements, you can do the following:

* xref:assembly-metrics-setup-{context}[Set up and deploy Prometheus to expose metrics]
* xref:proc-metrics-kafka-deploy-options-{context}[Deploy Kafka Exporter to provide additional metrics]
* xref:proc-metrics-grafana-dashboard-{context}[Use Grafana to present the Prometheus metrics]

Additionally, you can configure your deployment to track messages end-to-end by xref:assembly-distributed-tracing-str[setting up distributed tracing].

NOTE: Strimzi provides example installation files for Prometheus and Grafana, which can serve as a starting point for monitoring your Strimzi deployment. 
For further support, try engaging with the Prometheus and Grafana developer communities.

.Supporting documentation for metrics and monitoring tools
For more information on the metrics and monitoring tools, refer to the supporting documentation:

* {PrometheusHome}
* {PrometheusConfig}
* {kafka-exporter-project}
* {GrafanaHome}
* link:http://kafka.apache.org/documentation/#monitoring[Apache Kafka Monitoring] describes JMX metrics exposed by Apache Kafka
* link:https://zookeeper.apache.org/doc/current/zookeeperJMX.html[ZooKeeper JMX] describes JMX metrics exposed by Apache ZooKeeper

//what is Consumer lag?
include::../../modules/metrics/con_kafka-exporter-lag.adoc[leveloffset=+1]
//Understanding metrics for Cruise Control
include::../../modules/metrics/con-metrics-cruise-control.adoc[leveloffset=+1]
//Example metrics files
include::assembly-metrics-config-files.adoc[leveloffset=+1]
//How to set up Prometheus
include::assembly_metrics-prometheus-setup.adoc[leveloffset=+1]
//How to add Grafana dashboards
include::../../modules/metrics/proc_metrics-grafana-dashboard.adoc[leveloffset=+1]
//minikube metrics
ifdef::InstallationAppendix[]
include::../../modules/metrics/con_metrics-kafka-mini-kube.adoc[leveloffset=+1]
endif::InstallationAppendix[]