> ## Documentation Index
> Fetch the complete documentation index at: https://docs.controlplane.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Centralized Metrics Management

> Access metrics from multiple orgs using a centralized Grafana instance by adding Prometheus data sources across organizations.

## Overview

To access metrics from multiple ORGs using a centralized Grafana, it is necessary to add a data source for each [Org](/reference/org). This method is also applicable for integrating external Prometheus data sources with Control Plane's Grafana, enabling centralized metrics management.

In this guide, we will demonstrate adding the Prometheus data source from `org-2` to the Grafana instance of `org-1`. This integration will enable the observation of metrics from both `org-1` and `org-2` using the Grafana interface of `org-1`.

**Note**: Replace `org-1` and `org-2` with the actual names of your organizations.

### Follow the steps below

#### In `org-2`

1. Log in to `org-2`, and create a new Service Account named `grafana-data-source`.
2. Create a new **key** for the `grafana-data-source` Service Account that is just created and save it.
3. Create a **policy** named `grafana-data-source` that enables `readMetrics` for the `grafana-data-source` Service Account.

```yaml YAML theme={null}
kind: policy
name: grafana-data-source
description: grafana-data-source
tags: {}
bindings:
  - permissions:
      - readMetrics
    principalLinks:
      - /org/org-2/serviceaccount/grafana-data-source
target: all
targetKind: org
```

#### In `org-1`

1. Log in to `org-1`, and navigate to Grafana by going to **Metrics** in the [Control Plane Console](https://console.cpln.io/console/).
2. Proceed to `Connections` (available on the sidebar) > **Data Sources**.
3. Click on `Add new data source` and then select `Prometheus` as the type of the data source.
4. Complete the configuration:
   a. Name: Use a descriptive name. For example, the name of the target organization, `org-2`.
   b. URL: `https://metrics.cpln.io/metrics/org/org-2` (Note: Replace `org-2` with the actual organization's name).
   c. Add a custom HTTP Header for `authorization` with the value: `Bearer <YOUR-TOKEN-HERE>`. Replace `<YOUR-TOKEN-HERE>` with the key token generated for the `grafana-data-source` Service Account in `org-2` (step 2 under [In `org-2`](#in-org-2)). Then, click **Save & Test**.

After these steps, you should be able to select the `org-2` data source when using the `Explore` feature in the `org-1` Grafana.

**Import Dashboard for Multiple Sources**

5. In your `org-1` Grafana, create a dashboard named `Multi Source Metrics Overview Cloud` to view metrics from various data sources. This is achieved by importing the dashboard.
   1. Download the dashboard JSON file from [this link](https://grafana.com/api/dashboards/20378/revisions/1/download).
   2. Import the downloaded dashboard into Grafana in `org-1`.

You can now select `org-2` as the data source in the `Multi Source Metrics Overview Cloud` dashboard you imported into `org-1`. Additional data sources, including those external or from other organizations, can be added by following the instructions in steps 1-4 under `org-1`.
