Manage Prometheus views
Manage the full lifecycle of Managed Service for Prometheus views through the CLI aliyun cms2. A Prometheus view is an aggregation query layer on top of one or more Prometheus instances that supports unified cross-instance queries.
View-related commands are under the
prometheus viewcommand group (for example,aliyun cms2 prometheus view list).The
--prometheus-idparameter accepts both instance IDs and view IDs. You can also use a view ID directly with the--prometheus-idparameter of themetric promqlcommand.
Prerequisites
The CLI tool is installed and configured.
You have created at least one Prometheus instance.
prometheus view create — Create a Prometheus view
Create a Prometheus view. The body content is passed as-is to the Cloud Monitor API.
Run the following command:
aliyun cms2 prometheus view create --body '{
"prometheusViewName": "global-view",
"workspace": "default-cms-12345-cn-hangzhou"
}'
# Create from a JSON file
aliyun cms2 prometheus view create --body @./prometheus-view-create.jsonParameter | Type | Description |
| string | Request body in inline JSON or |
| bool | Print an example request body and exit. |
| bool | Print the JSON schema of the request body and exit. |
The create command does not perform client-side schema validation on the body. Format errors are returned by the API. The response returns prometheusViewId (the generated view ID) and requestId.
prometheus view get — Get Prometheus view details
Retrieve the full details of a Prometheus view by view ID, including the view name, workspace, associated instances, and status.
Run the following command:
aliyun cms2 prometheus view get --prometheus-id pv-abc123def456
# Set language and resource group
aliyun cms2 prometheus view get --prometheus-id pv-xxx \
--aliyun-lang zh --resource-group-id rg-xxx
# JSON output
aliyun cms2 prometheus view get --prometheus-id pv-abc123 -o jsonParameter | Type | Description |
| string | Prometheus view ID. Required. |
| string | Language setting ( |
| string | Resource group ID. |
prometheus view update — Update a Prometheus View
Update an existing Prometheus view. Only the fields included in the body are modified.
Run the following command:
aliyun cms2 prometheus view update --prometheus-id pv-abc123 \
--body '{"prometheusViewName": "new-name"}'Parameter | Type | Description |
| string | Prometheus view ID. Required. |
| string | Request body in inline JSON or |
| bool | Print an example request body and exit. |
| bool | Print the JSON schema of the request body and exit. |
The update command does not perform client-side schema validation on the body. Format errors are returned by the API.
prometheus view delete — Delete a Prometheus View
Delete a Prometheus view.
Deleting a view does not affect the underlying associated Prometheus instances.
Run the following command:
aliyun cms2 prometheus view delete --prometheus-id pv-abc123def456Parameter | Type | Description |
| string | Prometheus view ID. Required. |
prometheus view list — List Prometheus Views
List Prometheus views with various filter conditions and pagination.
Run the following command:
# List all views in a workspace
aliyun cms2 prometheus view list --workspace default-cms-12345-cn-hangzhou
# Filter by name (fuzzy match)
aliyun cms2 prometheus view list --prometheus-view-name global
# Filter by region and version
aliyun cms2 prometheus view list --filter-region-ids cn-hangzhou --version V2
# Filter by view IDs
aliyun cms2 prometheus view list --prometheus-ids pv-001,pv-002
# Filter by tag
aliyun cms2 prometheus view list --tag '[{"key":"team","value":"sre"}]'
# Paginate results
aliyun cms2 prometheus view list --workspace my-ws --max-results 10 --next-token "eyJ..."
# Text (CSV) output
aliyun cms2 prometheus view list --workspace my-ws -o textParameter | Type | Description |
| string | Filter by region IDs. Separate multiple IDs with commas (,). |
| int32 | Maximum number of entries to return. |
| string | Pagination token. |
| string | Filter by view IDs. Separate multiple IDs with commas (,). |
| string | Filter by view name (fuzzy match). |
| string | Resource group ID. |
| string | Resource type. |
| string | Filter by tag. Value must be a JSON array with lowercase field names: |
| string | Instance version ( |
| string | Workspace name. |
The list command returns a single page of results and does not automatically paginate.