Configuration shape
A Prometheus metric carries asource_config of:
prometheus_url overrides the agent’s
PROMETHEUS_SERVER_URL for this single metric. Use it when one
agent serves multiple Prometheus servers.
Query requirements
- The query must return a single scalar value. Use aggregation
(
sum,avg,rate, etc.) to collapse vector results. - Empty results are reported as
no_data; the metric does not flip status until the query produces a value. - A result with more than one series is reported as
no_datawith reasonprom_multiple_series. - The agent does not interpret the query content. The cloud’s push payload contains the precomputed status, not the query string.
Reason codes
The full catalog, with the hint the console shows for each code, is in Reason codes. A metric that cannot produce a value reportsno_data with one of:
prometheus_url_missing: neitherprometheus_urlnorPROMETHEUS_SERVER_URLis set.invalid_prometheus_url: the configured URL is not a valid URL.no_data_for_query: the query returned no series, or a value that is not a finite number.prom_multiple_series: the query returned more than one series. Aggregate it down to one.Unauthorized,BadQuery,PromUpstream: Prometheus answered 401 or 403, 400, or 5xx.prometheus_auth_conflict: a bearer token and basic auth are both set, orPROMETHEUS_HEADERSrepeats a header another variable already sets (agent 1.6.2+).prometheus_headers_invalid:PROMETHEUS_HEADERSis neither a JSON object nor aName: value; Name2: valuelist (agent 1.6.2+).ECONNREFUSED,ETIMEDOUT,ENOTFOUND,ECONNRESET,EHOSTUNREACH,connect_failed: the request did not reach Prometheus. Older agents report a failed lookup asDNS, and a refused port or a failed lookup asConnectionRefused.
Authentication
When Prometheus requires basic auth, set on the agent:PROMETHEUS_BEARER_TOKEN), a tenant header
(PROMETHEUS_TENANT_ID) and any other header
(PROMETHEUS_HEADERS). A bearer token and basic auth cannot be used
together. Header values are never written to the agent log.
Grafana CloudGrafana Cloud’s hosted Prometheus uses basic auth. The
credentials issued by Grafana for read access drop in here
unchanged. See
Connect to Grafana Cloud.
Grafana Mimir and other Prometheus-compatible backends
Requires agent 1.6.2 or later. Any backend that serves the Prometheus HTTP API (/api/v1/query)
works as a Prometheus source: Grafana Mimir, Cortex, Thanos Query,
VictoriaMetrics and Grafana Cloud. Set PROMETHEUS_SERVER_URL to the
base URL of the query API, including any path prefix. The agent keeps
the prefix and appends /api/v1/query.
Grafana Mimir with a tenant
Mimir is multi-tenant: each request names its tenant in theX-Scope-OrgID header. Set the tenant with PROMETHEUS_TENANT_ID:
PROMETHEUS_TENANT_ID unset. If a gateway in front of Mimir also
asks for credentials, add basic auth or a bearer token as below.
Grafana Cloud with basic auth
Grafana Cloud’s hosted Prometheus uses basic auth: the username is the numeric user ID shown on the stack’s Prometheus details page and the password is an access policy token with themetrics:read
scope. See Connect to Grafana Cloud.
Bearer token
For a backend or gateway that expectsAuthorization: Bearer, set
PROMETHEUS_BEARER_TOKEN and turn basic auth off:
PROMETHEUS_PASSWORD set), the agent
logs an error at startup and Prometheus metrics report no_data
with reason prometheus_auth_conflict.
Other headers
PROMETHEUS_HEADERS adds any other header, as a JSON object or a
Name: value; Name2: value list:
PROMETHEUS_HEADERS on the
agent host like any other secret. The Add agent screen in the console
writes them into the install command as variables you fill in on the
host, never as values.
Threshold examples
The strict-comparison rule applies (see
threshold operators in the
Documentation tab).

