云服务器内容精选

  • 更多操作 您还可以根据需要执行以下操作,具体请参见表 相关操作。 表5 相关操作 操作 说明 改变指标排列顺序 在“指标量(最近10分钟)”或“占比”列后单击,可改变指标在列表中的排列顺序。为默认排序,为按大小正序排序(即数据大的显示在最后方),为按大小倒序排序(即数据小的显示在最后方)。 新增指标 单击“新增指标”,在指标列表中选择需要新增的指标,单击“确定”。 说明: 单次新增指标最多支持新增100个指标。 废弃指标 废弃一个指标:选择一个指标,单击操作列的。 废弃一个或多个指标:选中一个或多个指标前的复选框,在弹出框中选择“废弃”,可以废弃一个或多个指标。 说明: 单次废弃指标最多支持废弃100个指标。
  • 注意事项 目前仅default类型、CCE类型、云服务类型、ECS类型的Prometheus实例支持指标查看、新增和废弃功能。 default类型的Prometheus实例下,指标名以“aom_”、“apm_”开头以及资源类型为ICAgent的指标暂不支持废弃。 ECS类型的Prometheus实例仅支持展示和配置UniAgent插件采集的指标。 CCE类型的Prometheus实例仅支持废弃如下指标: 只有在CCE “插件市场” 页面或AOM “集成中心” 页面安装的3.9.0以上的云原生监控插件(kube-prometheus-stack)上报的指标可以被废弃,且只有kube-prometheus-stack处于“运行中”状态时,指标才能废弃成功。 查看kube-prometheus-stack插件状态的方法:登录CCE控制台,单击集群名称进入集群,在左侧导航栏中选择“插件中心”,在右侧找到“云原生监控插件”卡片,查看插件的状态。
  • 注意事项 只有在CCE “插件市场” 页面或AOM “集成中心” 页面安装3.9.0以上的云原生监控插件(kube-prometheus-stack),且kube-prometheus-stack处于“运行中”状态时,才能成功启用/停用采集规则。 查看kube-prometheus-stack插件状态的方法:登录CCE控制台,单击集群名称进入集群,在左侧导航栏中选择“插件中心”,在右侧找到“云原生监控插件”卡片,查看插件的状态。
  • 更多操作 CCE集群的指标管理配置完成后,您还可以执行表1中的操作。 表1 相关操作 操作 说明 查看指标管理 在列表中,可查看名称、标签、命名空间、配置方式等信息,并支持按集群名称、命名空间或配置方式筛选查看。 单击“操作”列的,在弹出的对话框中查看ServiceMonitor或PodMonitor采集规则详情。 启用/停用采集规则 在“指标管理”页面的“配置”页签下,单击列表中“启停状态”列的,可以启用/停用采集规则。表示采集规则处于停用状态,表示采集规则处于启用状态。 删除指标管理 单击“操作”列的。
  • 返回值 正常 200 异常 返回值 说明 400 Bad Request 请求错误。 401 Unauthorized 未提供认证信息,或认证信息错误。 403 Forbidden 请求页面被禁止访问。 408 Request Timeout 请求超出了服务器的等待时间。 429 Too Many Requests 当前请求过多。 500 Internal Server Error 请求未完成,服务异常。 503 Service Unavailable 系统暂时不可用,请求受限。
  • 响应消息 响应参数 表3 响应参数 名称 参数类型 说明 metrics Array of objects 指标对象列表。 详细参数请参见表4。 meta_data Object 查询结果元数据信息,包括分页信息等。 详细参数请参见表6。 表4 metrics字段数据结构说明 名称 参数类型 说明 namespace String 指标所属命名空间。 dimensions Array of objects 指标维度列表。 详细参数请参见表5。 metric_name String 指标名称,如cpu_util。 unit String 指标单位。 表5 dimensions字段数据结构说明 名称 参数类型 说明 name String 监控维度名称,例如弹性云服务器的维度为instance_id。各服务维度请参考支持监控的服务列表,可参考维度中key字段。 value String 维度取值,例如弹性云服务器的ID。 长度最短为1,最大为256。 表6 meta_data字段数据结构说明 名称 参数类型 说明 count Integer 当前返回结果条数。 marker String 下一个开始的标记,用于分页。 如本次查询10条数据,第十条为cpu_util,下次start配置为cpu_util可从该指标开始查询。 total Integer 指标总条数。 响应样例 { "metrics": [ { "namespace": "SYS.ECS", "dimensions": [ { "name": "instance_id", "value": "d9112af5-6913-4f3b-bd0a-3f96711e004d" } ], "metric_name": "cpu_util", "unit": "%" } ], "meta_data": { "count": 1, "marker": "SYS.ECS.cpu_util.instance_id:d9112af5-6913-4f3b-bd0a-3f96711e004d", "total": 7 } }
  • URI GET /V1.0/{project_id}/metrics 参数说明 表1 参数说明 名称 是否必选 说明 project_id 是 项目ID。 获取方式请参见获取项目ID。 表2 查询检索参数说明 名称 是否必选 参数类型 说明 namespace 否 String 查询服务的命名空间,各服务命名空间请参考支持监控的服务列表。 格式为service.item;service和item必须是字符串,必须以字母开头,只能包含0-9/a-z/A-Z/_,service.item总长度最短为3,最大为32。 metric_name 否 String 指标ID,例如弹性云服务器的监控指标CPU使用率,对应的metric_name为cpu_util。各服务监控指标请参考支持监控的服务列表。 字符格式必须以字母开头,只能包含0-9/a-z/A-Z/_-,字符长度最短为1,最大为96。 dim 否 String 监控维度,例如弹性云服务器的维度为instance_id。各服务维度请参考支持监控的服务列表。 目前最大支持3个维度,必须从0开始;维度格式为dim.{i}=key,value,key的最大长度32,value的最大长度为256。 单维度:dim.0=instance_id,6f3c6f91-4b24-4e1b-b7d1-a94ac1cb011d 多维度:dim.0=key,value&dim.1=key,value start 否 String 分页起始值,格式为:namespace.metric_name.key:value 例如:start=SYS.ECS.cpu_util.instance_id:d9112af5-6913-4f3b-bd0a-3f96711e004d limit 否 Integer 取值范围(0,1000],默认值为1000。 用于限制结果数据条数。 order 否 String 用于标识结果排序方法,按时间戳排序。 取值说明,默认为desc: asc,升序 desc,降序 请求样例 请求样例一:查询当前可监控所有指标列表。 GET https://{云监控的终端节点}/V1.0/{project_id}/metrics 请求样例二:查询弹性云服务器ID为6f3c6f91-4b24-4e1b-b7d1-a94ac1cb011d的监控指标CPU使用率,结果按时间戳降序保留10条数据。 GET https://{云监控的终端节点}/V1.0/{project_id}/metrics?namespace=SYS.ECS&metric_name=cpu_util&dim.0=instance_id,6f3c6f91-4b24-4e1b-b7d1-a94ac1cb011d&limit=10&order=desc
  • 响应参数 状态码: 200 表4 响应Body参数 参数 参数类型 描述 total Integer 总数 最小值:0 最大值:100 result Array of EventSubMetricsItem objects 指标数据列表 数组长度:0 - 100 表5 EventSubMetricsItem 参数 参数类型 描述 fail_num Long 失败数 retry_success_num Long 重试成功数 retry_fail_num Long 重试失败数 retry_times Integer 重试数 timestamp Long 时间戳 num Long 调用数 success_num Long 调用成功数 process_time Long 处理时间 invoke_time Long 调用时间 状态码: 400 表6 响应Body参数 参数 参数类型 描述 error_code String 错误码 最小长度:1 最大长度:128 error_msg String 错误消息 最小长度:1 最大长度:512 error_details String 具体错误消息 最小长度:1 最大长度:1024 request_id String 请求处理ID 最小长度:1 最大长度:128 状态码: 401 表7 响应Body参数 参数 参数类型 描述 error_code String 错误码 最小长度:1 最大长度:128 error_msg String 错误消息 最小长度:1 最大长度:512 error_details String 具体错误消息 最小长度:1 最大长度:1024 request_id String 请求处理ID 最小长度:1 最大长度:128 状态码: 403 表8 响应Body参数 参数 参数类型 描述 error_code String 错误码 最小长度:1 最大长度:128 error_msg String 错误消息 最小长度:1 最大长度:512 error_details String 具体错误消息 最小长度:1 最大长度:1024 request_id String 请求处理ID 最小长度:1 最大长度:128 状态码: 404 表9 响应Body参数 参数 参数类型 描述 error_code String 错误码 最小长度:1 最大长度:128 error_msg String 错误消息 最小长度:1 最大长度:512 error_details String 具体错误消息 最小长度:1 最大长度:1024 request_id String 请求处理ID 最小长度:1 最大长度:128 状态码: 500 表10 响应Body参数 参数 参数类型 描述 error_code String 错误码 最小长度:1 最大长度:128 error_msg String 错误消息 最小长度:1 最大长度:512 error_details String 具体错误消息 最小长度:1 最大长度:1024 request_id String 请求处理ID 最小长度:1 最大长度:128
  • URI GET /v1/{project_id}/metrics/sub 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 租户项目ID 表2 Query参数 参数 是否必选 参数类型 描述 filter 否 String 指标数据统计方式 缺省值:AVG 枚举值: AVG MIN MAX period 否 Integer 指标数据统计周期(单位minute) 缺省值:1 start_time 是 Long 获取指标数据起始时间 end_time 否 Long 获取指标数据结束时间 subscription_id 是 String 事件订阅id provider_type 否 String 事件目标类型/事件通道类型 枚举值: OFFICIAL CUSTOM target_id 否 String 事件目标id
  • 响应示例 状态码: 400 { "error_code" : "EG.00014000", "error_msg" : "Bad request" } 状态码: 401 { "error_code" : "EG.00014010", "error_msg" : "Incorrect token or token resolution failed" } 状态码: 403 { "error_code" : "EG.00014030", "error_msg" : "No permissions to request this method" } 状态码: 404 { "error_code" : "EG.00014040", "error_msg" : "Not request resource found" } 状态码: 500 { "error_code" : "EG.00015000", "error_msg" : "Internal Server Error" }
  • Go 更新一条指标,指标触发标志为否,值为ip。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" secmaster "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := secmaster.NewSecMasterClient( secmaster.SecMasterClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.UpdateIndicatorRequest{} sourceTypeDataSource:= int32(1) domainIdDataSource:= "ac7438b990ef4a37b741004eb45e8bf4" projectIdDataSource:= "5b8bb3c888db498f9eeaf1023f7ba597" regionIdDataSource:= "cn-xxx-7" dataSourceDataObject := &model.IndicatorDataObjectDetailDataSource{ SourceType: &sourceTypeDataSource, DomainId: &domainIdDataSource, ProjectId: &projectIdDataSource, RegionId: ®ionIdDataSource, } indicatorTypeIndicatorType:= "ipv6" idIndicatorType:= "ac794b2dfab9fe8c0676587301a636d3" categoryIndicatorType:= "ipv6" layoutIdIndicatorType:= "4e2d7f64-a66d-3236-a8c1-704636ced9a7" indicatorTypeDataObject := &model.IndicatorDataObjectDetailIndicatorType{ IndicatorType: &indicatorTypeIndicatorType, Id: &idIndicatorType, Category: &categoryIndicatorType, LayoutId: &layoutIdIndicatorType, } valueDataObject:= "ip" firstReportTimeDataObject:= "2023-07-04T16:47:01Z+0800" granularMarkingDataObject:= int32(1) projectIdDataObject:= "909494e3-558e-46b6-a9eb-07a8e18ca62f" statusDataObject:= "Open" workspaceIdDataObject:= "909494e3-558e-46b6-a9eb-07a8e18ca620" dataObjectbody := &model.IndicatorDataObjectDetail{ IndicatorType: indicatorTypeDataObject, Value: &valueDataObject, DataSource: dataSourceDataObject, FirstReportTime: &firstReportTimeDataObject, GranularMarking: &granularMarkingDataObject, ProjectId: &projectIdDataObject, Status: &statusDataObject, WorkspaceId: &workspaceIdDataObject, } request.Body = &model.UpdateIndicatorRequestBody{ DataObject: dataObjectbody, } response, err := client.UpdateIndicator(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • 请求示例 更新一条指标,指标触发标志为否,值为ip。 { "data_object" : { "indicator_type" : { "layout_id" : "4e2d7f64-a66d-3236-a8c1-704636ced9a7", "indicator_type" : "ipv6", "id" : "ac794b2dfab9fe8c0676587301a636d3", "category" : "ipv6" }, "value" : "ip", "data_source" : { "domain_id" : "ac7438b990ef4a37b741004eb45e8bf4", "project_id" : "5b8bb3c888db498f9eeaf1023f7ba597", "region_id" : "cn-xxx-7", "source_type" : 1 }, "workspace_id" : "909494e3-558e-46b6-a9eb-07a8e18ca620", "project_id" : "909494e3-558e-46b6-a9eb-07a8e18ca62f", "granular_marking" : 1, "first_report_time" : "2023-07-04T16:47:01Z+0800", "status" : "Open" } }
  • 响应示例 状态码: 200 请求成功响应信息 { "code" : "909494e3-558e-46b6-a9eb-07a8e18ca62f", "message" : "Error message", "data" : { "id" : "28f61af50fc9452aa0ed5ea25c3cc3d3", "name" : "指标名称", "data_object" : { "indicator_type" : { "layout_id" : "4e2d7f64-a66d-3236-a8c1-704636ced9a7", "indicator_type" : "ipv6", "id" : "ac794b2dfab9fe8c0676587301a636d3", "category" : "ipv6" }, "value" : "ip", "data_source" : { "domain_id" : "ac7438b990ef4a37b741004eb45e8bf4", "project_id" : "5b8bb3c888db498f9eeaf1023f7ba597", "region_id" : "cn-xxx-7", "source_type" : 1 }, "workspace_id" : "909494e3-558e-46b6-a9eb-07a8e18ca620", "project_id" : "909494e3-558e-46b6-a9eb-07a8e18ca62f", "granular_marking" : 1, "first_report_time" : "2023-07-04T16:47:01Z+0800", "status" : "Open" }, "workspace_id" : "909494e3-558e-46b6-a9eb-07a8e18ca620", "project_id" : "909494e3-558e-46b6-a9eb-07a8e18ca62f", "dataclass_ref" : { "id" : "28f61af50fc9452aa0ed5ea25c3cc3d3", "name" : "名称" }, "create_time" : "2021-01-30T23:00:00Z+0800", "update_time" : "2021-01-30T23:00:00Z+0800" } }
  • Python 更新一条指标,指标触发标志为否,值为ip。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 # coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdksecmaster.v2.region.secmaster_region import SecMasterRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdksecmaster.v2 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.getenv("CLOUD_SDK_AK") sk = os.getenv("CLOUD_SDK_SK") credentials = BasicCredentials(ak, sk) \ client = SecMasterClient.new_builder() \ .with_credentials(credentials) \ .with_region(SecMasterRegion.value_of("cn-north-4")) \ .build() try: request = UpdateIndicatorRequest() dataSourceDataObject = IndicatorDataObjectDetailDataSource( source_type=1, domain_id="ac7438b990ef4a37b741004eb45e8bf4", project_id="5b8bb3c888db498f9eeaf1023f7ba597", region_id="cn-xxx-7" ) indicatorTypeDataObject = IndicatorDataObjectDetailIndicatorType( indicator_type="ipv6", id="ac794b2dfab9fe8c0676587301a636d3", category="ipv6", layout_id="4e2d7f64-a66d-3236-a8c1-704636ced9a7" ) dataObjectbody = IndicatorDataObjectDetail( indicator_type=indicatorTypeDataObject, value="ip", data_source=dataSourceDataObject, first_report_time="2023-07-04T16:47:01Z+0800", granular_marking=1, project_id="909494e3-558e-46b6-a9eb-07a8e18ca62f", status="Open", workspace_id="909494e3-558e-46b6-a9eb-07a8e18ca620" ) request.body = UpdateIndicatorRequestBody( data_object=dataObjectbody ) response = client.update_indicator(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
  • Java 更新一条指标,指标触发标志为否,值为ip。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.secmaster.v2.region.SecMasterRegion; import com.huaweicloud.sdk.secmaster.v2.*; import com.huaweicloud.sdk.secmaster.v2.model.*; public class UpdateIndicatorSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); ICredential auth = new BasicCredentials() .withAk(ak) .withSk(sk); SecMasterClient client = SecMasterClient.newBuilder() .withCredential(auth) .withRegion(SecMasterRegion.valueOf("cn-north-4")) .build(); UpdateIndicatorRequest request = new UpdateIndicatorRequest(); UpdateIndicatorRequestBody body = new UpdateIndicatorRequestBody(); IndicatorDataObjectDetailDataSource dataSourceDataObject = new IndicatorDataObjectDetailDataSource(); dataSourceDataObject.withSourceType(1) .withDomainId("ac7438b990ef4a37b741004eb45e8bf4") .withProjectId("5b8bb3c888db498f9eeaf1023f7ba597") .withRegionId("cn-xxx-7"); IndicatorDataObjectDetailIndicatorType indicatorTypeDataObject = new IndicatorDataObjectDetailIndicatorType(); indicatorTypeDataObject.withIndicatorType("ipv6") .withId("ac794b2dfab9fe8c0676587301a636d3") .withCategory("ipv6") .withLayoutId("4e2d7f64-a66d-3236-a8c1-704636ced9a7"); IndicatorDataObjectDetail dataObjectbody = new IndicatorDataObjectDetail(); dataObjectbody.withIndicatorType(indicatorTypeDataObject) .withValue("ip") .withDataSource(dataSourceDataObject) .withFirstReportTime("2023-07-04T16:47:01Z+0800") .withGranularMarking(1) .withProjectId("909494e3-558e-46b6-a9eb-07a8e18ca62f") .withStatus("Open") .withWorkspaceId("909494e3-558e-46b6-a9eb-07a8e18ca620"); body.withDataObject(dataObjectbody); request.withBody(body); try { UpdateIndicatorResponse response = client.updateIndicator(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } }