Skip to main content

prometheus_scrape_targets

Creates, updates, deletes, gets or lists a prometheus_scrape_targets resource.

Overview

Nameprometheus_scrape_targets
TypeResource
Idclickhouse.organizations.prometheus_scrape_targets

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
labelsobject
targetsarrayHost (and port) of the ClickHouse Cloud API.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
listselectorganization_idfiltered_metricsDisclaimer: 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.<br /><br />Sample Prometheus scrape config:<br /><br />yaml&lt;br /&gt;scrape_configs:&lt;br /&gt; - job_name: clickhouse-cloud&lt;br /&gt; http_sd_configs:&lt;br /&gt; - url: https:​//api.clickhouse.cloud/v1/organizations/&lt;organizationId&gt;/prometheus/discovery&lt;br /&gt; refresh_interval: 60s&lt;br /&gt; basic_auth:&lt;br /&gt; username: &lt;key-id&gt;&lt;br /&gt; password: &lt;key-secret&gt;&lt;br /&gt; basic_auth:&lt;br /&gt; username: &lt;key-id&gt;&lt;br /&gt; password: &lt;key-secret&gt;&lt;br /&gt;<br /><br />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.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
organization_idstringClickHouse Cloud organization ID. Resolved from the CLICKHOUSE_ORG_ID environment variable when it is set (x-stackQL-envVar); otherwise it must be supplied on every query as WHERE organization_id = <uuid>. A WHERE value always takes precedence over the environment. (x-stackQL-envVar: CLICKHOUSE_ORG_ID)
filtered_metricsstring (boolean)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. (example: true)

SELECT examples

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.<br /><br />Sample Prometheus scrape config:<br /><br />yaml&lt;br /&gt;scrape_configs:&lt;br /&gt; - job_name: clickhouse-cloud&lt;br /&gt; http_sd_configs:&lt;br /&gt; - url: https:​//api.clickhouse.cloud/v1/organizations/&lt;organizationId&gt;/prometheus/discovery&lt;br /&gt; refresh_interval: 60s&lt;br /&gt; basic_auth:&lt;br /&gt; username: &lt;key-id&gt;&lt;br /&gt; password: &lt;key-secret&gt;&lt;br /&gt; basic_auth:&lt;br /&gt; username: &lt;key-id&gt;&lt;br /&gt; password: &lt;key-secret&gt;&lt;br /&gt;<br /><br />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.

SELECT
labels,
targets
FROM clickhouse.organizations.prometheus_scrape_targets
WHERE organization_id = '{{ organization_id }}' -- required unless CLICKHOUSE_ORG_ID is set
AND filtered_metrics = '{{ filtered_metrics }}'
;