How to monitor disk space on EC2

wget https://s3.amazonaws.com/amazoncloudwatch-agent/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm
sudo rpm -U amazon-cloudwatch-agent.rpm
DEB: sudo dpkg -i -E ./amazon-cloudwatch-agent.debWindows: msiexec /i amazon-cloudwatch-agent.msi
sudo vi /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json
{
"agent": {
"metrics_collection_interval": 60,
"run_as_user": "cwagent"
},
"metrics": {
"append_dimensions": {
"InstanceId": "${aws:InstanceId}"
},
"metrics_collected": {
"disk": {
"measurement": [
"used_percent"
],
"metrics_collection_interval": 60,
"resources": [
"/"
]
}
}
}
}
sudo systemctl restart amazon-cloudwatch-agent
  1. Login to the AWS console
  2. Navigate to CloudWatch and click on Create alarm
  3. Select metric
  4. Under custom namespaces you should see CWAgent
  5. Select the metric to monitor
  6. The list of instance ids which are being monitored by the agent will be shown, select the instances you want to monitor
  7. Set the threshold for which you want to alert on, for example setting to 80% will alert when there is only 20% of disk space left
  8. Setup the notification so that you get notified once the threshold is hit. This is done by creating a new SNS topic, provide a list of emails who should receive the alert.
  9. The last step is to name the alarm
  10. We now have a CW alarm in place to monitor disk usage on the selected instances 🎉

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How To Become Software Engineer in 2022

How Managed Print Services Can Benefit Your Business

The Role of a Business Analyst in Software Development

SRE Engagment Playbook — Month 5

For Unstoppable Taste for Haste: Scan the QR Code to Use Services!

5 things that developers do all the time, in Scala

Axie Infinity — Breaking the market with bots

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kieran Robinson

Kieran Robinson

More from Medium

AWS Config — Remediation and Notification for S3

AWS VPC Gateway Endpoints and NACLs

Evolving to Production Readiness

How to automatically generate fine-grained AWS IAM policy