

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 使用 Amazon 监控 EMR HBase CloudWatch
<a name="emr-hbase-cw"></a>

从 EMR 7.0 开始，亚马逊 EMR 提供 CloudWatch 亚马逊代理，用于向 Prometheus 发送指标，取代 G CloudWatch anglia 监控系统。您可以在《[Amazon CloudWatch 代理配置指南](https://docs.aws.amazon.com/emr/latest/ReleaseGuide/AmazonCloudWatchAgent-config-700.html)》中找到更多详细信息。

EMR 7.0 A CloudWatch mazon 代理提供了基本集成，设置需要手动操作，例如下载组件和使用引导操作。但是从 EMR 7.1 开始，该过程得到了简化。在 EMR 7.1 中使用 Amazon A CloudWatch gent 可以轻松监控系统级指标和应用程序特定指标，包括的指标。 HBase通过使用 EMR 配置 API，您可以快速设置和自定义指标收集流程，并选择将数据发送到哪里，可以发送到亚马逊 CloudWatch 或 Prometheus。这种灵活性可以帮助您密切关注 HBase 集群，确保它们平稳高效地运行。

使用 EMR 配置 API 处理整个设置，使过程更加顺畅。EMR 7.1 中的 CloudWatch 代理支持三种主要的指标类型：
+ **系统指标**：这些指标包括系统性能的关键指标，例如：CPU 使用率、磁盘使用率、内存使用量、网络 I/O、进程和交换区使用情况。
+ **Hadoop 守护程序指标** — 这些指标与 Hadoop 的各个组成部分有关，包括： DataNode 指标、指标、YARN 指标和 NameNode YARN NodeManager 指标。 ResourceManager 
+ **HBase 指标** — 这些指标提供了 HBase对性能的见解： HBase 主指标、 HBase 区域服务器指标、 HBase REST Server 指标和 HBase Thrift Server 指标。

------
#### [ Using the AWS CLI ]

Hadoop 和 HBase 的所有指标都基于 JMX，这意味着它们使用 Java 管理扩展来提供详细的见解。您可以通过以下方式设置 Amazon A CloudWatch gent 进行监控 HBase：
+ 在使用 Amazon A CloudWatch gent 创建集群之前，请参阅[先决条件](https://docs.aws.amazon.com/emr/latest/ReleaseGuide/AmazonCloudWatchAgent-create.html)。使用类似于此列表后面的示例的 `create-cluster` 命令。
+ 请参阅集 HBase 群支持的[配置](https://docs.aws.amazon.com/emr/latest/ReleaseGuide/AmazonCloudWatchAgent-config.html)。
+ 有关设置 HBase 监控的配置示例，请参阅以下示例。有关 `--configuration` 输入，请参阅配置示例。

```
aws emr create-cluster --name "HBase cluster with CloudWatch agent" \
--release-label emr-7.1.0 \
--applications Name=HBase Name=AmazonCloudWatchAgent \
--ec2-attributes KeyName=myKey --instance-type m7g.2xlarge \
--configurations file://./configurations.json \  
--instance-count 3 --use-default-roles
```

有关指标的 JSON 示例配置的更多信息，请参阅[设置指标](https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-hbase-setting-up-metrics.html)。

------
#### [ Using the console ]

要通过控制台使用 Amazon CloudWatch 代理创建集群，请执行以下步骤：

**通过控制台使用 CloudWatch 代理创建集群**

1. [登录 AWS 管理控制台，然后在 /emr 上打开亚马逊 EMR 控制台。https://console.aws.amazon.com](https://console.aws.amazon.com/emr)

1. 选择**创建集群**。

1. 在**名称和应用程序**下，选择 7.0.0 或更高版本的 Amazon EMR 发行版。

1. 在 “**应用程序捆绑包**” 下 HBase ，选择要安装到集群的其他应用程序，并在您的选择中加入 CloudWatch 代理。

1. 展开**软件设置**。然后，您可以在控制台中使用 JSON 或以阴影文本表示的简写语法直接输入配置。否则，您可以为具有 JSON `Configurations` 对象的文件提供一个 Amazon S3 URI。有关指标的 JSON 示例配置的更多信息，请参阅[设置指标](https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-hbase-setting-up-metrics.html)。

1. 继续创建集群以满足您的应用场景需求。



------

# 设置指标
<a name="emr-hbase-setting-up-metrics"></a>

要监控 HBase 主数据，您可以将 Amazon A CloudWatch gent 设置为收集特定指标。

1. **设置 HBase 主指标**-要监控 HBase 主指标，您可以将 Amazon A CloudWatch gent 设置为收集特定指标。以下是一个用于跟踪 Master 分配管理器活动的配置示例：

   ```
   [
     {
       "Classification": "emr-metrics",
       "Properties": {},
       "Configurations": [
         {
           "Classification": "emr-hbase-master-metrics",
           "Properties": {
             "Hadoop:service=HBase,name=Master,sub=AssignmentManager": "AssignFailedCount,AssignSubmittedCount",
             "otel.metric.export.interval": "30000"
           },
           "Configurations": []
         }
       ]
     }
   ]
   ```

   在此设置中：
   + 我们指定 MBean (`Hadoop:service=HBase,name=Master,sub=AssignmentManager`) 来收集诸如`AssignFailedCount`和之类的指标`AssignSubmittedCount`。
   + 我们将间隔设置为每 30 秒（30000 毫秒）收集一次这些指标。

1. **设置 HBase 区域服务器指标**-要监控 HBase 区域服务器，请按以下方式配置 CloudWatch 代理：

   ```
   [
     {
       "Classification": "emr-metrics",
       "Properties": {},
       "Configurations": [
         {
           "Classification": "emr-hbase-region-server-metrics",
           "Properties": {
             "Hadoop:service=HBase,name=RegionServer,sub=IPC": "numActiveHandler,numActivePriorityHandler",
             "otel.metric.export.interval": "30000"
           },
           "Configurations": []
         }
       ]
     }
   ]
   ```

   此配置：
   + 监视 Region Server 上的活跃处理程序（`numActiveHandler`、`numActivePriorityHandler`）。
   + 使用 30 秒的间隔进行指标收集。

1. **设置 HBase REST 服务器指标**-要监控 HBase REST 接口，您可以使用以下配置：

   ```
   [
     {
       "Classification": "emr-metrics",
       "Properties": {},
       "Configurations": [
         {
           "Classification": "emr-hbase-rest-server-metrics",
           "Properties": {
             "Hadoop:service=HBase,name=REST": "successfulPut,successfulScanCount",
             "otel.metric.export.interval": "30000"
           },
           "Configurations": []
         }
       ]
     }
   ]
   ```

   在此示例中， CloudWatch 代理每 30 秒收集有关成功 PUT 操作和扫描计数的指标。

1. **设置 HBase Thrift Server 指标** — 要监控 HBase Thrift Server，您可以使用如下配置来配置指标：

   ```
   [
     {
       "Classification": "emr-metrics",
       "Properties": {},
       "Configurations": [
         {
           "Classification": "emr-hbase-thrift-server-metrics",
           "Properties": {
             "Hadoop:service=HBase,name=Thrift,sub=ThriftOne": "BatchGet_max,BatchGet_mean",
             "otel.metric.export.interval": "30000"
           },
           "Configurations": []
         }
       ]
     }
   ]
   ```

   此设置跟踪 Thrift 服务器上批量 GET 操作的最大时间和平均时间。

# 使用指标目标
<a name="emr-hbase-using-metrics"></a>

在 EMR 7.1 中，您可以选择将指标数据发送到亚马逊或 CloudWatch 亚马逊 Prometheus 托管服务。此选择允许您根据需要与不同的监控工具无缝集成。

## 向 Amazon 发送指标 CloudWatch
<a name="emr-hbase-using-metrics-cw"></a>

要将指标发送到 CloudWatch，请使用以下配置：

```
[
  {
    "Classification": "emr-metrics",
    "Properties": {
      "metrics_destination": "cloudwatch"
    },
    "Configurations": []
  }
]
```

## 将指标发送到 Amazon Managed Service for Prometheus
<a name="emr-hbase-using-metrics-prom"></a>

如果您更喜欢使用 Prometheus，请设置目标并提供端点 URL：

```
[
  {
    "Classification": "emr-metrics",
    "Properties": {
      "metrics_destination": "prometheus",
      "prometheus_endpoint": "https://aps-workspaces.region.amazonaws.com/workspaces/workspace_id/api/v1/remote_write"
    },
    "Configurations": []
  }
]
```

`region`替换为你所在的 AWS 地区和`workspace_id`你的 Prometheus 工作空间 ID。此配置使用指定的端点将您的 HBase 指标定向到 Prometheus。

通过上述设置，您可以在**监控**选项卡下查看以下指标。