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

如何在Google Container Linux上安装Ops Agent以实现磁盘告警

在Google Container Linux上部署Ops Agent以实现磁盘使用率告警

1. 安装Cloud Ops Agent

Container Linux采用容器化方式运行Ops Agent,执行以下命令完成安装与配置:

# 创建配置目录
sudo mkdir -p /var/lib/google-cloud-ops-agent/config.d

# 写入磁盘监控配置(指定需监控的文件系统)
sudo tee /var/lib/google-cloud-ops-agent/config.d/disk.yaml <<EOF
metrics:
  receivers:
    disk:
      type: disk
      metrics:
        - name: filesystem/bytes_used
          enabled: true
        - name: filesystem/bytes_total
          enabled: true
        - name: filesystem/usage
          enabled: true
  service:
    pipelines:
      default_pipeline:
        receivers: [disk]
EOF

# 启动Ops Agent容器(设置开机自启)
sudo podman run -d \
  --name google-cloud-ops-agent \
  --pull always \
  --restart always \
  --volume /var/lib/google-cloud-ops-agent/config.d:/etc/google-cloud-ops-agent/config.d:ro \
  --volume /var/run:/var/run:ro \
  --volume /sys:/sys:ro \
  --volume /dev/disk/:/dev/disk:ro \
  --privileged \
  gcr.io/cloud-ops-agent/cloud-ops-agent:latest

2. 验证指标可用性

安装完成后等待5-10分钟,在Google Cloud监控控制台验证指标:

  • 进入监控 > 指标资源管理器
  • 筛选指标:GCE Instance > filesystem > filesystem/bytes_used
  • 选择目标Container Linux实例,确认存在连续的数据点

3. 创建磁盘使用率告警策略

指标正常上报后,配置告警规则:

  • 进入监控 > 告警 > 创建策略
  • 添加告警条件:
    1. 资源类型选择「GCE 实例」
    2. 关联指标filesystem/bytes_used与filesystem/bytes_total
    3. 计算使用率:(bytes_used / bytes_total) * 100,设置阈值(如90%)
    4. 配置评估周期(如每5分钟检查一次,连续3次触发则告警)
  • 绑定通知渠道(邮件、企业IM等)
  • 保存并启用告警策略

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.18 08:40:31