Prometheus Integration

```
prometheus.scrape "clickhouse_cloud" {
  targets = [{
  __address__ = "api.clickhouse.cloud",
  }]

  scheme       = "https"
  metrics_path = "/v1/organizations/<clickhouse_org_id>/prometheus"

  params = {
  "filtered_metrics" = ["true"],
  }

  honor_labels    = true
  scrape_interval = "30s"
  scrape_timeout  = "25s"

  basic_auth {
  username = "<clickhouse_api_key_id>"
  password = "<clickhouse_api_key_secret>"
  }

  forward_to = [prometheus.remote_write.grafana_cloud.receiver]
}

  prometheus.remote_write "grafana_cloud" {
  endpoint {
  url = "https://<grafana_prometheus_url>/api/prom/push"

  basic_auth {
  username = "<grafana_username>"
  password = "<grafana_api_token>"
  }
  }
}
```

Note the `honor_labels` configuration parameter needs to be set to `true` for the instance label to be properly populated.

### Grafana self-managed with Alloy[​](#grafana-self-managed-with-alloy "Direct link to Grafana self-managed with Alloy")

Self-managed users of Grafana can find the instructions for installing the Alloy agent [here](https://grafana.com/docs/alloy/latest/get-started/install/). We assume users have configured Alloy to send Prometheus metrics to their desired destination. The `prometheus.scrape` component below causes Alloy to scrape the ClickHouse Cloud Endpoint. We assume `prometheus.remote_write` receives the scraped metrics. Adjust the `forward_to key` to the target destination if this doesn't exist.

```
// prometheus.scrape component causes Alloy to scrape the ClickHouse Cloud Prometheus endpoint.
  // Adjust the forward_to key to match your remote_write receiver if it differs.
  prometheus.scrape "clickhouse_cloud" {
  targets = [{
  __address__ = "api.clickhouse.cloud",
  }]

  scheme       = "https"
  metrics_path = "/v1/organizations/<organizationId>/prometheus"

  params = {
  "filtered_metrics" = ["true"],
  }

  honor_labels = true

  basic_auth {
  username = "<KEY_ID>"
  password = "<KEY_SECRET>"
  }

  forward_to = [prometheus.remote_write.metrics_service.receiver]
}
```

Once configured, you should see ClickHouse related metrics in your metrics explorer:

  

Note the `honor_labels` configuration parameter needs to be set to `true` for the instance label to be properly populated.

## Integrating with Datadog[​](#integrating-with-datadog "Direct link to Integrating with Datadog")

You can use the Datadog [Agent](https://docs.datadoghq.com/agent/?tab=Linux) and [OpenMetrics integration](https://docs.datadoghq.com/integrations/openmetrics/) to collect metrics from the ClickHouse Cloud endpoint. Below is a simple example configuration for this agent and integration. Please note though that you may want to select only those metrics that you care about the most. The catch-all example below will export many thousands of metric-instance combinations which Datadog will treat as custom metrics.

```
init_config:

instances:
   - openmetrics_endpoint: 'https://api.clickhouse.cloud/v1/organizations/97a33bdb-4db3-4067-b14f-ce40f621aae1/prometheus?filtered_metrics=true'
     namespace: 'clickhouse'
     metrics:
         - '^ClickHouse.*'
     username: username
     password: password
```

  

## Related pages[​](#related "Direct link to Related pages")

- [Monitoring overview](/docs/cloud/monitoring) — Compare all monitoring approaches for ClickHouse Cloud
- [Cloud Console monitoring](/docs/cloud/monitoring/cloud-console) — Built-in dashboards that require no external tools
- [Community and partner integrations](/docs/cloud/monitoring/integrations) — Datadog agent integration and community solutions
- [Querying system tables](/docs/cloud/monitoring/system-tables) — Direct SQL access to system metrics

- [Prometheus endpoint API to retrieve ClickHouse Cloud metrics](#prometheus-endpoint-api-to-retrieve-clickhouse-cloud-metrics)
  - [API reference](#api-reference)- [Authentication](#authentication)- [Sample response](#sample-response)- [Metric labels](#metric-labels)- [Information metrics](#information-metrics)- [Configuring Prometheus](#configuring-prometheus)- [Integrating with Grafana](#integrating-with-grafana)
    - [Grafana Cloud with metrics endpoint](#grafana-cloud-with-metrics-endpoint)- [Grafana Cloud with Alloy](#grafana-cloud-with-alloy)- [Grafana self-managed with Alloy](#grafana-self-managed-with-alloy)- [Integrating with Datadog](#integrating-with-datadog)- [Related pages](#related)

Was this page helpful?