Viewing CPU and Memory metrics of a Bitnami AWS Lightsail instance in Cloudwatch

0

I have a Bitnami AWS Lightsail Wordpress instance, 2 GB RAM, 2 vCPUs, 60 GB SSD. I have followed the Bitnami instructions to integrate Cloudwatch. I can verify that all my logs are streaming into Cloudwatch. But I am interested in viewing the machine metrics such as memory usage and CPU.

How can I get these metrics into Cloudwatch?

asked 9 months ago391 views
1 Answer
0

Hello.

CPU usage can be checked from Lightsail without looking at CloudWatch.
https://lightsail.aws.amazon.com/ls/docs/en_us/articles/understanding-instance-health-metrics-in-amazon-lightsail

A CloudWatch agent configuration file must be created to output CPU usage and memory to CloudWatch.
Looking at the URL you provided, there seems to be a configuration file in "/opt/aws/amazon-cloudwatch-agent/bin/config.json", so edit this.
https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html
The following settings will output memory usage and CPU usage.

{
    "metrics": {
      "metrics_collected": {
        "cpu": {
          "measurement": [
            "cpu_usage_idle",
            "cpu_usage_iowait"
          ]
        },
        "mem": {
          "measurement": [
            "mem_used_percent"
          ]
        }
      }
    }
  }

After updating the file, restart CloudWatch Agent with the following command.

sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a stop
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json -s
profile picture
EXPERT
answered 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions