Manage Prometheus views

Updated at:

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.

Note
  • View-related commands are under the prometheus view command group (for example, aliyun cms2 prometheus view list).

  • The --prometheus-id parameter accepts both instance IDs and view IDs. You can also use a view ID directly with the --prometheus-id parameter of the metric promql command.

Prerequisites

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

Parameter

Type

Description

--body

string

Request body in inline JSON or @file.json format. Required.

--show-example-body

bool

Print an example request body and exit.

--show-schema

bool

Print the JSON schema of the request body and exit.

Note

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 json

Parameter

Type

Description

--prometheus-id

string

Prometheus view ID. Required.

--aliyun-lang

string

Language setting (zh | en).

--resource-group-id

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

--prometheus-id

string

Prometheus view ID. Required.

--body

string

Request body in inline JSON or @file.json format. Required.

--show-example-body

bool

Print an example request body and exit.

--show-schema

bool

Print the JSON schema of the request body and exit.

Note

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.

Note

Deleting a view does not affect the underlying associated Prometheus instances.

Run the following command:

aliyun cms2 prometheus view delete --prometheus-id pv-abc123def456

Parameter

Type

Description

--prometheus-id

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 text

Parameter

Type

Description

--filter-region-ids

string

Filter by region IDs. Separate multiple IDs with commas (,).

--max-results

int32

Maximum number of entries to return.

--next-token

string

Pagination token.

--prometheus-ids

string

Filter by view IDs. Separate multiple IDs with commas (,).

--prometheus-view-name

string

Filter by view name (fuzzy match).

--resource-group-id

string

Resource group ID.

--resource-type

string

Resource type.

--tag

string

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

--version

string

Instance version (V1 | V2).

--workspace

string

Workspace name.

Note

The list command returns a single page of results and does not automatically paginate.