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?

1 Antwort
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
EXPERTE
beantwortet vor 10 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen