Prometheus Targets API

Retrieve target and scrape pool information.

GitHub OpenAPI
Business capability
Observability Management BC-4220.20

Operations 4

Each operation below carries the questions people ask an LLM about it and the instructions they give an agent to run it. Generated by API Evangelist overlay

GET /scrape_pools List scrape pools · Get scrape pools #
Ask an LLM
“Which scrape pools are configured in Prometheus?”
“What scrape pools exist in my setup?”
Tell an agent
List all scrape pools.
Show the scrape pools configured in Prometheus.
GET /targets List targets in a scrape pool · Get targets #
Ask an LLM
“Which targets are up in a given scrape pool?”
“Can I list only dropped targets in a pool?”
Tell an agent
List targets in scrape pool {scrapePool}.
Show targets in pool {scrapePool} with state {state}.
GET /targets/metadata Get target metadata for a metric · Get targets metadata #
Ask an LLM
“What labels and help text does a metric expose on its targets?”
“Can I get metadata for a metric across targets matching a label selector?”
Tell an agent
Get metadata for metric {metric}.
Show target metadata for {metric} matching {match_target}.
GET /targets/relabel_steps Apply relabel rules to labels · Get targets relabel steps #
Ask an LLM
“How would Prometheus relabel a set of labels for a scrape pool?”
“Can I preview relabel steps for a target before it is scraped?”
Tell an agent
Apply relabel steps of pool {scrapePool} to labels {labels}.
Preview relabeling of {labels} in scrape pool {scrapePool}.

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/prometheus-io:prometheus-io-targets-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

prometheus-io-targets-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Prometheus Targets API
  description: Prometheus is an Open-Source monitoring system with a dimensional data model, flexible query language, efficient time series database and modern alerting approach.
  contact:
    name: Prometheus Community
    url: https://prometheus.io/community/
  version: 0.0.1-undefined
servers:
- url: /api/v1
tags:
- name: Targets
  description: Retrieve target and scrape pool information.
paths:
  /scrape_pools:
    get:
      tags:
      - Targets
      summary: Get scrape pools
      operationId: get-scrape-pools
      responses:
        '200':
          description: Scrape pools retrieved successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScrapePoolsOutputBody'
              examples:
                scrapePoolsList:
                  summary: List of scrape pool names
                  value:
                    data:
                      scrapePools:
                      - alertmanager
                      - blackbox
                      - caddy
                      - cadvisor
                      - grafana
                      - node
                      - prometheus
                      - random
                    status: success
        default:
          description: Error retrieving scrape pools.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                tsdbNotReady:
                  summary: TSDB not ready
                  value:
                    error: TSDB not ready
                    errorType: internal
                    status: error
  /targets:
    get:
      tags:
      - Targets
      summary: Get targets
      operationId: get-targets
      parameters:
      - name: scrapePool
        in: query
        description: Filter targets by scrape pool name.
        required: false
        explode: false
        schema:
          type: string
        examples:
          example:
            value: prometheus
      - name: state
        in: query
        description: 'Filter by state: active, dropped, or any.'
        required: false
        explode: false
        schema:
          type: string
        examples:
          example:
            value: active
      responses:
        '200':
          description: Target discovery information retrieved successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TargetsOutputBody'
              examples:
                targetsList:
                  summary: Active and dropped targets
                  value:
                    data:
                      activeTargets:
                      - discoveredLabels:
                          __address__: demo.prometheus.io:9093
                          __meta_filepath: /etc/prometheus/file_sd/alertmanager.yml
                          __metrics_path__: /metrics
                          __scheme__: http
                          env: demo
                          job: alertmanager
                        globalUrl: http://demo.prometheus.io:9093/metrics
                        health: up
                        labels:
                          env: demo
                          instance: demo.prometheus.io:9093
                          job: alertmanager
                        lastError: ''
                        lastScrape: '2026-01-02T13:36:40.200Z'
                        lastScrapeDuration: 0.006576866
                        scrapeInterval: 15s
                        scrapePool: alertmanager
                        scrapeTimeout: 10s
                        scrapeUrl: http://demo.prometheus.io:9093/metrics
                      droppedTargetCounts:
                        alertmanager: 0
                        blackbox: 0
                        caddy: 0
                        cadvisor: 0
                        grafana: 0
                        node: 0
                        prometheus: 0
                        random: 0
                      droppedTargets: []
                    status: success
        default:
          description: Error retrieving targets.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                tsdbNotReady:
                  summary: TSDB not ready
                  value:
                    error: TSDB not ready
                    errorType: internal
                    status: error
  /targets/metadata:
    get:
      tags:
      - Targets
      summary: Get targets metadata
      operationId: get-targets-metadata
      parameters:
      - name: match_target
        in: query
        description: Label selector to filter targets.
        required: false
        explode: false
        schema:
          type: string
        examples:
          example:
            value: '{job="prometheus"}'
      - name: metric
        in: query
        description: Metric name to retrieve metadata for.
        required: false
        explode: false
        schema:
          type: string
        examples:
          example:
            value: http_requests_total
      - name: limit
        in: query
        description: Maximum number of targets to match.
        required: false
        explode: false
        schema:
          type: integer
          format: int64
        examples:
          example:
            value: 10
      responses:
        '200':
          description: Target metadata retrieved successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TargetMetadataOutputBody'
              examples:
                targetMetadata:
                  summary: Metadata for targets
                  value:
                    data:
                    - help: The current health status of the target
                      metric: up
                      target:
                        instance: localhost:9090
                        job: prometheus
                      type: gauge
                      unit: ''
                    status: success
        default:
          description: Error retrieving target metadata.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                tsdbNotReady:
                  summary: TSDB not ready
                  value:
                    error: TSDB not ready
                    errorType: internal
                    status: error
  /targets/relabel_steps:
    get:
      tags:
      - Targets
      summary: Get targets relabel steps
      operationId: get-targets-relabel-steps
      parameters:
      - name: scrapePool
        in: query
        description: Name of the scrape pool.
        required: true
        explode: false
        schema:
          type: string
        examples:
          example:
            value: prometheus
      - name: labels
        in: query
        description: JSON-encoded labels to apply relabel rules to.
        required: true
        explode: false
        schema:
          type: string
        examples:
          example:
            value: '{"__address__":"localhost:9090","job":"prometheus"}'
      responses:
        '200':
          description: Relabel steps retrieved successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TargetRelabelStepsOutputBody'
              examples:
                relabelSteps:
                  summary: Relabel steps for a target
                  value:
                    data:
                      steps:
                      - keep: true
                        output:
                          __address__: localhost:9090
                          instance: localhost:9090
                          job: prometheus
                        rule:
                          action: replace
                          regex: (.*)
                          replacement: $1
                          source_labels:
                          - __address__
                          target_label: instance
                    status: success
        default:
          description: Error retrieving relabel steps.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                tsdbNotReady:
                  summary: TSDB not ready
                  value:
                    error: TSDB not ready
                    errorType: internal
                    status: error
