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

# Prometheus - Upstash Redis Integration

To monitor your Upstash database in Prometheus and visualize metrics in Grafana, follow these steps:

<Check>
  **Integration Scope**

  Upstash Prometheus Integration only covers Pro databases or those included in the Enterprise Plan.
</Check>

## **Step 1: Log in to Your Upstash Account**

1. Open your web browser and navigate to [Upstash](https://console.upstash.com/).
2. Navigate to the main dashboard, where you’ll see a list of your databases.

## **Step 2: Select your Database**

1. Select the database you want to integrate with Prometheus.
2. This will open the database settings, where you can manage various configuration options for your selected database.

<img src="https://mintcdn.com/upstash/pqZtv0gXFMQuy8rU/img/prometheus/configuration.png?fit=max&auto=format&n=pqZtv0gXFMQuy8rU&q=85&s=40fe38535d9e2fbdb7d59428c6a94f6d" alt="configuration.png" width="1938" height="610" data-path="img/prometheus/configuration.png" />

3. Enable Prometheus by toggling the switch. This allows you to monitor metrics related to your Upstash database performance, usage, and other key metrics.

## **Step 3: Connect Accounts**

1. After enabling Prometheus, a monitoring token is generated and displayed.

2. Copy this token. This token is unique to your database and is required to authenticate Prometheus with the Upstash metrics endpoint.

<Check>
  **Header Format**

  You should add monitoring token according to this format `Bearer <MONITORING_TOKEN>`
</Check>

<img src="https://mintcdn.com/upstash/pqZtv0gXFMQuy8rU/img/prometheus/monitoring-token.png?fit=max&auto=format&n=pqZtv0gXFMQuy8rU&q=85&s=2618f754b9209f28f30d27b16a652786" alt="monitoring-token.png" width="950" height="520" data-path="img/prometheus/monitoring-token.png" />

## **Step 4: Set Up Prometheus Connection**

### **Grafana Dashboard Setup**

1. Open your Grafana instance, navigate to the Data Sources section, and select Prometheus as the data source.

<img src="https://mintcdn.com/upstash/pqZtv0gXFMQuy8rU/img/prometheus/datasource.png?fit=max&auto=format&n=pqZtv0gXFMQuy8rU&q=85&s=3dce2b10059a2eb96d8d560bdabb7303" alt="datasource.png" width="1848" height="464" data-path="img/prometheus/datasource.png" />

2. Enter the data source name, set `https://api.upstash.com/monitoring/prometheus` as the data source address, and then add your monitoring token in the HTTP Headers section.

<img src="https://mintcdn.com/upstash/pqZtv0gXFMQuy8rU/img/prometheus/headers.png?fit=max&auto=format&n=pqZtv0gXFMQuy8rU&q=85&s=f32611d6c8cedb2b6a73d21e9b8a1cd5" alt="headers.png" width="1322" height="346" data-path="img/prometheus/headers.png" />

3. Then, click <b>Test and Save</b> to verify that the data source is working properly.

<img src="https://mintcdn.com/upstash/pqZtv0gXFMQuy8rU/img/prometheus/datasource-final.png?fit=max&auto=format&n=pqZtv0gXFMQuy8rU&q=85&s=6e3f9cc214486c59085fe036a0dd6a28" alt="datasource-final.png" width="1560" height="412" data-path="img/prometheus/datasource-final.png" />

### **Prometheus Federation Setup**

Federation lets your Prometheus pull metrics from Upstash’s API and store them in **your own** Prometheus instance, so Grafana can query your Prometheus instead of hitting the Upstash endpoint directly.

#### When to use federation

* You already run Prometheus and want to persist Upstash metrics locally.
* You want to control retention, recording rules, or alerts on Upstash metrics

1. Set up a new scrape job in your Prometheus configuration file (`prometheus.yml`):

```yaml theme={"system"}
scrape_configs:
  # Federation job: pull from Upstash API
  - job_name: "federate_upstash"
    honor_labels: true
    metrics_path: "/monitoring/prometheus/federate"
    scheme: https
    params:
      match[]:
        - 'upstash_db_metrics{}'
    static_configs:
      - targets:
          - "api.upstash.com"
    authorization:
      type: Bearer
      credentials: "<MONITORING_TOKEN>"
```

<Check>
  This configuration assumes you want to pull all metrics. You can adjust the `match[]` parameter to filter specific metrics if needed.

  * `upstash_db_metrics{database_id="your_database_id"}` can be used to pull metrics for a specific database
  * `upstash_db_metrics{replica_id=~"us-east-1.*"}` can be used to pull metrics for replicas in a specific region
</Check>

2. Verify the Federation Target

* Reload (or restart) your Prometheus server to apply the new configuration.
* Visit **Prometheus → Status → Targets** and confirm `federate_upstash` is **UP**

## **Step 5: Wait for Metrics Availability**

To visualize your Upstash metrics, you can use a pre-built Grafana dashboard.

Select your Prometheus data source when prompted, and complete the import.

Please check this address to access Upstash Grafana Dashboard <a href="https://grafana.com/grafana/dashboards/22257-upstash-redis-dashboard/"> Dashboard </a>

<img src="https://mintcdn.com/upstash/pqZtv0gXFMQuy8rU/img/prometheus/grafana-dashboard.png?fit=max&auto=format&n=pqZtv0gXFMQuy8rU&q=85&s=372dafae3c34f39565a23447bbc4446f" alt="grafana-dashboard.png" width="1800" height="1118" data-path="img/prometheus/grafana-dashboard.png" />

## **Conclusion**

You've now integrated your database with Upstash Prometheus, providing access to improved monitoring and analytics.

Feel free to explore Upstash's features and dashboards to gain deeper insights into your system's performance.

If you encounter any issues or have questions, please refer to the Upstash support documentation or contact our support team for assistance.
