Skip to content

A Go lang tool designed to shrink AWS Autoscaling Clusters based on CPU and Memory Cloudwatch Alarm Metrics.

License

Notifications You must be signed in to change notification settings

darkraiden/sigmund

Repository files navigation

Sigmund

A Go tool designed to shrink AWS Autoscaling Clusters based on CPU and Memory Cloudwatch Alarm Metrics.

This tool is meant to be for people who want to scale their instances back in whenever both CPU AND Memory conditions are met.

Sigmund Go

Prerequisites

  • A DynamoDB table
  • AWS credentials with the following permissions:
    • DynamoDB Table Read/Write access
    • Ability to Execute Autoscaling Policies

DyanamoDB Table structure

In order to work, your DynamoDB table should look like the one that follows:

ID isLowCPU isLowMemory
0 false false

NB it is important that the table is pre-populated with the values showed above, most importantly you must make sure that the ID = 0 - that value will never change.

Installing

You can directly use the go tool to download and install the sigmund package into your GOPATH:

$ go get github.com/darkraiden/sigmund.go

You can also clone the repository yourself:

$ mkdir -p $GOPATH/src/github.com/darkraiden
$ cd $GOPATH/src/github.com/darkraiden
$ git clone git@git.int.avast.com:devops/sigmund

How to use it

First things first, initialise a Sigmund from your application:

  // Get a Sigmund
  s, err := sigmund.New(&sigmund.Config{Region: "eu-west-1", AsgName: "anASGName", PolicyName: "anASGPolicyName", TableName: "aDynamoTableName", Metric: "LowCPU"}) // LowCPU can be replaced by OkCPU, LowMemory, OkMemory, depending on which metric changed on your Cloudwatch Alerts
  if err != nil {
    panic(err)
  }

Now that you have your Sigmund, you're ready to update the DB and eventually execute the autoscaling group policy:

  err := s.Shrink()
  if err != nil {
    panic(err)
  }

Logging

Sigmund uses Logrus for logging. The default config is different depending on whether it was compiled for production or not (mage releaseLambda or building with the PRODUCTION environment variable set).

Currently, all errors are deemed irrecoverable and result in a panic.

Running the tests

Every Package of this project comes with some unit tests which use the Go testing package. Run the tests, from the package folder, by typing:

$ go test ./...

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

About

A Go lang tool designed to shrink AWS Autoscaling Clusters based on CPU and Memory Cloudwatch Alarm Metrics.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages