All Products
Search
Document Center

Container Service for Kubernetes:Use PromQL to query Prometheus monitoring data

Last Updated:Mar 01, 2026

Query monitoring data from your ACK cluster using Prometheus Query Language (PromQL) to verify the accuracy and timeliness of alert rules.

ACK clusters support two Prometheus deployment options -- Managed Service for Prometheus and open source Prometheus. Both support querying through the console UI and through the HTTP API.

Prerequisites

Before you begin, ensure that you have:

Query via console

Managed Service for Prometheus

  1. Log on to the ARMS console.

  2. In the left-side navigation pane, choose Managed Service for Prometheus > Instances.

  3. In the upper-left corner of the Managed Service for Prometheus page, select the region where your ACK cluster is located. In the Grafana Workspace column of the target instance, click Shared Edition.

  4. In the left-side navigation pane of the dashboard, click the 大盘 icon. From the drop-down list to the right of Explore in the upper-left corner, select the appropriate data source.

  5. In the text box next to Metric, enter a PromQL query statement and click Run query.

Open source Prometheus

To query open source Prometheus through the console, expose the Prometheus service over the Internet by attaching a Server Load Balancer (SLB) instance.

  1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, find the target cluster and click its name. In the left-side pane, choose Network > Services.

  3. On the Services page, select the namespace where ack-prometheus-operator is deployed (monitoring by default). Find ack-prometheus-operator-prometheus and click Update in the Actions column.

  4. In the Update Service dialog box, set Service Type to SLB. Select Create Resource and set Access Method to Public Access. Select Pay-as-you-go for the Billing Method parameter, configure other parameters as needed, and click OK.

    Note: SLB usage incurs charges. For details, see Classic Load Balancer (CLB) billing.
  5. After the update completes, copy the external IP address. Access the Prometheus console by entering IP address:port number in the browser address bar. Example: 47.XX.XX.12:9090.

  6. In the Prometheus console, click the Graph tab. Enter a PromQL query statement in the text box and click Execute.

Query via API

Managed Service for Prometheus

Get the HTTP API URL

  1. Log on to the ARMS console.

  2. In the left-side navigation pane, choose Managed Service for Prometheus > Instances.

  3. At the top of the Instances page, select the region where the Prometheus instance is located. In the Actions column for the target cluster, click Settings.

  4. On the Settings page, in the HTTP API URL (Grafana Read URL) section, copy the public or internal HTTP API URL as needed.

  5. (Optional) For a Prometheus V1 instance, click Generate Token to obtain an authentication token.

Important
  • V1 instance: After you generate the authentication token, specify the token when adding the Prometheus instance as a data source in Grafana. Otherwise, monitoring data cannot be read from the Prometheus instance.

  • V2 instance: By default, data access requires both an AccessKey ID and an AccessKey secret of your account. The associated RAM user must have the AliyunPrometheusMetricReadAccess or AliyunCloudMonitorFullAccess system permission.

V1 request example

Send a GET request to the instant query endpoint with a token-based authorization header:

GET {HTTP API}/api/v1/query

Accept: application/json
Content-Type: application/json
Authorization: {Token}

{
  "query":"arms_prometheus_target_interval_length_seconds_sum",
  "time":"1635302655",
  "timeout":"1000"
}

V2 request example

Send a GET request to the instant query endpoint with Base64-encoded AccessKey credentials:

GET {HTTP API}/api/v1/query

Accept: application/json
Content-Type: application/json
Authorization: Basic <base64Encode(<accessKey:secretKey>)>

{
  "query":"arms_prometheus_target_interval_length_seconds_sum",
  "time":"1635302655",
  "timeout":"1000"
}

For more information about the HTTP API, see the Prometheus HTTP API documentation.

Open source Prometheus

Get the HTTP API URL

Access from within the cluster

The default service URL for data requests to ack-prometheus-operator is:

http://ack-prometheus-operator-prometheus.monitoring:9090

Access over the Internet

To access open source Prometheus over the Internet, attach an SLB instance to the ack-prometheus-operator service:

  1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, find the target cluster and click its name. In the left-side pane, choose Network > Services.

  3. At the top of the Services page, set Namespace to monitoring. Find ack-prometheus-operator-prometheus and click Update in the Actions column.

  4. In the Update Service dialog box, set the following parameters and click Update.

    ParameterValue
    Service TypeServer Load Balancer (LoadBalancer). Set Access Method to Public Access.
    Port MappingEnter a port name. Set Service Port to 9090, Container Port to 9090, and Protocol to TCP.
  5. On the Services page, click the ack-prometheus-operator-prometheus service. In the Basic Information section, obtain the External IP. The external IP address is the HTTP API URL.

Call the HTTP API

Instant query

Query monitoring data at a specific point in time using the instant query endpoint:

GET {HTTP API}/api/v1/query

Headers:
Accept: application/json
Content-Type: application/json

Params:
{
  "query":"{{PromQL}}",
  "time":"1635302655",
  "timeout":"1000"
}
ParameterDescription
queryPromQL expression to evaluate.
timeEvaluation timestamp (RFC3339 or Unix timestamp).
timeoutEvaluation timeout. If the query exceeds this period, a result is returned.

Range query

Query monitoring data over a time range using the range query endpoint:

GET {HTTP API}/api/v1/query_range

Headers:
Accept: application/json
Content-Type: application/json

Params:
{
  "query":"{{PromQL}}",
  "start": 1673946024,
  "end": 1673949624,
  "step": 30
}
ParameterDescription
queryPromQL expression to evaluate.
startStart timestamp of the query range (RFC3339 or Unix timestamp).
endEnd timestamp of the query range (RFC3339 or Unix timestamp).
stepQuery resolution step width in duration format (for example, 15s or 1m) or float number of seconds.

References