EnsureSharedPrometheusInstance - 获取或创建Workspace共享Prometheus实例

更新时间:
复制 MD 格式

获取或创建Workspace共享Prometheus实例

接口说明

按 Workspace 获取或创建共享 Prometheus 实例。实例不存在时创建,已存在时直接返回。当前只支持 shareScope=Workspace。同一 Workspace 在请求地域只对应一个共享实例,实例名由服务端生成。调用身份是用户。工作空间不存在时返回 404。

调试

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

调试

授权信息

下表是API对应的授权信息,可以在RAM权限策略语句的Action元素中使用,用来给RAM用户或RAM角色授予调用此API的权限。具体说明如下:

  • 操作:是指具体的权限点。

  • 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。

  • 资源类型:是指操作中支持授权的资源类型。具体说明如下:

    • 对于必选的资源类型,用前面加 * 表示。

    • 对于不支持资源级授权的操作,用全部资源表示。

  • 条件关键字:是指云产品自身定义的条件关键字。

  • 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。

操作

访问级别

资源类型

条件关键字

关联操作

cms:EnsureSharedPrometheusInstance

none

*PrometheusInstance

acs:cms:{#regionId}:{#accountId}:prometheusinstance/*

无 无

请求语法

POST /shared-prometheus-instances HTTP/1.1

请求参数

名称

类型

必填

描述

示例值

body

object

否

获取或创建共享 Prometheus 实例的请求参数。

shareScope

string

是

共享范围。当前仅支持 Workspace,表示该 Workspace 在请求地域的共享 Prometheus 实例。同一 Workspace 的 Region 共享使用同一实例,不另建。Policy、Environment 暂不支持。

枚举值:

  • Workspace

Workspace

workspace

string

是

工作空间名称。工作空间不存在时返回 404。

team-workspace

aliyunLang

string

否

返回信息的语言。zh 表示中文,en 表示英文。默认 zh。

zh

返回参数

名称

类型

描述

示例值

object

共享 Prometheus 实例详情,以及本次调用是否新创建了实例。

prometheusInstance

object

共享 Prometheus 实例详情,字段与 GetPrometheusInstance 的 prometheusInstance 一致。

accessType

string

实例访问权限。取值 readWrite、readOnly、httpReadOnly。

readWrite

archiveDuration

integer

存储到期后自动归档保存的天数。0 表示不归档,3650 表示永久保存。

0

authFreeReadPolicy

string

读免密地址允许访问的 IP 白名单策略。

127.0.0.1

authFreeWritePolicy

string

写免密地址允许访问的 IP 白名单策略。

127.0.0.1

authToken

string

实例的 AuthToken。

example-auth-token

createTime

string

实例创建时间,UTC+0,格式为 yyyy-MM-ddTHH:mmZ。

2026-11-11T06:00Z

enableAuthFreeRead

boolean

是否开启读免密。

false

enableAuthFreeWrite

boolean

是否开启写免密。

false

enableAuthToken

boolean

是否开启 AuthToken 认证。

false

extraInfo

object

扩展信息。仅控制台请求返回。

{"slsProject":"proj-cms-cn-hangzhou"}

string

扩展信息的值。

proj-cms-cn-hangzhou

httpApiInterUrl

string

Prometheus HTTP API 的公网地址。

https://cn-hangzhou.arms.aliyuncs.com/prometheus/rw-example/api/v1

httpApiIntraUrl

string

Prometheus HTTP API 的内网地址。

https://cn-hangzhou-intranet.arms.aliyuncs.com/prometheus/rw-example/api/v1

httpApiInternalUrl

string

Prometheus HTTP API 的内部地址。

http://prometheus.cn-hangzhou.aliyuncs.com/prometheus/rw-example/api/v1

instanceType

string

实例类型。共享实例为 remote-write,表示 Prometheus for Remote Write。

remote-write

paymentType

string

计费方式。POSTPAY 表示按指标上报量后付费,POSTPAY_GB 表示按指标写入量后付费。

POSTPAY_GB

product

string

实例归属的产品,取值为 arms 或 cms。

cms

prometheusInstanceId

string

Prometheus 实例 ID。

rw-8f3c1a2b4d5e6f70

prometheusInstanceName

string

Prometheus 实例名称。Workspace 共享实例由服务端生成为 RegionShare:{workspace}:{regionId}。

RegionShare:team-workspace:cn-hangzhou

pushGatewayInterUrl

string

Pushgateway 的公网地址。

https://cn-hangzhou.arms.aliyuncs.com/prometheus/rw-example/api/v1/pushgateway

pushGatewayIntraUrl

string

Pushgateway 的内网地址。

https://cn-hangzhou-intranet.arms.aliyuncs.com/prometheus/rw-example/api/v1/pushgateway

pushGatewayInternalUrl

string

Pushgateway 的内部地址。

http://prometheus.cn-hangzhou.aliyuncs.com/prometheus/rw-example/api/v1/pushgateway

regionId

string

实例所在地域 ID。

cn-hangzhou

remoteReadInterUrl

string

Remote Read 的公网地址。

https://cn-hangzhou.arms.aliyuncs.com/prometheus/rw-example/api/v1/read

remoteReadIntraUrl

string

Remote Read 的内网地址。

https://cn-hangzhou-intranet.arms.aliyuncs.com/prometheus/rw-example/api/v1/read

remoteReadInternalUrl

string

Remote Read 的内部地址。

http://prometheus.cn-hangzhou.aliyuncs.com/prometheus/rw-example/api/v1/read

remoteWriteInterUrl

string

Remote Write 的公网地址。

https://cn-hangzhou.arms.aliyuncs.com/prometheus/rw-example/api/v1/write

remoteWriteIntraUrl

string

Remote Write 的内网地址。

https://cn-hangzhou-intranet.arms.aliyuncs.com/prometheus/rw-example/api/v1/write

remoteWriteInternalUrl

string

Remote Write 的内部地址。

http://prometheus.cn-hangzhou.aliyuncs.com/prometheus/rw-example/api/v1/write

resourceGroupId

string

实例所属资源组 ID。

rg-acfmyexample

resourceType

string

资源类型,固定为 PrometheusInstance。

PrometheusInstance

status

string

后端数据存储状态,例如 Running。

Running

storageDuration

integer

指标存储时长,单位为天。

90

supportAuthTypes

array

实例支持的认证鉴权类型列表。

["BasicAuth"]

string

实例支持的一种认证鉴权类型。取值 BasicAuth、AuthFree、AuthToken。

枚举值:

  • BasicAuth
  • AuthFree
  • AuthToken

BasicAuth

tags

array<object>

实例标签。Workspace 共享实例包含系统标签 acs:cms:shareScope。

object

key

string

实例标签的键。

acs:cms:shareScope

value

string

实例标签的值。

region:cn-hangzhou:team-workspace

userId

string

实例所属阿里云账号 ID。

1234567890123456

version

string

实例版本,例如 V2。

V2

workspace

string

实例所属工作空间名称。

team-workspace

folderUrl

string

实例关联的可视化大盘地址。

https://g.console.aliyun.com/folders/example

grafanaInstanceId

string

绑定的托管 Grafana 实例 ID。

grafana-cn-hangzhou-example

grafanaInstanceName

string

绑定的托管 Grafana 实例名称。

shared-grafana

paymentTypeUpdateTime

string

实例计费方式最近一次修改时间,UTC+0,格式为 yyyy-MM-ddTHH:mmZ。

2026-11-11T06:00Z

storeConfig PrometheusInstanceStoreConfig

Prometheus 查询缓存和并行查询配置。

created

boolean

本次调用是否新创建了实例。找到已有实例时为 false。

false

requestId

string

请求 ID。

A1B2C3D4-E5F6-7890-ABCD-EF1234567890

示例

正常返回示例

JSON格式

{
  "prometheusInstance": {
    "accessType": "readWrite",
    "archiveDuration": 0,
    "authFreeReadPolicy": "127.0.0.1",
    "authFreeWritePolicy": "127.0.0.1",
    "authToken": "example-auth-token",
    "createTime": "2026-11-11T06:00Z",
    "enableAuthFreeRead": false,
    "enableAuthFreeWrite": false,
    "enableAuthToken": false,
    "extraInfo": {
      "key": "proj-cms-cn-hangzhou"
    },
    "httpApiInterUrl": "https://cn-hangzhou.arms.aliyuncs.com/prometheus/rw-example/api/v1",
    "httpApiIntraUrl": "https://cn-hangzhou-intranet.arms.aliyuncs.com/prometheus/rw-example/api/v1",
    "httpApiInternalUrl": "http://prometheus.cn-hangzhou.aliyuncs.com/prometheus/rw-example/api/v1",
    "instanceType": "remote-write",
    "paymentType": "POSTPAY_GB",
    "product": "cms",
    "prometheusInstanceId": "rw-8f3c1a2b4d5e6f70",
    "prometheusInstanceName": "RegionShare:team-workspace:cn-hangzhou",
    "pushGatewayInterUrl": "https://cn-hangzhou.arms.aliyuncs.com/prometheus/rw-example/api/v1/pushgateway",
    "pushGatewayIntraUrl": "https://cn-hangzhou-intranet.arms.aliyuncs.com/prometheus/rw-example/api/v1/pushgateway",
    "pushGatewayInternalUrl": "http://prometheus.cn-hangzhou.aliyuncs.com/prometheus/rw-example/api/v1/pushgateway",
    "regionId": "cn-hangzhou",
    "remoteReadInterUrl": "https://cn-hangzhou.arms.aliyuncs.com/prometheus/rw-example/api/v1/read",
    "remoteReadIntraUrl": "https://cn-hangzhou-intranet.arms.aliyuncs.com/prometheus/rw-example/api/v1/read",
    "remoteReadInternalUrl": "http://prometheus.cn-hangzhou.aliyuncs.com/prometheus/rw-example/api/v1/read",
    "remoteWriteInterUrl": "https://cn-hangzhou.arms.aliyuncs.com/prometheus/rw-example/api/v1/write",
    "remoteWriteIntraUrl": "https://cn-hangzhou-intranet.arms.aliyuncs.com/prometheus/rw-example/api/v1/write",
    "remoteWriteInternalUrl": "http://prometheus.cn-hangzhou.aliyuncs.com/prometheus/rw-example/api/v1/write",
    "resourceGroupId": "rg-acfmyexample",
    "resourceType": "PrometheusInstance",
    "status": "Running",
    "storageDuration": 90,
    "supportAuthTypes": [
      "BasicAuth"
    ],
    "tags": [
      {
        "key": "acs:cms:shareScope",
        "value": "region:cn-hangzhou:team-workspace"
      }
    ],
    "userId": "1234567890123456",
    "version": "V2",
    "workspace": "team-workspace",
    "folderUrl": "https://g.console.aliyun.com/folders/example",
    "grafanaInstanceId": "grafana-cn-hangzhou-example",
    "grafanaInstanceName": "shared-grafana",
    "paymentTypeUpdateTime": "2026-11-11T06:00Z",
    "storeConfig": {
      "queryCacheEnable": false,
      "parallelEnable": false,
      "parallelMode": "static",
      "parallelCountPerHost": 2,
      "totalParallelCount": 8
    }
  },
  "created": false,
  "requestId": "A1B2C3D4-E5F6-7890-ABCD-EF1234567890"
}

错误码

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

变更历史

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