Manage Prometheus instances

Updated at:

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.

Note

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 AliyunCloudMonitorFullAccess permission granted.

prometheus instance create — Create an instance

Create a Prometheus instance. The body content is passed through to the CMS API as-is.

Note

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-schema

Parameter

Type

Description

--body

string

Request body, inline JSON or @file.json (required)

--show-example-body

bool

Print an example request body and exit

--show-schema

bool

Print the JSON schema for the request body and exit

Common body fields

Field

Description

prometheusInstanceName

Instance name

workspace

Workspace name

storageDuration

Storage duration (days)

Note

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 json

Parameter

Type

Description

--prometheus-id

string

Prometheus instance ID (required)

--aliyun-lang

string

Language setting (zh | en)

--resource-group-id

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.json

Parameter

Type

Description

--prometheus-id

string

Prometheus instance ID (required)

--body

string

Request body, inline JSON or @file.json (required)

--show-example-body

bool

Print an example request body and exit

--show-schema

bool

Print the JSON schema for the request body and exit

prometheus instance delete — Delete an instance

Delete a specified Prometheus instance.

Warning

This operation is irreversible. All stored metric data is permanently deleted.

aliyun cms2 prometheus instance delete --prometheus-id pi-abc123def456

Parameter

Type

Description

--prometheus-id

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 text

Parameter

Type

Description

--filter-region-ids

string

Filter by region ID (comma-separated)

--max-results

int32

Maximum number of results to return

--next-token

string

Pagination token

--prometheus-ids

string

Filter by instance ID (comma-separated)

--prometheus-instance-name

string

Fuzzy match by instance name

--resource-group-id

string

Resource group ID

--resource-type

string

Resource type

--tag

string

Filter by tag. Must be a JSON array with lowercase field names: [{"key":"k","value":"v"}]

--version

string

Instance version (V1 | V2)

--workspace

string

Workspace name

--member-account-id

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"}]'
Note

Currently, only the list subcommand supports cross-account delegation. The create, get, update, and delete subcommands are not supported in the current release.

Limits

  • list returns a single page per request without automatic pagination. Use the nextToken in the response to manually request the next page.

  • The body for create and update is not validated on the CLI side. Format errors are returned by the API.

  • --tag must be a JSON array with lowercase field names: [{"key":"k","value":"v"}].