Giter Site home page Giter Site logo

rdok / aws-ec2-autoscale-monitor-slack Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 442 KB

Auto scale EC2 capacity, based on CPU and memory metrics. Slack message upon auto-scaling. Monitor metrics through CloudWatch dashboard.

Makefile 100.00%
ec2-autoscaling slack-bot ec2-monitoring aws-ec2

aws-ec2-autoscale-monitor-slack's Introduction

Autoscale based on CPU and memory metrics. Monitor, slack.

  1. Monitor EC2 memory, disk, and CPU utilization using CloudWatch agent.
  2. Create dashboard with the metrics, and alert through slack when any alarm goes in alert status.
  3. Auto increase EC2 desired capacity, when CPU OR memory utilisation is greater than a threshold.
  4. Auto decrease EC2 desired capacity, when CPU AND memory utilisation is lower than a threshold.

dashboard
auto-scale
slack

Stress Test

sudo amazon-linux-extras install -y epel
sudo yum install -y stress htop

# CPU, and memory stress. t3.medium 2 CPU, 4GB memory
sudo stress --cpu 2 --vm-bytes $(awk '/MemAvailable/{printf "%d\n", $2 * 0.9;}' < /proc/meminfo)k --vm-keep -m 5

# Memory stress. t3.medium CPU, 4GB memory
sudo stress --vm-bytes $(awk '/MemAvailable/{printf "%d\n", $2 * 0.9;}' < /proc/meminfo)k --vm-keep -m 5
 
 # Disk utilization. 8GB disk
df -h
dd if=/dev/urandom of=2GB.bin bs=64M count=32 iflag=fullblock
dd if=/dev/urandom of=3GB.bin bs=64M count=48 iflag=fullblock
df -h

Debug

  • The subnets are public to keep the stack simple; the focus is to showcase memory, cpu utilization and the autoscaling.
  • Use the EC2 serial console to connect the instance.

The EC2 password is set to secret from the UserData. This is set ONLY for debugging purposes, so do we remove this command before using it on production.

Development

Sources

aws-ec2-autoscale-monitor-slack's People

Contributors

rdok avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.