// Module included in the following assemblies:
//
// metrics/assembly-metrics.adoc

[id='con-metrics-cruise-control-{context}']
= Monitoring Cruise Control operations

[role="_abstract"]
Cruise Control monitors Kafka brokers in order to track the utilization of brokers, topics, and partitions.
Cruise Control also provides a set of metrics for monitoring its own performance. 

The Cruise Control metrics reporter collects raw metrics data from Kafka brokers.
The data is produced to topics that are automatically created by Cruise Control.
The metrics are used to xref:proc-generating-optimization-proposals-str[generate optimization proposals for Kafka clusters].

Cruise Control metrics are available for real-time monitoring of Cruise Control operations.
For example, you can use Cruise Control metrics to monitor the status of rebalancing operations that are running or provide alerts on any anomalies that are detected in an operation's performance.

You expose Cruise Control metrics by xref:proc-metrics-kafka-deploy-options-{context}[enabling the {JMXExporter} in the Cruise Control configuration].

NOTE: For a full list of available Cruise Control metrics, which are known as _sensors_, see the {CruiseControlSensorsDocs}

== Monitoring balancedness scores

Cruise Control metrics include a balancedness score.
Balancedness is the measure of how evenly a workload is distributed in a Kafka cluster.

The Cruise Control metric for balancedness score (`balancedness-score`) might differ from the balancedness score in the `KafkaRebalance` resource.
Cruise Control calculates each score using `anomaly.detection.goals` which might not be the same as the `default.goals` used in the `KafkaRebalance` resource.
The `anomaly.detection.goals` are specified in the `spec.cruiseControl.config` of the `Kafka` custom resource.

[NOTE]
====
Refreshing the `KafkaRebalance` resource fetches an optimization proposal.
The latest cached optimization proposal is fetched if one of the following conditions applies:

* KafkaRebalance `goals` match the goals configured in the `default.goals` section of the `Kafka` resource
* KafkaRebalance `goals` are not specified

Otherwise, Cruise Control generates a new optimization proposal based on KafkaRebalance `goals`. If new proposals are generated with each refresh, this can impact performance monitoring.
====

== Setting up alerts for anomaly detection

Cruise control's _anomaly detector_ provides metrics data for conditions that block the generation of optimization goals, such as broker failures.
If you want more visibility, you can use the metrics provided by the anomaly detector to set up alerts and send out notifications.
You can set up Cruise Control’s _anomaly notifier_ to route alerts based on these metrics through a specified notification channel.
Alternatively, you can set up Prometheus to scrape the metrics data provided by the anomaly detector and generate alerts.
Prometheus Alertmanager can then route the alerts generated by Prometheus.

The {CruiseControlConfigDocs} provides information on `AnomalyDetector` metrics and the anomaly notifier.
