【问题标题】:AWS CloudWatch Agent not startingAWS CloudWatch 代理未启动
【发布时间】:2019-12-01 03:42:28
【问题描述】:

我有一个 Ubuntu EC2 实例。我在以下位置手动创建了以下基本 CloudWatch 代理配置文件:

/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json

{
    "metrics": {
        "metrics_collected": {
            "collectd": {},
            "mem": {
                "measurement": [
                    "used_percent",
                    "total"
                ]
            },
            "disk": {
                "measurement": [
                    "used_percent",
                    "total"
                ]
            }
        }
    }
}

我正在尝试使用以下命令启动 CloudWatch 代理。

sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a start

然后我使用下面的命令检查状态以确认它正在运行。

sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a status

但我得到下面的输出,显示代理处于停止状态。

{
  "status": "stopped",
  "starttime": "",
  "version": "1.223987.0"
}

我检查了下面的日志文件。

/var/log/amazon/amazon-cloudwatch-agent

它包含:

2019/07/23 06:51:04 I! I! Detected the instance is EC2
2019/07/23 06:51:04 Reading json config file path: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json ...
Valid Json input schema.
I! Detecting runasuser...
No csm configuration found.
No log configuration found.
No structuredlog configuration found.
Configuration validation first phase succeeded

2019/07/23 06:51:04 I! Config has been translated into TOML /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.toml
2019/07/23 06:51:04 Reading json config file path: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json ...
2019/07/23 06:51:04 I! Detected runAsUser: root

我需要做什么才能让 CloudWatch 代理运行?

【问题讨论】:

    标签: amazon-web-services service amazon-cloudwatch


    【解决方案1】:

    CentOS

    yum update && yum install epel-release && yum install collectd
    

    对于 Ubuntu

    sudo apt-get update && sudo apt-get install collectd 
    

    【讨论】:

    • apt-get 用于 Ubuntu,yum 用于 Centos。 :)
    • 我真的希望 OP 接受这个作为正确答案。在正确配置我的系统并集思广益数小时后,这是让他们立即登录的唯一解决方案!!!!非常感谢你的洞察力!也希望 AMZ 将其包含在他们的文档中!我在我能回忆的任何地方都没有提到 collectd 。如果它在那里并且我错了,有人可以分享文档的链接吗!? :D
    • 为什么这是一个公认的答案? collectd 与这些有什么关系?
    【解决方案2】:

    上述解决方案对我不起作用:

    yum update && yum install epel-release && yum install collectd
    

    但是,我使用了以下命令,并且安装了 epelcollectd 没有问题:

    EPEL:

    sudo amazon-linux-extras install epel -y
    

    收集:

    sudo amazon-linux-extras install collectd -y
    

    我的 Linux 发行版: Amazon Linux 2(运行 Tomcat 8.5 Corretto 8 的 Elastic Beanstalk 64 位 Amazon Linux 2)

    【讨论】:

      【解决方案3】:

      须藤百胜更新 sudo amazon-linux-extras 安装 epel sudo yum install collectd

      为我工作

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-09-25
        • 1970-01-01
        • 2020-01-27
        • 2016-11-22
        • 2020-02-27
        • 2016-12-25
        • 1970-01-01
        • 2011-01-28
        相关资源
        最近更新 更多