[Yandex Cloud documentation](../../index.md) > [Yandex Managed Service for Apache Kafka®](../index.md) > [Step-by-step guides](index.md) > Logs and monitoring > Cluster and host state monitoring

# Apache Kafka® cluster and host state monitoring

Data on the cluster and host state is available in the [management console](https://console.yandex.cloud). You can view them on the **Monitoring** tab of the cluster management page or in [Yandex Monitoring](../../monitoring/concepts/index.md).

Diagnostic information about cluster states is presented as graphs.

Chart update rate:

* Standard hosts and hosts with an increased RAM to vCPU ratio (`memory-optimized`): 15 seconds.
* Hosts with a guaranteed vCPU share under 100% (`burstable`): 150 seconds.

{% note info %}

The most appropriate multiple units (MB, GB, and more) are automatically used in charts.

{% endnote %}

You can [configure alerts](#monitoring-integration) in Yandex Monitoring to receive notifications about cluster failures. In Yandex Monitoring, there are two alert thresholds: `Warning` and `Alarm`. If the specified threshold is exceeded, you will receive alerts via the configured [notification channels](../../monitoring/concepts/alerting.md#notification-channel).

## Cluster state monitoring {#monitoring-cluster}

To view detailed information on the health state of a Managed Service for Apache Kafka® cluster:

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), navigate to the relevant folder.
  1. Navigate to **Managed Service for&nbsp;Kafka**.
  1. Click the name of your cluster and select the **Monitoring** tab.
  
  1. To get started with Yandex Monitoring metrics, dashboards, or alerts, click **Open in Monium** in the top panel.

  The page displays the following charts:

  * **Alive brokers**: Number of functional brokers for each host with the `KAFKA` role.
  * **Problematic partitions**: Displays the values of the settings below:
      * `Offline Replicas`: Number of partitions with no leader broker. These partitions do not support message writes or reads.
      * `UnderMinISR`: Number of partitions with an in-sync replicas (ISRs) count below the minimum value specified in the [settings](../concepts/settings-list.md).
      * `UnderReplicated`: Number of partitions with an ISR count below the replication factor.
  * **Errors**: Number of failed requests by error type.
  * **Free space**: Free disk space for each host with the `KAFKA` role, in bytes.
  * **Messages in**: Message write rate for each host with the `KAFKA` role, messages per second.
  * **Bytes In/Out**: Message write and read rate for each host with the `KAFKA` role, in bytes per second.
  * **Top 5 topics by size**: Amount of data for each of the five largest topics, in bytes.
  * **Replicated bytes**: Replication data streaming rate for each host with the `KAFKA` role, in bytes per second.
  * **Partitions**: Total number of partition replicas.
  * **Replication lag [messages]**: Greatest replication lag for each host with the `KAFKA` role, in messages.
  * **Request time (0.95 quantile)**: Request processing time at the 95th percentile by request type.
  * **Requests**: Request rate by type, in requests per second.

{% endlist %}

## Host state monitoring {#monitoring-hosts}

To view detailed information on the state of individual Managed Service for Apache Kafka® hosts:

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), navigate to the relevant folder.
  1. Navigate to **Managed Service for&nbsp;Kafka**.
  1. Click the name of your cluster and select the **Monitoring** tab.
  1. Navigate to the **Hosts** tab and select the host.

      Host type, `KAFKA`, `KRAFT` or `ZOOKEEPER`, is specified for each host.

      To get started with Yandex Monitoring metrics, dashboards, or alerts, click **Open in Monium** in the top panel.

  This page displays workload charts for an individual cluster host:

  * **CPU usage**: Processor core workload. As the workload goes up, the `idle` value goes down.
  * **Memory usage**: Use of RAM, in bytes. At high workloads, the `Free` value goes down, while the other values go up.
  * **Disk IOPS**: Number of disk operations per second.
  * **Network packets**: Network packet exchange rate, in packets per second.
  * **Free space**: Free disk space, in bytes.
  * **Network bytes**: Network data exchange rate, in bytes per second.

  Under **Disk Metrics Details**:

  * **Disk write latency (percentiles)**: Disk write time, in percentiles.
  * **Disk write bytes**: Average and maximum disk write rate.
  * **Disk write operations**: Average and maximum number of write operations per second.
  * **Disk read latency (percentiles)**: Disk read time, in percentiles.
  * **Disk read bytes**: Average and maximum disk read rate.
  * **Disk read operations**: Average and maximum number of read operations per second.
  * **Disk write throttler latency (percentiles)**: Write delay introduced by exceeding disk quota, percentiles.
  * **Disk read throttler latency (percentiles)**: Read delay introduced by exceeding disk quota, percentiles.
  * **Disk used quota**: Disk operation quota usage.

{% endlist %}


## Setting up alerts in Yandex Monitoring {#monitoring-integration}

To configure state indicator alerts for a [cluster](#monitoring-cluster) and [hosts](#monitoring-hosts):

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), select the folder with the cluster for which you want to set up alerts.
  1. Navigate to ![image](../../_assets/console-icons/display-pulse.svg) **Monitoring**.
  1. Under **Service dashboards**, select **Managed Service for Apache Kafka® — Cluster Overview**.
  1. In the chart you need, click ![options](../../_assets/console-icons/ellipsis.svg) and select **Create alert**.
  1. If the chart displays multiple metrics, select the data query for the relevant metric and click **Continue**. You can learn more about the query language in [this Yandex Monitoring article](../../monitoring/concepts/querying.md).
  1. Set the `Alarm` and `Warning` threshold values to trigger the alert.
  1. Click **Create alert**.

{% endlist %}

To have other cluster health indicators monitored automatically:

{% list tabs group=instructions %}

- Management console {#console}

    1. [Create an alert](../../monitoring/operations/alert/create-alert.md).
    1. Add a status metric.
    1. In the alert parameters, set the alert thresholds.

{% endlist %}

The recommended thresholds for some metrics are as follows:

| Metric                            | Internal metric name                                             | `Alarm`                    | `Warning`                  |
|------------------------------------|---------------------------------------------------------|----------------------------|----------------------------|
| Number of healthy hosts  | `kafka_is_alive`                                        | `<number_of_hosts> - 2`  | `<number_of_hosts> - 1`  |
| Partition replication state      | `kafka_server_ReplicaManager_UnderReplicatedPartitions` | —                          | `More than 0`                 |
| Number of lagging replicas             | `kafka_server_ReplicaManager_UnderMinIsrPartitionCount` | `More than 0`                 | —                          |
| Storage space used    | `disk.used_bytes`                                       | 90% of the storage size | 80% of the storage size |

For the `disk.used_bytes` metric, the `Alarm` and `Warning` thresholds are only set in bytes. For example, the recommended values for a 100 GB disk are as follows:

* `Alarm`: `96,636,764,160` bytes (90%)
* `Warning`: `85,899,345,920` bytes (80%)

You can check the current storage size in the [cluster details](cluster-list.md#get-cluster). For a complete list of supported metrics, see [this Monitoring guide](../../monitoring/metrics-ref/managed-kafka-ref.md).


## Cluster health and status {#cluster-health-and-status}

The **State** of a cluster shows the health of its hosts, while the **Status** shows whether the cluster is started, stopped, or is at an intermediate stage.

To view the health state and status of a cluster:

1. In the [management console](https://console.yandex.cloud), navigate to the relevant folder.
1. Navigate to **Managed Service for&nbsp;Kafka**.
1. In the cluster row, hover over the indicator in the **Availability** column.

### Cluster health states {#cluster-health}

State | Description | Suggested actions
:--- | :--- | :---
**ALIVE** | Cluster is operating normally. | No action is required.
**DEGRADED** | Cluster is not running at its full capacity: the state of at least one of the hosts is other than `ALIVE`. | Run the diagnostics:<ul><li>Go to the **Hosts** tab and see which hosts are not working.</li><li>Go to the **Operations** tab and make sure all operations are completed.</li><li>Make sure the cluster is not under maintenance.</li></ul>If you cannot find the cause yourself, [contact support](https://center.yandex.cloud/support).
**DEAD** | The cluster is down: none of its hosts are running. | [Make a support request](https://center.yandex.cloud/support) stating the following:<ul><li>Cluster ID.</li><li>IDs of the last operations performed on it.</li><li>Time the cluster entered the `DEAD` state according to the [availability charts](#monitoring-cluster).</li></ul>
**UNKNOWN** | Cluster state is unknown. | [Make a support request](https://center.yandex.cloud/support) stating the following:<ul><li>Cluster ID.</li><li>IDs of the last operations performed on it.</li><li>Time the cluster entered the `UNKNOWN` state according to the [availability charts](#monitoring-cluster).</li></ul>

### Cluster statuses {#cluster-status}

Status | Description | Suggested actions
:--- | :--- | :---
**CREATING** | Preparing for the first start | Wait a while and get started. The time it takes to create a cluster depends on the host class.
**RUNNING** | The cluster is operating normally | No action is required.
**STOPPING** | The cluster is stopping | After a while, the cluster status will switch to `STOPPED` and the cluster will be disabled. No action is required.
**STOPPED** | The cluster is stopped | Start the cluster to get it running again.
**STARTING** | Starting the cluster that was stopped earlier | After a while, the cluster status will switch to `RUNNING`. Wait a while and get started.
**UPDATING** | Updating the cluster's configuration | Once the update is complete, the cluster will get the status it had prior to the update: `RUNNING` or `STOPPED`.
**ERROR** | Error when performing an operation with the cluster or during a maintenance window | If the cluster remains in this status for a long time, [contact support](https://center.yandex.cloud/support). You can see whether a cluster is available by its status.
**STATUS_UNKNOWN** | The cluster is unable to determine its status | If the cluster remains in this status for a long time, [contact support](https://center.yandex.cloud/support).