Manage Prometheus instances
Manage the full lifecycle of Managed Service for Prometheus instances through the CLI aliyun cms2, including creating, querying, updating, deleting, and listing instances. A Prometheus instance is a metric storage backend available in V1 and V2 versions; you can filter by version when you list instances.
Instance-related commands are under the prometheus instance command group. For example, aliyun cms2 prometheus instance list.
Prerequisites
The CLI tool is installed and configured.
An AccessKey for the target Alibaba Cloud account with the
AliyunCloudMonitorFullAccesspermission granted.
prometheus instance create — Create an instance
Create a Prometheus instance. The body content is passed through to the CMS API as-is.
To connect a Simple Log Service (SLS) MetricStore or an Alibaba Cloud service, use the addon integration system instead of creating an instance manually. The integration system automatically completes instance activation, policy creation, and storage binding. See Manage integrations.
aliyun cms2 prometheus instance create --body '{
"prometheusInstanceName": "my-prometheus",
"workspace": "default-cms-12345-cn-hangzhou"
}'
# Create from a JSON file
aliyun cms2 prometheus instance create --body @./prometheus-create.json
# View example body and request schema
aliyun cms2 prometheus instance create --show-example-body
aliyun cms2 prometheus instance create --show-schemaParameter | Type | Description |
| string | Request body, inline JSON or |
| bool | Print an example request body and exit |
| bool | Print the JSON schema for the request body and exit |
Common body fields
Field | Description |
| Instance name |
| Workspace name |
| Storage duration (days) |
The body content is not validated on the CLI side. Field-level constraints are validated by the API. For complete field definitions, see the CMS API reference. The response returns prometheusInstanceId (the generated instance ID) and requestId.
prometheus instance get — Query an instance
Retrieve the full details of a Prometheus instance by instance ID, including the instance name, workspace, storage duration, status, and access endpoint.
# Basic query
aliyun cms2 prometheus instance get --prometheus-id pi-abc123def456
# Set language
aliyun cms2 prometheus instance get --prometheus-id pi-xxx --aliyun-lang zh
# Specify resource group
aliyun cms2 prometheus instance get --prometheus-id pi-xxx --resource-group-id rg-xxx
# JSON output
aliyun cms2 prometheus instance get --prometheus-id pi-abc123 -o jsonParameter | Type | Description |
| string | Prometheus instance ID (required) |
| string | Language setting ( |
| string | Resource group ID |
prometheus instance update — Update an instance
Update an existing Prometheus instance. Only fields included in the body are modified. Fields not included remain unchanged.
aliyun cms2 prometheus instance update --prometheus-id pi-abc123 --body '{
"prometheusInstanceName": "renamed-instance",
"storageDuration": 180,
"workspace": "default-cms-12345-cn-hangzhou"
}'
# Update from a file
aliyun cms2 prometheus instance update --prometheus-id pi-abc123 \
--body @./prometheus-update.jsonParameter | Type | Description |
| string | Prometheus instance ID (required) |
| string | Request body, inline JSON or |
| bool | Print an example request body and exit |
| bool | Print the JSON schema for the request body and exit |
prometheus instance delete — Delete an instance
Delete a specified Prometheus instance.
This operation is irreversible. All stored metric data is permanently deleted.
aliyun cms2 prometheus instance delete --prometheus-id pi-abc123def456Parameter | Type | Description |
| string | Prometheus instance ID (required) |
prometheus instance list — List instances
List Prometheus instances with support for multiple filter conditions and pagination.
# List all instances in a workspace
aliyun cms2 prometheus instance list --workspace default-cms-12345-cn-hangzhou
# Filter by region and version
aliyun cms2 prometheus instance list --filter-region-ids cn-hangzhou --version V2
# Fuzzy match by instance name
aliyun cms2 prometheus instance list --prometheus-instance-name my-instance
# Filter by instance ID list
aliyun cms2 prometheus instance list --prometheus-ids pi-001,pi-002
# Filter by tag
aliyun cms2 prometheus instance list --tag '[{"key":"env","value":"prod"}]'
# Paged query
aliyun cms2 prometheus instance list --workspace my-ws --max-results 10
aliyun cms2 prometheus instance list --workspace my-ws --max-results 10 --next-token "eyJ..."
# Text (CSV) output
aliyun cms2 prometheus instance list --workspace my-ws -o textParameter | Type | Description |
| string | Filter by region ID (comma-separated) |
| int32 | Maximum number of results to return |
| string | Pagination token |
| string | Filter by instance ID (comma-separated) |
| string | Fuzzy match by instance name |
| string | Resource group ID |
| string | Resource type |
| string | Filter by tag. Must be a JSON array with lowercase field names: |
| string | Instance version ( |
| string | Workspace name |
| string | Member account ID for cross-account delegation. |
Cross-account delegation mode
prometheus instance list supports the --member-account-id parameter for listing the Prometheus instances of a member account in Resource Management resource directory scenarios.
Before you use cross-account delegation, confirm the following prerequisites:
Credential — The credential must belong to the management account (the resource directory owner).
Member account — The member account must have joined the resource directory.
Region — In cross-account delegation mode, you must specify
--region(or--endpoint).
# List Prometheus instances of a member account
aliyun cms2 prometheus instance list \
--member-account-id 1234567890 \
--region cn-hangzhou \
--workspace default-cms-1234567890-cn-hangzhou
# Filter by tag across accounts
aliyun cms2 prometheus instance list \
--member-account-id 1234567890 \
--region cn-hangzhou \
--tag '[{"key":"env","value":"prod"}]'Currently, only the list subcommand supports cross-account delegation. The create, get, update, and delete subcommands are not supported in the current release.
Limits
listreturns a single page per request without automatic pagination. Use thenextTokenin the response to manually request the next page.The body for
createandupdateis not validated on the CLI side. Format errors are returned by the API.--tagmust be a JSON array with lowercase field names:[{"key":"k","value":"v"}].