All Products
Search
Document Center

Application Real-Time Monitoring Service:Access Prometheus data through HTTP API URLs

Last Updated:Mar 10, 2026

Managed Service for Prometheus exposes HTTP API URLs that let you query monitoring data from a self-managed Grafana instance or any application that supports the Prometheus HTTP API.

Prerequisites

Before you begin, make sure you have:

Get the HTTP API URL

  1. Log on to the Cloud Monitor console. In the left navigation pane, choose Managed Service for Prometheus > Instances.

  2. In the top navigation bar, select the region where the Prometheus instance is deployed. Find the instance and click Settings in the Actions column.

  3. On the Settings tab, copy the public or internal HTTP API URL.

    HTTP API URL on the Settings tab

Set up authentication

Authentication differs between Prometheus V1 and V2 instances. Check your version before proceeding.

Prometheus V1 (token-based, optional)

Optionally, on the Settings tab, click Generate Token to create an authentication token. Save this token -- you need it when adding the data source to Grafana and when making API requests.

Important

After the authentication token is generated, you must specify the token when you add the Prometheus instance to your Grafana system as a data source. Otherwise, monitoring data cannot be read from the Prometheus instance.

Prometheus V2 (AccessKey-based)

By default, data access requires both an AccessKey ID and AccessKey secret with HTTP Basic authentication. No token is needed.

The associated RAM user must have one of the following system permissions:

  • AliyunPrometheusMetricReadAccess -- read-only access to metrics

  • AliyunCloudMonitorFullAccess -- full access to Cloud Monitor

To grant these permissions, see Grant permissions to a RAM user.

Add the data source to self-managed Grafana

Configure the Prometheus data source

  1. Log on to your Grafana instance as an administrator.

  2. Click the Grafana menu icon icon in the upper-left corner. In the left navigation pane, choose Configuration > Data sources.

    Note

    This menu is visible only to administrators.

  3. Click + Add data source, then select Prometheus.

  4. On the Settings tab, configure the following fields:

    FieldValue
    NameA descriptive name for this data source
    Prometheus server URLThe HTTP API URL copied from the Get the HTTP API URL step
  5. Configure authentication based on your Prometheus version: Prometheus V1: If you generated a token, click + Add header in the Custom HTTP Headers section. Set the Header to Authorization and the Value to the token from the Set up authentication step. Prometheus V2: Turn on Basic auth. Set User to your AccessKey ID and Password to your AccessKey secret.

    Custom HTTP Headers configuration for V1

    Basic auth configuration for V2

  6. Click Save & test.

Verify the data source

  1. Click the Grafana menu icon icon in the upper-left corner, and then click Dashboards in the left navigation pane.

  2. Click New > New dashboard, then click + Add visualization.

  3. On the Select data source page, select the data source you configured.

  4. In the Query tab, enter a metric name in the Metrics field and a label filter in the Label filters field. Click Run queries. If a chart appears, the data source is connected. If no chart appears, see Troubleshooting.

    Query results chart

Query Prometheus data with the HTTP API

The standard Prometheus HTTP API supports programmatic access to monitoring data.

Request format

Authentication headers differ between V1 and V2.

Prometheus V1:

GET <http-api-url>/api/v1/query

Accept: application/json
Content-Type: application/json
Authorization: <your-auth-token>

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

Prometheus V2:

GET <http-api-url>/api/v1/query

Accept: application/json
Content-Type: application/json
Authorization: Basic <base64-encoded-accesskey-id:accesskey-secret>

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

Replace the following placeholders with actual values:

PlaceholderDescriptionExample
<http-api-url>The HTTP API URL from the Settings tabhttps://cn-hangzhou.arms.aliyuncs.com/...
<your-auth-token>(V1) The token generated in the consoleeyJhbGci...
<base64-encoded-accesskey-id:accesskey-secret>(V2) Base64-encoded AccessKeyID:AccessKeySecretTFRBSTV0WH...

View sample response

{
    "status": "success",
    "data": {
        "resultType": "vector",
        "result": [
            {
                "metric": {
                    "__name__": "arms_prometheus_target_interval_length_seconds_sum",
                    "instance": "localhost:9335",
                    "interval": "15s",
                    "job": "_arms-prom/kubelet/1"
                },
                "value": [
                    1635302655,
                    "146655.24420603***"
                ]
            },
            {
                "metric": {
                    "__name__": "arms_prometheus_target_interval_length_seconds_sum",
                    "instance": "localhost:9335",
                    "interval": "30s",
                    "job": "_arms-prom/kubelet/1"
                },
                "value": [
                    1635302655,
                    "879810.747346***"
                ]
            },
            {
                "metric": {
                    "__name__": "arms_prometheus_target_interval_length_seconds_sum",
                    "instance": "localhost:9335",
                    "interval": "20s",
                    "job": "_arms-prom/kubelet/1"
                },
                "value": [
                    1635302655,
                    "73320.13578499***"
                ]
            }
        ]
    }
}

Troubleshooting

SymptomPossible causeSolution
Save & test fails with an authentication error(V1) Invalid or missing token in the Authorization headerRegenerate the token on the Settings tab and update the Custom HTTP Headers value
Save & test fails with an authentication error(V2) Incorrect AccessKey ID or AccessKey secretVerify the credentials. Make sure the RAM user has AliyunPrometheusMetricReadAccess or AliyunCloudMonitorFullAccess permission
Save & test fails with a connection errorIncorrect HTTP API URL or network connectivity issueConfirm the URL on the Settings tab. If you use an internal URL, make sure your Grafana instance can reach the internal endpoint
Query returns no dataThe Prometheus instance has no monitoring data yet, or the metric name is incorrectMake sure the Prometheus instance is actively scraping targets and check the metric name
API request returns 401 Unauthorized(V1) Missing tokenGenerate a new token and include it in the Authorization header
API request returns 403 Forbidden(V2) The RAM user lacks the required permissionsGrant AliyunPrometheusMetricReadAccess to the RAM user

What's next