全部产品
Search
文档中心

应用实时监控服务ARMS:CreateEnvServiceMonitor - 创建环境的ServiceMonitor

更新时间:Aug 28, 2026

创建环境的ServiceMonitor。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

调试

授权信息

当前API暂无授权信息透出。

请求参数

名称

类型

必填

描述

示例值

RegionId

string

是

地域 ID。

cn-hangzhou

AliyunLang

string

否

语言环境:

  • zh(默认):中文

  • en:英文

枚举值:

  • en :

    en

  • zh :

    zh

zh

EnvironmentId

string

是

环境实例 ID。

env-xxxxxx

DryRun

boolean

否

试运行。检查格式是否合法、是否能匹配到 targets。

true

ConfigYaml

string

是

ServiceMonitor 的 YAML 配置串。

参见补充说明。

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

其中 arms.prometheus.io/discovery 必须存在,其值为“true”,表示 serviceMonitor 启用,否则表示停止。

返回参数

名称

类型

描述

示例值

object

Schema of Response

RequestId

string

Id of the request

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

Code

integer

状态码。200 表示成功。

200

Data

object

返回结构体。

MatchedMsg

string

Target 匹配提示信息。

匹配成功。

Namespace

string

命名空间。

arms-prom

ServiceMonitorName

string

成功创建的 ServiceMonitor 名称。

arms-admin1

MatchedTargetCount

integer

匹配出的 target 数量。

1

Message

string

返回结果的提示信息。

message

示例

正常返回示例

JSON格式

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

错误码

访问错误中心查看更多错误码。

变更历史

更多信息,参考变更详情。