You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过CloudWatch获取EC2实例多磁盘分区(C盘、D盘)指标?

如何通过CloudWatch Agent获取EC2实例多磁盘分区指标

操作步骤

1. 编辑CloudWatch Agent配置文件

根据EC2实例的操作系统,定位到对应配置文件路径:

  • Windows实例:C:\Program Files\Amazon\CloudWatchAgent\config.json
  • Linux实例:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json

打开配置文件,找到metrics节点下的disk配置块,修改为包含目标磁盘分区的监控规则。

Windows实例配置示例(监控C盘和D盘)

在disk的resources数组中指定具体磁盘路径:

{
  "metrics": {
    "namespace": "CWAgent",
    "metrics_collected": {
      "disk": {
        "measurement": [
          "disk_used_percent",
          "disk_free",
          "disk_used"
        ],
        "resources": [
          "C:\\",
          "D:\\"
        ],
        "metrics_collection_interval": 60
      }
    }
  }
}

Linux实例配置示例(监控根分区和/data分区)

在resources中指定分区挂载路径:

{
  "metrics": {
    "namespace": "CWAgent",
    "metrics_collected": {
      "disk": {
        "measurement": [
          "used_percent",
          "free",
          "used"
        ],
        "resources": [
          "/",
          "/data"
        ],
        "metrics_collection_interval": 60
      }
    }
  }
}

2. 重启CloudWatch Agent服务

保存配置文件后,重启服务使配置生效:

  • Windows实例:打开PowerShell执行
    Restart-Service AmazonCloudWatchAgent
    
  • Linux实例:执行
    sudo systemctl restart amazon-cloudwatch-agent
    

3. 验证指标上报状态

登录AWS CloudWatch控制台,进入Metrics页面:

  1. 左侧导航栏选择All metrics
  2. 找到Custom Namespaces下的CWAgent
  3. 选择维度InstanceId和path,即可查看各磁盘分区的disk_used_percent、disk_free等指标

内容的提问来源于stack exchange,提问作者Smeet Gohil

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 12:39:57