10

I have an Ubuntu EC2 instance. I manually created the following basic CloudWatch Agent config file in:

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

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

I'm trying to start the CloudWatch Agent using the command below.

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

Then I check the status using the command below to confirm that it's running.

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

But I get the output below that shows the Agent as being in a stopped status.

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

I checked the log file below.

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

It contains:

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

What do I need to do get the CloudWatch Agent running?

Stephen Walsh
  • 815
  • 4
  • 18
  • 34

3 Answers3

15

For CentOS

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

For Ubuntu

sudo apt-get update && sudo apt-get install collectd 
Sean
  • 166
  • 1
  • 2
  • 4
    apt-get for Ubuntu , yum for Centos . :) – Sean Aug 19 '19 at 18:18
  • 1
    I really wish the OP would accept this as the correct answer. After properly configuring my systems and brainstorming for hours, this was the only solution that got them logging immediately!!!! Thank you so much for this insight! Also wish that AMZ would include this in their documentation! I see no mention of collectd anywhere that I can recall. If its in there and I'm wrong, can someone please share the link to the docs!? :D – Michael J Sep 23 '19 at 01:05
  • Why is this an accepted answer? What does `collectd` have to do with any of this? – ficuscr Feb 07 '21 at 05:08
  • 2
    @ficuscr the `"collectd": {},` line in the question's config possibly means the cloudwatch agent goes looking for the ability to collect metrics via `collectd` ... but it needs to be installed as an extra. The `amazon-cloudwatch-agent-config-wizard` specifically warns about this. – dijksterhuis Jun 09 '22 at 18:04
4

The above solution didn't work for me:

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

However, I used the following command and the epel and collectd were installed without a problem:

EPEL:

sudo amazon-linux-extras install epel -y

Collected:

sudo amazon-linux-extras install collectd -y

My Linux Distribution: Amazon Linux 2( Elastic Beanstalk 64bit Amazon Linux 2 running Tomcat 8.5 Corretto 8)

pacman
  • 1,061
  • 1
  • 17
  • 36
ABoringAI
  • 89
  • 5
-1

sudo yum update sudo amazon-linux-extras install epel sudo yum install collectd

Worked for me

Vimal
  • 1