配置 IBM Cloud® Object Storage 的度量值
使用 IBM Cloud® Monitoring 服务可监视 IBM Cloud® Object Storage 数据。 IBM Cloud Monitoring 是一个云本机管理系统。 COS 存储区生成的度量可以显示在 IBM Monitoring 中内置的仪表板中。 来自 监视 的文档可指导您如何使用综合仪表板。 此外,指定触发度量警报时的条件 以在超过定制阈值时设置通知。
在存储区上启用度量值监视时,捕获这些度量值的缺省目标服务是 IBM Cloud Monitoring。 确保在接收位置具有与 COS 服务集成中指定的存储区位置对应的 IBM Cloud Monitoring 平台实例。
或者,使用 IBM Cloud 度量值路由 规则将度量值发送到其他目标服务或存储区位置以外的位置中的 IBM Cloud Monitoring 实例。
通过 IBM Cloud® Object Storage 资源配置 API 或通过 UI 直接在存储区上启用度量值监视。 这是在存储区供应期间或之后通过更新存储区配置完成的。
IBM COS 支持对以下度量值类型启用度量值跟踪:
- 使用情况度量值-这些度量值与 COS 存储区的总体使用情况相关,例如使用的总存储量 (以字节为单位)。
- 请求度量值-度量值报告对存储区发出的特定类型 API 请求的计数
请参阅下面的 IBM Cloud® Object Storage 度量详细信息部分,以获取发送到 IBM Monitoring 的度量的完整列表。
此功能在 Satellite 的 Object Storage 中当前不受支持。
此功能部件支持 SCC 监视。
IBM Cloud® Object Storage 度量只能由 IBM Monitoring 平台实例使用。 如果最终接收位置不存在平台实例,请确保已创建一个平台实例。
通过 IBM Cloud 度量值路由度量值
使用 IBM Cloud® 度量值路由将 IBM Cloud® Object Storage 存储区的度量值路由到与存储区位置不同的位置或其他目标服务。 您可以使用“度量值路由”(平台服务) 来管理用于定义度量值数据路由位置的目标和路由。
在 IBM Cloud® Object Storage 存储区上启用监视时,会将度量值发送到 COS 服务集成 中定义的缺省接收位置。 您必须在此位置具有 IBM Monitoring 实例,或者使用 Monitoring 实例配置到其他位置的路由规则,以确保接收到度量值。
请参阅 IBM Cloud Metrics Routing 入门 以获取更多信息。
在 IBM Cloud® Object Storage 存储区上配置度量 (建议)
在存储区供应时或通过在创建存储区后更新存储区配置,对 IBM Cloud® Object Storage 存储区启用度量跟踪。 度量值监视仅适用于启用后生成的 IBM Cloud® Object Storage 度量值。
请参阅 IBM Cloud® Object Storage 度量详细信息,以查看可用于跟踪的使用情况和请求度量的完整列表。
使用 IBM Cloud® Object Storage 资源配置 API 来配置对存储区的这些度量的跟踪。
启用度量值跟踪后,将根据存储区的位置将所有度量值发送到 IBM Cloud 度量值路由器的缺省接收位置。 请参阅 IBM Cloud® Object Storage 服务集成 以查看此缺省映射。 使用“指标路由器”规则将指标路由到非存储区位置或其他目标服务。 请参阅 管理路由 以获取更多信息。
如何配置 IBM Cloud® Object Storage 的度量 (建议)
选择本主题顶部的 UI,API 或 Terraform 选项卡以显示示例,这些示例显示如何配置度量监视以跟踪存储区上的使用情况和请求度量。
有关如何在存储区上配置度量值监视的 UI 示例
- 从 IBM Cloud 控制台 资源列表 中,选择包含您希望添加度量值监视的存储区的服务实例。 这会将您转至 " Object Storage " 控制台
- 选择要对其启用监视的存储区。
- 浏览至配置选项卡。
- 向下滚动到高级配置部分,并切换要为此存储区监视的度量。
- 几分钟后,任何活动都将显示在 IBM Cloud Monitoring Web UI 中。
示例
Java SDK
import com.ibm.cloud.objectstorage.config.resource_configuration.v1.ResourceConfiguration;
import com.ibm.cloud.objectstorage.config.resource_configuration.v1.model.BucketPatch;
import com.ibm.cloud.sdk.core.security.IamAuthenticator;
public class MetricsMonitoringExample {
private static final String BUCKET_NAME = <BUCKET_NAME>;
private static final String API_KEY = <API_KEY>;
public static void main(String[] args) {
IamAuthenticator authenticator = new IamAuthenticator.Builder()
.apiKey(API_KEY)
.build();
ResourceConfiguration RC_CLIENT = new ResourceConfiguration("resource-configuration", authenticator);
MetricsMonitoring metricsMonitoringConfig = new MetricsMonitoring().Builder()
.requestMetricsEnabled(true)
.usageMetricsEnabled(true)
.build();
BucketPatch bucketPatch = new BucketPatch.Builder().metricsMonitoring(metricsMonitoringConfig).build();
UpdateBucketConfigOptions update = new UpdateBucketConfigOptions
.Builder(BUCKET_NAME)
.bucketPatch(bucketPatch.asPatch())
.build();
RC_CLIENT.updateBucketConfig(update).execute();
GetBucketConfigOptions bucketOptions = new GetBucketConfigOptions.Builder(BUCKET_NAME).build();
Bucket bucket = RC_CLIENT.getBucketConfig(bucketOptions).execute().getResult();
MetricsMonitoring metricsMonitoringResponse = bucket.getMetricsMonitoring();
System.out.println("Usage Metrics Enabled : " + metricsMonitoringResponse.usageMetricsEnabled());
System.out.println("Request Metrics Enabled : " + metricsMonitoringResponse.requestMetricsEnabled());
}
}
NodeJS SDK
const ResourceConfigurationV1 = require('ibm-cos-sdk-config/resource-configuration/v1');
IamAuthenticator = require('ibm-cos-sdk-config/auth');
var apiKey = "<API_KEY>"
var bucketName = "<BUCKET_NAME>"
authenticator = new IamAuthenticator({apikey: apiKey})
rcConfig = {authenticator: authenticator}
const client = new ResourceConfigurationV1(rcConfig);
function addMM() {
console.log('Updating bucket metadata...');
var params = {
bucket: bucketName,
metricsMonitoring: {
"request_metrics_enabled": true,
"usage_metrics_enabled": true
}
};
client.updateBucketConfig(params, function (err, response) {
if (err) {
console.log("ERROR: " + err);
} else {
console.log(response.result);
}
});
}
addMM()
Python SDK
from ibm_cos_sdk_config.resource_configuration_v1 import ResourceConfigurationV1
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
api_key = "<API_KEY>"
bucket_name = "<BUCKET_NAME>"
authenticator = IAMAuthenticator(apikey=api_key)
client = ResourceConfigurationV1(authenticator=authenticator)
metrics_monitoring_config = {'metrics_monitoring':
{
'request_metrics_enabled':True,
'usage_metrics_enabled':True
}
}
client.update_bucket_config(bucket_name, bucket_patch=metrics_monitoring_config
GO SDK
import (
"github.com/IBM/go-sdk-core/core"
rc "github.com/IBM/ibm-cos-sdk-go-config/v2/resourceconfigurationv1"
)
apiKey := "<ApiKey>"
bucketName := "<BucketName>"
authenticator := new(core.IamAuthenticator)
authenticator.ApiKey = apiKey
optionsRC := new(rc.ResourceConfigurationV1Options)
optionsRC.Authenticator = authenticator
rcClient, _ := rc.NewResourceConfigurationV1(optionsRC)
patchNameMap := make(map[string]interface{})
patchNameMap["metrics_monitoring"] = &rc.MetricsMonitoring{
RequestMetricsEnabled: core.BoolPtr(true),
UsageMetricsEnabled: core.BoolPtr(true)
}
updateBucketConfigOptions := &rc.UpdateBucketConfigOptions{
Bucket: core.StringPtr(bucketName),
BucketPatch: patchNameMap,
}
rcClient.UpdateBucketConfig(updateBucketConfigOptions)
示例
resource "ibm_resource_instance" "cos_instance" {
name = "cos-instance"
resource_group_id = data.ibm_resource_group.cos_group.id
service = "cloud-object-storage"
plan = "standard"
location = "global"
}
resource "ibm_cos_bucket" "metric_monitoring_bucket" {
bucket_name = “bucket_name”
resource_instance_id = ibm_resource_instance.cos_instance.id
region_location = “us-south”
storage_class = “standard”
metrics_monitoring {
usage_metrics_enabled = true
request_metrics_enabled = true
}
}
在 IBM Cloud® Object Storage 存储区 (旧版) 上配置度量值
通过在 IBM Cloud® Object Storage 资源配置 API 中指定 Monitoring 实例的目标 CRN,在 IBM Cloud® Object Storage 存储区上启用 IBM Metrics Monitoring。 指定 CRN 以定义 COS 度量的路径。
IBM Cloud Metrics Routing 是客户管理平台可观察性数据路由的标准化方法。 不推荐使用特定于服务的路由配置,例如 IBM Cloud® Object Storage。
建议客户除去这些使用 CRN 的 旧路由配置 (使其成为以下升级部分的链接),而改为使用 IBM Metrics Router 服务将度量值路由到其他位置。
IBM Cloud® Object Storage 将继续支持指定了不同于缺省位置的 CRN 的旧配置。
从 Legacy 升级到 COS 存储区上的推荐度量监视:
要使用资源配置 API 从旧配置进行升级,请除去目标度量监视实例 CRN。 现在,度量值将路由到缺省度量值路由器接收位置,如 COS 服务集成 中所述。 请在此位置供应“监视”实例,或者在升级之前定义路由规则,以确保度量值监视不会中断。
用于在 COS 存储区上从“旧”转换为“建议”事件跟踪配置的示例补丁
选择本主题顶部的 UI,API 或 Terraform 选项卡以查看补丁示例。
要在 COS 存储区上从“旧”转换为“建议”事件跟踪配置的 UI 示例补丁
用于在 IBM Cloud® Object Storage 存储区 (SDK,RC API,UI 和 Terraform) 上从“旧”转换为“建议度量值”监视配置的示例补丁
- 从 IBM Cloud 控制台资源列表中,选择包含要升级到建议度量值监视配置的存储区的服务实例。 这会将您转至 " Object Storage " 控制台。
- 选择要升级的存储区。
- 浏览至配置选项卡。
- 向下滚动到高级配置部分,并找到用于度量监视的配置面板。
- 单击面板右上角,然后选择“升级”。
- 确认要升级此存储区的度量值监视。
示例
Java SDK
import com.ibm.cloud.objectstorage.config.resource_configuration.v1.ResourceConfiguration;
import com.ibm.cloud.objectstorage.config.resource_configuration.v1.model.BucketPatch;
import com.ibm.cloud.sdk.core.security.IamAuthenticator;
public class MetricsMonitoringExample {
private static final String BUCKET_NAME = <BUCKET_NAME>;
private static final String API_KEY = <API_KEY>;
public static void main(String[] args) {
IamAuthenticator authenticator = new IamAuthenticator.Builder()
.apiKey(API_KEY)
.build();
ResourceConfiguration RC_CLIENT = new ResourceConfiguration("resource-configuration", authenticator);
MetricsMonitoring metricsMonitoringConfig = new MetricsMonitoring().Builder()
.metricsMonitoringCrn(MM_CRN)
.requestMetricsEnabled(true)
.usageMetricsEnabled(true)
.build();
BucketPatch bucketPatch = new BucketPatch.Builder().metricsMonitoring(metricsMonitoringConfig).build();
UpdateBucketConfigOptions update = new UpdateBucketConfigOptions
.Builder(BUCKET_NAME)
.bucketPatch(bucketPatch.asPatch())
.build();
RC_CLIENT.updateBucketConfig(update).execute();
GetBucketConfigOptions bucketOptions = new GetBucketConfigOptions.Builder(BUCKET_NAME).build();
Bucket bucket = RC_CLIENT.getBucketConfig(bucketOptions).execute().getResult();
MetricsMonitoring metricsMonitoringResponse = bucket.getMetricsMonitoring();
System.out.println("Usage Metrics Enabled : " + metricsMonitoringResponse.usageMetricsEnabled());
System.out.println("Request Metrics Enabled : " + metricsMonitoringResponse.requestMetricsEnabled());
}
}
NodeJS SDK
const ResourceConfigurationV1 = require('ibm-cos-sdk-config/resource-configuration/v1');
IamAuthenticator = require('ibm-cos-sdk-config/auth');
var apiKey = "<API_KEY>"
var bucketName = "<BUCKET_NAME>"
authenticator = new IamAuthenticator({apikey: apiKey})
rcConfig = {authenticator: authenticator}
const client = new ResourceConfigurationV1(rcConfig);
function addMM() {
console.log('Updating bucket metadata...');
var params = {
bucket: bucketName,
metricsMonitoring: {
"metrics_monitoring_crn": metricsCrn,
"request_metrics_enabled": true,
"usage_metrics_enabled": true
}
};
client.updateBucketConfig(params, function (err, response) {
if (err) {
console.log("ERROR: " + err);
} else {
console.log(response.result);
}
});
}
addMM()
Python SDK
from ibm_cos_sdk_config.resource_configuration_v1 import ResourceConfigurationV1
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
api_key = "<API_KEY>"
bucket_name = "<BUCKET_NAME>"
authenticator = IAMAuthenticator(apikey=api_key)
client = ResourceConfigurationV1(authenticator=authenticator)
metrics_monitoring_config = {'metrics_monitoring':
{
'metrics_monitoring_crn': mm_crn,
'request_metrics_enabled':True,
'usage_metrics_enabled':True
}
}
client.update_bucket_config(bucket_name, bucket_patch=metrics_monitoring_config
GO SDK
import (
"github.com/IBM/go-sdk-core/core"
rc "github.com/IBM/ibm-cos-sdk-go-config/v2/resourceconfigurationv1"
)
apiKey := "<ApiKey>"
bucketName := "<BucketName>"
authenticator := new(core.IamAuthenticator)
authenticator.ApiKey = apiKey
optionsRC := new(rc.ResourceConfigurationV1Options)
optionsRC.Authenticator = authenticator
rcClient, _ := rc.NewResourceConfigurationV1(optionsRC)
patchNameMap["metrics_monitoring"] = &rc.MetricsMonitoring{
MetricsMonitoringCrn: core.StringPtr(MMCrn),
RequestMetricsEnabled: core.BoolPtr(true),
UsageMetricsEnabled: core.BoolPtr(true)
}
updateBucketConfigOptions := &rc.UpdateBucketConfigOptions{
Bucket: core.StringPtr(bucketName),
BucketPatch: patchNameMap,
}
rcClient.UpdateBucketConfig(updateBucketConfigOptions)
示例
resource "ibm_resource_instance" "cos_instance" {
name = "cos-instance"
resource_group_id = data.ibm_resource_group.cos_group.id
service = "cloud-object-storage"
plan = "standard"
location = "global"
}
resource "ibm_cos_bucket" "metric_monitoring_bucket" {
bucket_name = “bucket_name”
resource_instance_id = ibm_resource_instance.cos_instance.id
region_location = “us-south”
storage_class = “standard”
metrics_monitoring {
usage_metrics_enabled = true
request_metrics_enabled = true
metrics_monitoring_crn = "crn:v1:bluemix:public:sysdig-monitor:us-east:a/xxxxxxxxxxxxxxxxxxxxxxxxx:4xxxxxxxx-xxxx-xxxx-xxxx-fxxxxxxxxx4c::"
}
}
Cloud Object Storage 度量详细信息
使用情况度量
有一组基本度量用于跟踪使用情况:
ibm_cos_bucket_used_bytes
ibm_cos_bucket_object_count
ibm_cos_bucket_hard_quota_bytes
请求度量值 (request metrics)
有一些度量值用于报告不同 HTTP 请求类的聚集:
ibm_cos_bucket_all_requests
ibm_cos_bucket_get_requests
ibm_cos_bucket_put_requests
ibm_cos_bucket_delete_requests
ibm_cos_bucket_post_requests
ibm_cos_bucket_list_requests
ibm_cos_bucket_head_requests
还会收集错误,并对服务器端 (5xx) 错误进行细分:
ibm_cos_bucket_4xx_errors
ibm_cos_bucket_5xx_errors
报告按网络类型传输的最小字节数,最大字节数和平均字节数:
ibm_cos_bucket_bytes_download_public_min
ibm_cos_bucket_bytes_download_public_max
ibm_cos_bucket_bytes_download_public_avg
ibm_cos_bucket_bytes_download_private_min
ibm_cos_bucket_bytes_download_private_max
ibm_cos_bucket_bytes_download_private_avg
ibm_cos_bucket_bytes_download_direct_min
ibm_cos_bucket_bytes_download_direct_max
ibm_cos_bucket_bytes_download_direct_avg
ibm_cos_bucket_bytes_upload_public_min
ibm_cos_bucket_bytes_upload_public_max
ibm_cos_bucket_bytes_upload_public_avg
ibm_cos_bucket_bytes_upload_private_min
ibm_cos_bucket_bytes_upload_private_max
ibm_cos_bucket_bytes_upload_private_avg
ibm_cos_bucket_bytes_upload_direct_min
ibm_cos_bucket_bytes_upload_direct_max
ibm_cos_bucket_bytes_upload_direct_avg
请求的等待时间指标 (第一个字节和常规) 按请求类型细分:
ibm_cos_bucket_first_byte_latency_read_min
ibm_cos_bucket_first_byte_latency_read_max
ibm_cos_bucket_first_byte_latency_read_avg
ibm_cos_bucket_first_byte_latency_write_min
ibm_cos_bucket_first_byte_latency_write_max
ibm_cos_bucket_first_byte_latency_write_avg
ibm_cos_bucket_first_byte_latency_misc_min
ibm_cos_bucket_first_byte_latency_misc_max
ibm_cos_bucket_first_byte_latency_misc_avg
ibm_cos_bucket_request_latency_read_min
ibm_cos_bucket_request_latency_read_max
ibm_cos_bucket_request_latency_read_avg
ibm_cos_bucket_request_latency_write_min
ibm_cos_bucket_request_latency_write_max
ibm_cos_bucket_request_latency_write_avg
ibm_cos_bucket_request_latency_misc_min
ibm_cos_bucket_request_latency_misc_max
ibm_cos_bucket_request_latency_misc_avg
所有度量都报告为 float64
个数字值:
分段的属性
您可以按属性过滤结果。 在本指南中,我们将查看一些常规示例以及特定于 IBM Cloud Object Storage的示例。
全局属性
以下属性可用于对上面列出的所有度量进行分段
属性 | 属性名称 | 属性描述 |
---|---|---|
Cloud Type |
ibm_ctype |
公用,专用或本地 |
Location |
ibm_location |
受监视资源的位置。 这可以是“跨区域”,“区域”或“单个站点”存储区。 |
Resource |
ibm_resource |
COS 存储区名称 |
Resource Type |
ibm_resource_type |
COS 存储区 |
Scope |
ibm_scope |
作用域是与此度量相关联的帐户。 |
Service name |
ibm_service_name |
cloud-object-storage |
其他属性
以下属性可用于对上面参考内容中所述的一个或多个属性分段。 请查看各个度量值以了解分段选项。
属性 | 属性名称 | 属性描述 |
---|---|---|
IBM COS Bucket storage class |
ibm_cos_bucket_storage_class |
存储区的存储类 |
Service instance |
ibm_service_instance |
服务实例段标识与度量相关联的实例的指南。 |