# Export cluster metrics to Prometheus

## Overview

Cloud WEKA Home (CWH) allows exporting key cluster metrics directly to Prometheus using a custom application that follows the [Prometheus Data Model](https://prometheus.io/docs/concepts/data_model/#data-model).

This feature is designed for customers who do not use the [WEKAmon](https://docs.weka.io/monitor-the-weka-cluster/external-monitoring) monitoring utility but still need to integrate essential cluster statistics into their Prometheus environments.

Key exported metrics include:

* Throughput metrics
* IO performance metrics
* Cluster resource metrics
* Cluster health and alerts
* Cluster capacity metrics

<details>

<summary>Cluster metrics in Prometheus format</summary>

{% code overflow="wrap" %}

```
Name: weka_throughput_bytes_per_second
Help: Weka throughput in bytes per second
Labels with Values:
type: read, write

Name: weka_iops
Help: Weka cluster IOPS
Labels with Values:
type: read, write, metadata

Name: weka_cluster_drives_count
Help: Number of drives in the cluster
Labels with Values:
status: active, created

Name: weka_cluster_processes_count
Help: Number of processes in the cluster
Labels with Values:
status: active, created
type: compute, drive

Name: weka_cluster_containers_count
Help: Number of containers in the cluster
Labels with Values:
status: active, created
type: compute, drive

Name: weka_cluster_alerts_count
Help: Number of alerts in the cluster
Labels with Values:
status: active

Name: weka_cluster_status
Help: Weka cluster status
Labels with Values:
status: (Dynamic values based on cluster status, e.g., OK, Rebuilding, etc.)

Name: weka_cluster_protection_level
Help: Weka cluster protection level
Labels with Values:
num_failures: (Dynamic values based on the number of failures, e.g., 0, 1, 2, etc.)

Name: weka_cluster_capacity_bytes
Help: Weka cluster capacity in bytes
Labels with Values:
type: total, unprovisioned, unavailable, hotSpare
```

{% endcode %}

</details>

<div data-with-frame="true"><figure><img src="https://2745724548-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZW262oqYA8pNNfGvXjHa%2Fuploads%2F0CylwjlGq6gD5gLHxTLr%2FCluster_metrics_sync_with_Prometheus.png?alt=media&#x26;token=6263b281-b8dd-43eb-be27-fd7b74fb222e" alt=""><figcaption><p>Cluster metrics sync with Prometheus</p></figcaption></figure></div>

## Export Prometheus metrics from CWH

To export Prometheus metrics from CWH, implement the Prometheus API call within a custom application to retrieve metrics at the required intervals. This procedure demonstrates the operation using the `curl` command to extract the metrics.

**Procedure**

1. **Obtain the Prometheus token:**
   * Contact the Customer Success Team to obtain the Prometheus token of your cluster.
2. **Export metrics in Prometheus format:**

   * Use the following API call, replacing `<cluster_id>` with your cluster ID and `<prometheus_token>` with the Prometheus token from Step 1:

     <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">curl --location \
     'https://api.home.weka.io/api/v3/clusters/&#x3C;cluster_id>/stats/prometheus' \
     --header 'Authorization: Bearer &#x3C;prometheus_token>'
     </code></pre>

   The command returns Prometheus-formatted metrics cluster information.
3. **Import the metrics into Prometheus:**
   1. Configure Prometheus to import the exported metrics.
   2. Use the Prometheus UI to visualize and monitor the metrics.

{% hint style="info" %}
If accessing the backend, prepend `api.` to the URL for legacy ingress support.
{% endhint %}

**Related information**

[Prometheus documentation](https://prometheus.io/docs/introduction/overview/)
