All Products
Search
Document Center

Managed Service for Prometheus:Access Prometheus monitoring 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 outside the Alibaba Cloud console. Two common use cases:

  • Self-managed Grafana: Add the HTTP API URL as a Prometheus data source to visualize metrics in your own Grafana instance.

  • Custom applications: Call the Prometheus-compatible HTTP API directly to retrieve metrics programmatically.

Authentication

Managed Service for Prometheus supports two instance versions, each with a different authentication method.

Instance versionAuthentication methodCredentials
Prometheus V1Token-based (optional)Authentication token generated in the console
Prometheus V2Basic auth (required)AccessKey ID and AccessKey secret of your account, and the associated RAM user must have AliyunPrometheusMetricReadAccess or AliyunCloudMonitorFullAccess permission
Important

For Prometheus V2, data access requires both an AccessKey ID and AccessKey secret of your account, and the associated RAM user must have the AliyunPrometheusMetricReadAccess or AliyunCloudMonitorFullAccess system permission.

Prerequisites

Before you begin, make sure that you have:

Get the HTTP API URL

  1. Log on to the CloudMonitor console.

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

  3. In the top navigation bar, select the region where your Prometheus instance resides.

  4. Find your Prometheus instance, and then click Settings in the Actions column.

  5. On the Settings tab, copy the HTTP API URL. HTTP API URL on the Settings tab

    • Use the public URL if your Grafana instance or application is outside the Alibaba Cloud internal network.

    • Use the internal URL if your Grafana instance or application runs within the same Alibaba Cloud region and can access internal endpoints.

  6. (Prometheus V1 only) Click Generate Token to create an authentication token. Save this token for later use.

Important

For a Prometheus V1 instance, after you generate a token, you must include it when configuring the Grafana data source. Without the token, Grafana cannot read monitoring data from the instance.

Configure a self-managed Grafana data source

Add the data source

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

  2. Go to Connections > Data sources.

    This menu is visible only to Grafana administrators. In Grafana 8 and earlier, go to Configuration > Data sources. The Connections menu is available in Grafana 9 and later.
  3. Click + Add data source, and then select Prometheus.

  4. In the Name field, enter a descriptive name for the data source.

  5. In the Prometheus server URL field (under the HTTP section), paste the HTTP API URL you copied earlier.

Configure authentication

Follow the steps for your Prometheus instance version.

Prometheus V1

If you generated a token, add it as a custom HTTP header:

  1. In the Custom HTTP Headers section, click + Add header.

  2. Set Header to Authorization.

  3. Set Value to the authentication token.

Custom HTTP header configuration for Prometheus V1

Prometheus V2

  1. Turn on Basic auth.

  2. Set User to your AccessKey ID.

  3. Set Password to your AccessKey secret.

Basic auth configuration for Prometheus V2

Save and test

Click Save & test. A success message confirms that Grafana can reach the Prometheus data source.

Verify the data source in Grafana

  1. In Grafana, go to Dashboards and click New > New dashboard.

  2. Click + Add visualization and select the data source you configured.

  3. On the Edit Panel page, open the Query tab. In section A, enter a metric name in the Metrics field (for example, arms_prometheus_target_interval_length_seconds_sum) and configure any Label filters as needed.

  4. Click Run queries.

If a chart renders with metric data, the data source is working. If no chart appears, check whether the API URL or token is valid and whether the data source has monitoring data. For additional help, see Troubleshooting.

Query the HTTP API programmatically

The following examples use the /api/v1/query endpoint for instant queries. For range queries (/api/v1/query_range), series metadata, and other endpoints, see the Prometheus HTTP API reference.

Prometheus V1

curl -G '<your-http-api-url>/api/v1/query' \
  -H 'Authorization: <your-token>' \
  -H 'Accept: application/json' \
  --data-urlencode 'query=arms_prometheus_target_interval_length_seconds_sum' \
  --data-urlencode 'time=1635302655' \
  --data-urlencode 'timeout=1000'

Replace the following placeholders with actual values:

PlaceholderDescriptionExample
<your-http-api-url>The HTTP API URL from the Settings tabhttps://cn-hangzhou.arms.aliyuncs.com/...
<your-token>The authentication token generated in the consoleeyJhbGciOi...

Prometheus V2

curl -G '<your-http-api-url>/api/v1/query' \
  -u '<your-accesskey-id>:<your-accesskey-secret>' \
  -H 'Accept: application/json' \
  --data-urlencode 'query=arms_prometheus_target_interval_length_seconds_sum' \
  --data-urlencode 'time=1635302655' \
  --data-urlencode 'timeout=1000'

Replace the following placeholders with actual values:

PlaceholderDescriptionExample
<your-http-api-url>The HTTP API URL from the Settings tabhttps://cn-hangzhou.arms.aliyuncs.com/...
<your-accesskey-id>The AccessKey ID of your accountLTAI5tXxx...
<your-accesskey-secret>The AccessKey secret of your accountxXxXxXx...
The -u flag encodes the AccessKey ID and AccessKey secret as a Base64 Authorization: Basic header automatically.

Query parameters

ParameterRequiredDescription
queryYesA PromQL expression to evaluate
timeNoEvaluation timestamp (Unix timestamp or RFC 3339). Defaults to the current server time
timeoutNoEvaluation timeout in milliseconds

Sample response

A successful query returns a JSON response like the following:

{
    "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
HTTP 401 UnauthorizedInvalid or missing credentialsVerify the token (V1) or AccessKey pair (V2). Regenerate if expired.
HTTP 403 ForbiddenInsufficient permissionsGrant the RAM user AliyunPrometheusMetricReadAccess or AliyunCloudMonitorFullAccess.
Connection timeoutNetwork unreachableIf Grafana runs outside Alibaba Cloud, use the public HTTP API URL. If it runs inside the same region, use the internal URL.
No data in Grafana chartNo ingested data for the queried metricConfirm that the Prometheus instance is actively scraping targets and the metric name is correct.

Related topics