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

# Discover Prometheus scrape targets for an organization

> **Disclaimer:** This beta endpoint is evolving; the API contract may change. <br /><br /> Returns one Prometheus scrape target per service in the organization that the caller is authorized to view, in HTTP service discovery (http_sd) format. Services the caller lacks view access to, and services in a terminated, terminating, or (soft-)deleted state, are omitted — the response can have fewer groups than the organization has services. Point a Prometheus http_sd_configs job at this endpoint to discover and scrape all services automatically; targets are refreshed on every discovery poll, so created and deleted services are picked up without reconfiguration. Targets scrape with filtered_metrics=true by default; pass ?filtered_metrics=false to this endpoint to discover unfiltered targets.

Sample Prometheus scrape config:

```yaml
scrape_configs:
  - job_name: clickhouse-cloud
    http_sd_configs:
      - url: https://api.clickhouse.cloud/v1/organizations/<organizationId>/prometheus/discovery
        refresh_interval: 60s
        basic_auth:
          username: <key-id>
          password: <key-secret>
    basic_auth:
      username: <key-id>
      password: <key-secret>
```

The `basic_auth` block must be set both under `http_sd_configs` (used to authenticate discovery polls against this endpoint) and on the scrape job itself (used to authenticate the actual per-service scrapes) — omitting either one is the most common misconfiguration.

<span data-endpoint-badge="Beta"><Badge color="blue">Beta</Badge></span>

**Disclaimer:** This beta endpoint is evolving; the API contract may change. <br /><br /> Returns one Prometheus scrape target per service in the organization that the caller is authorized to view, in HTTP service discovery (http\_sd) format. Services the caller lacks view access to, and services in a terminated, terminating, or (soft-)deleted state, are omitted — the response can have fewer groups than the organization has services. Point a Prometheus http\_sd\_configs job at this endpoint to discover and scrape all services automatically; targets are refreshed on every discovery poll, so created and deleted services are picked up without reconfiguration. Targets scrape with filtered\_metrics=true by default; pass ?filtered\_metrics=false to this endpoint to discover unfiltered targets.

Sample Prometheus scrape config:

```yaml theme={null}
scrape_configs:
  - job_name: clickhouse-cloud
    http_sd_configs:
      - url: https://api.clickhouse.cloud/v1/organizations/<organizationId>/prometheus/discovery
        refresh_interval: 60s
        basic_auth:
          username: <key-id>
          password: <key-secret>
    basic_auth:
      username: <key-id>
      password: <key-secret>
```

The `basic_auth` block must be set both under `http_sd_configs` (used to authenticate discovery polls against this endpoint) and on the scrape job itself (used to authenticate the actual per-service scrapes) — omitting either one is the most common misconfiguration.


## OpenAPI

````yaml _specs/cloud-openapi.json GET /v1/organizations/{organizationId}/prometheus/discovery
openapi: 3.1.2
info:
  title: OpenAPI spec for ClickHouse Cloud
  version: '1.0'
  contact:
    name: ClickHouse Support
    url: >-
      https://clickhouse.com/docs/en/cloud/manage/openapi?referrer=openapi-1064384
    email: support@clickhouse.com
servers:
  - url: https://api.clickhouse.cloud
security:
  - basicAuth: []
tags:
  - name: Organization
  - name: User management
  - name: Billing
  - name: Role Management
  - name: Service
  - name: Backup
  - name: OpenAPI
  - name: Prometheus
  - name: ClickPipes
  - name: ClickStack
  - name: Postgres
  - name: UDF
paths:
  /v1/organizations/{organizationId}/prometheus/discovery:
    get:
      tags:
        - Prometheus
      summary: Discover Prometheus scrape targets for an organization
      description: >-
        **Disclaimer:** This beta endpoint is evolving; the API contract may
        change. <br /><br /> Returns one Prometheus scrape target per service in
        the organization that the caller is authorized to view, in HTTP service
        discovery (http_sd) format. Services the caller lacks view access to,
        and services in a terminated, terminating, or (soft-)deleted state, are
        omitted — the response can have fewer groups than the organization has
        services. Point a Prometheus http_sd_configs job at this endpoint to
        discover and scrape all services automatically; targets are refreshed on
        every discovery poll, so created and deleted services are picked up
        without reconfiguration. Targets scrape with filtered_metrics=true by
        default; pass ?filtered_metrics=false to this endpoint to discover
        unfiltered targets.


        Sample Prometheus scrape config:


        ```yaml

        scrape_configs:
          - job_name: clickhouse-cloud
            http_sd_configs:
              - url: https://api.clickhouse.cloud/v1/organizations/<organizationId>/prometheus/discovery
                refresh_interval: 60s
                basic_auth:
                  username: <key-id>
                  password: <key-secret>
            basic_auth:
              username: <key-id>
              password: <key-secret>
        ```


        The `basic_auth` block must be set both under `http_sd_configs` (used to
        authenticate discovery polls against this endpoint) and on the scrape
        job itself (used to authenticate the actual per-service scrapes) —
        omitting either one is the most common misconfiguration.
      operationId: organizationPrometheusDiscoveryGet
      parameters:
        - in: path
          name: organizationId
          description: ID of the requested organization.
          required: true
          schema:
            type: string
            format: uuid
        - in: query
          name: filtered_metrics
          description: >-
            Whether discovered targets carry filtered_metrics=true or =false as
            a scrape param. Accepts true or false; defaults to true — the
            opposite default from the per-service prometheus endpoint.
          schema:
            type: string
            format: boolean
          example: 'true'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/PrometheusDiscoveryTargetGroup'
        '400':
          description: >-
            The request cannot be processed due to a client error. Please verify
            your request parameters and try again.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: number
                    description: HTTP status code.
                    example: 400
                  error:
                    type: string
                    description: Detailed error description.
                  requestId:
                    type: string
                    description: Unique id assigned to every request. UUIDv4
                    format: uuid
        '500':
          description: >-
            An internal server error has occurred. If this issue persists,
            please contact ClickHouse Cloud support for assistance.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                    description: HTTP status code.
                    example: 500
                  error:
                    type: string
                    description: Detailed error description.
                  requestId:
                    type: string
                    description: Unique id assigned to every request. UUIDv4
                    format: uuid
components:
  schemas:
    PrometheusDiscoveryTargetGroup:
      properties:
        targets:
          type: array
          description: Host (and port) of the ClickHouse Cloud API.
          items:
            type: string
        labels:
          $ref: '#/components/schemas/PrometheusDiscoveryLabels'
    PrometheusDiscoveryLabels:
      properties:
        __scheme__:
          description: URL scheme Prometheus must scrape the target with.
          type: string
        __metrics_path__:
          description: Path of the per-service Prometheus metrics endpoint.
          type: string
        __param_filtered_metrics:
          description: Value passed as the filtered_metrics query parameter on each scrape.
          type: string
          format: boolean
        clickhouse_org_id:
          description: Organization ID the service belongs to.
          type: string
          format: uuid
        clickhouse_service_id:
          description: Service ID.
          type: string
          format: uuid
        clickhouse_discovery_service_name:
          description: Service name.
          type: string
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: >-
        Use key ID and key secret obtained in ClickHouse Cloud console:
        https://clickhouse.com/docs/cloud/manage/openapi

````