All Products
Search
Document Center

Application Real-Time Monitoring Service:CreateEnvServiceMonitor

Last Updated:Aug 28, 2026

Creates a ServiceMonitor for an environment.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID.

cn-hangzhou

AliyunLang

string

No

The language. Valid values:

  • zh (default): Chinese

  • en: English

Valid values:

  • en :

    en

  • zh :

    zh

zh

EnvironmentId

string

Yes

The ID of the environment instance.

env-xxxxxx

DryRun

boolean

No

Whether to perform a dry run without executing the request. The system validates the format and checks whether targets are matched.

true

ConfigYaml

string

Yes

The YAML configuration file of the ServiceMonitor.

参见补充说明。

Sample ConfigYAML:

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: arms-admin1
  namespace: arms-prom
  annotations:
    arms.prometheus.io/discovery: 'true'
spec:
  endpoints:
  - interval: 30s
    port: operator
    path: /metrics
  - interval: 10s
    port: operator1
    path: /metrics
  namespaceSelector:
    any: true
  selector:
    matchLabels:
     app: arms-prometheus-ack-arms-prometheus

You must specify arms.prometheus.io/discovery and set it to true to enable the ServiceMonitor.

Response elements

Element

Type

Description

Example

object

Schema of Response

RequestId

string

The request ID.

78901766-3806-4E96-8E47-CFEF59E4****

Code

integer

The HTTP status code. 200 indicates success.

200

Data

object

The response data.

MatchedMsg

string

Whether targets are matched.

匹配成功。

Namespace

string

The namespace.

arms-prom

ServiceMonitorName

string

The name of the created ServiceMonitor.

arms-admin1

MatchedTargetCount

integer

The number of matched targets.

1

Message

string

The response message.

message

Examples

Success response

JSON format

{
  "RequestId": "78901766-3806-4E96-8E47-CFEF59E4****",
  "Code": 200,
  "Data": {
    "MatchedMsg": "匹配成功。",
    "Namespace": "arms-prom",
    "ServiceMonitorName": "arms-admin1",
    "MatchedTargetCount": 1
  },
  "Message": "message"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.