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

如何通过AWS CloudWatch Agent监控Windows PerfMon的MSMQ队列消息数?

解决AWS CloudWatch Agent监控Windows MSMQ队列消息数的问题

先确认PerfMon计数器的正确路径

先打开Windows性能监视器(PerfMon),找到对应的MSMQ计数器:

  • 要监控全局MSMQ总消息数:对象选MSMQ,计数器选Messages in Queue,无实例
  • 要监控单个队列的消息数:对象选MSMQ Queue,计数器选Messages in Queue,实例是具体队列名(或_Total)
    直接复制PerfMon里的完整计数器路径(比如\MSMQ\Messages in Queue),别自己拼写——你之前写的"messages in que"少了个字母,正确是"Messages in Queue",大小写和空格尽量和PerfMon里的一致,避免踩坑

实测有效的CloudWatch Agent配置

直接用counter_specs指定完整计数器路径的方式最稳,不容易踩格式坑,配置片段如下(放到config.json的metrics节点下):

{
  "metrics": {
    "namespace": "Custom/MSMQ",
    "metrics_collected": {
      "perfmon": {
        "counter_specs": [
          // 全局总消息数
          "\\MSMQ\\Messages in Queue",
          // 所有队列的消息数,自动按队列名生成维度
          "\\MSMQ Queue(*)\\Messages in Queue"
        ],
        "metrics_collection_interval": 60,
        "append_dimensions": {
          "InstanceId": "${aws:InstanceId}"
        }
      }
    }
  }
}

如果要用customizedObjectName方式,注意对象名必须和PerfMon里完全一致,比如监控单个队列的配置:

{
  "metrics": {
    "namespace": "Custom/MSMQ",
    "metrics_collected": {
      "perfmon": {
        "measurement": [
          {
            "name": "Messages in Queue",
            "rename": "MSMQ_QUEUE_MESSAGE_COUNT",
            "unit": "Count"
          }
        ],
        "customizedObjectName": "MSMQ Queue",
        "dimensions": [["QueueName"]],
        "metrics_collection_interval": 60,
        "append_dimensions": {
          "InstanceId": "${aws:InstanceId}"
        }
      }
    }
  }
}

排查步骤

  1. 先验证计数器本身能用:在PerfMon里添加目标计数器,确认能正常拿到数据,排除计数器本身的问题
  2. 查Agent日志找报错:去C:\ProgramData\Amazon\CloudWatchAgent\Logs\amazon-cloudwatch-agent.log看日志,如果有Failed to collect counter之类的报错,要么是路径写错了,要么是权限不够
  3. 检查Agent运行权限:默认CloudWatch Agent用LocalSystem账户运行,要是权限不够,换成管理员账户试试
  4. 重启Agent等数据:改完配置后重启Amazon CloudWatch Agent服务,等5-10分钟去CloudWatch控制台的Custom/MSMQ命名空间看有没有数据进来

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.18 21:05:05