components:
  schemas:
    ScrapePoolsOutputBody:
      type: object
      properties:
        status:
          type: string
          enum:
          - success
          - error
          description: Response status.
          example: success
        data:
          $ref: '#/components/schemas/ScrapePoolsDiscovery'
        warnings:
          type: array
          items:
            type: string
          description: Only set if there were warnings while executing the request. There will still be data in the data field.
        infos:
          type: array
          items:
            type: string
          description: Only set if there were info-level annotations while executing the request.
      required:
      - status
      - data
      additionalProperties: false
      description: Response body for scrape pools endpoint.
    TargetMetadataOutputBody:
      type: object
      properties:
        status:
          type: string
          enum:
          - success
          - error
          description: Response status.
          example: success
        data:
          type: array
          items:
            $ref: '#/components/schemas/MetricMetadata'
          example:
          - help: The current health status of the target
            metric: up
            target:
              instance: localhost:9090
              job: prometheus
            type: gauge
            unit: ''
        warnings:
          type: array
          items:
            type: string
          description: Only set if there were warnings while executing the request. There will still be data in the data field.
        infos:
          type: array
          items:
            type: string
          description: Only set if there were info-level annotations while executing the request.
      required:
      - status
      - data
      additionalProperties: false
      description: Response body with an array of metric metadata.
    Labels:
      type: object
      additionalProperties: true
      description: Label set represented as a key-value map.
    DroppedTarget:
      type: object
      properties:
        discoveredLabels:
          $ref: '#/components/schemas/Labels'
        scrapePool:
          type: string
          description: Name of the scrape pool.
      required:
      - discoveredLabels
      - scrapePool
      additionalProperties: false
      description: Dropped target information.
    RelabelStepsResponse:
      type: object
      properties:
        steps:
          type: array
          items:
            $ref: '#/components/schemas/RelabelStep'
      required:
      - steps
      additionalProperties: false
      description: Relabeling steps response.
    Error:
      type: object
      properties:
        status:
          type: string
          enum:
          - success
          - error
          description: Response status.
          example: success
        errorType:
          type: string
          description: Type of error that occurred.
          example: bad_data
        error:
          type: string
          description: Human-readable error message.
          example: invalid parameter
      required:
      - status
      - errorType
      - error
      additionalProperties: false
      description: Error response.
    MetricMetadata:
      type: object
      properties:
        target:
          $ref: '#/components/schemas/Labels'
        metric:
          type: string
          description: Metric name.
        type:
          type: string
          description: Metric type (counter, gauge, histogram, summary, or untyped).
        help:
          type: string
          description: Help text describing the metric.
        unit:
          type: string
          description: Unit of the metric.
      required:
      - target
      - type
      - help
      - unit
      additionalProperties: false
      description: Target metric metadata.
    ScrapePoolsDiscovery:
      type: object
      properties:
        scrapePools:
          type: array
          items:
            type: string
      required:
      - scrapePools
      additionalProperties: false
      description: List of all configured scrape pools.
    RelabelStep:
      type: object
      properties:
        rule:
          $ref: '#/components/schemas/Config'
        output:
          $ref: '#/components/schemas/Labels'
        keep:
          type: boolean
      required:
      - rule
      - output
      - keep
      additionalProperties: false
      description: Relabel step showing the rule, output, and whether the target was kept.
    Config:
      type: object
      properties:
        source_labels:
          type: array
          items:
            type: string
          description: Source labels for relabeling.
        separator:
          type: string
          description: Separator for source label values.
        regex:
          type: string
          description: Regular expression for matching.
        modulus:
          type: integer
          format: int64
          description: Modulus for hash-based relabeling.
        target_label:
          type: string
          description: Target label name.
        replacement:
          type: string
          description: Replacement value.
        action:
          type: string
          description: Relabel action.
      additionalProperties: false
      description: Relabel configuration.
    Target:
      type: object
      properties:
        discoveredLabels:
          $ref: '#/components/schemas/Labels'
        labels:
          $ref: '#/components/schemas/Labels'
        scrapePool:
          type: string
          description: Name of the scrape pool.
        scrapeUrl:
          type: string
          description: URL of the target.
        globalUrl:
          type: string
          description: Global URL of the target.
        lastError:
          type: string
          description: Last error message from scraping.
        lastScrape:
          type: string
          format: date-time
          description: Timestamp of the last scrape.
        lastScrapeDuration:
          type: number
          format: double
          description: Duration of the last scrape in seconds.
        health:
          type: string
          description: Health status of the target (up, down, or unknown).
        scrapeInterval:
          type: string
          description: Scrape interval for this target.
        scrapeTimeout:
          type: string
          description: Scrape timeout for this target.
      required:
      - discoveredLabels
      - labels
      - scrapePool
      - scrapeUrl
      - globalUrl
      - lastError
      - lastScrape
      - lastScrapeDuration
      - health
      - scrapeInterval
      - scrapeTimeout
      additionalProperties: false
      description: Scrape target information.
    TargetDiscovery:
      type: object
      properties:
        activeTargets:
          type: array
          items:
            $ref: '#/components/schemas/Target'
        droppedTargets:
          type: array
          items:
            $ref: '#/components/schemas/DroppedTarget'
        droppedTargetCounts:
          type: object
          additionalProperties:
            type: integer
            format: int64
      required:
      - activeTargets
      - droppedTargets
      - droppedTargetCounts
      additionalProperties: false
      description: Target discovery information including active and dropped targets.
    TargetRelabelStepsOutputBody:
      type: object
      properties:
        status:
          type: string
          enum:
          - success
          - error
          description: Response status.
          example: success
        data:
          $ref: '#/components/schemas/RelabelStepsResponse'
        warnings:
          type: array
          items:
            type: string
          description: Only set if there were warnings while executing the request. There will still be data in the data field.
        infos:
          type: array
          items:
            type: string
          description: Only set if there were info-level annotations while executing the request.
      required:
      - status
      - data
      additionalProperties: false
      description: Response body for target relabel steps endpoint.
    TargetsOutputBody:
      type: object
      properties:
        status:
          type: string
          enum:
          - success
          - error
          description: Response status.
          example: success
        data:
          $ref: '#/components/schemas/TargetDiscovery'
        warnings:
          type: array
          items:
            type: string
          description: Only set if there were warnings while executing the request. There will still be data in the data field.
        infos:
          type: array
          items:
            type: string
          description: Only set if there were info-level annotations while executing the request.
      required:
      - status
      - data
      additionalProperties: false
      description: Response body for targets endpoint.