Creating Cloudwatch Dashboards per Environment with Python

Reading Time: 5 minutes


Show Me The Code Already

After installing Cloudwatch Agent to the machines you want to monitor, it’s time to create dashboards to view real-time metrics.

There are some ways to create Cloudwatch Dashboards such as creating them manually by selecting widgets from AWS Console, with Cloudformation etc.

I’ve decided to create them with Python because in DevOps literature, there is no such a thing as manually creating something. I also didn’t want to use Cloudformation because I like scripting and we have many applications to monitor in our company, thus, I needed something to iterate over our environments and create dashboards for each of them.

What Does This Code Do?

This particular code takes one parameter from terminal which is the environment you want to create dashboards for. You execute the script by:

After executing the script, dashboards for that specified environment will get created based on the instance count. Since there is a widget count limitation per dashboard, when widget count exceeds 500, other dashboards will get created. If the count is lower than 500, only one will be created.

Let’s get right into the code!

Leave a Reply