Synchronising CloudWatch Dashboards

How to keep your CloudWatch dashboards in sync across multiple environments.

thomas michael wallace
DevicePilot
2 min readJul 4, 2018

--

It won’t take long on your AWS journey before you bump into CloudWatch- the repository of all logs and metrics. You’ll probably start by scanning through logs, progress to plotting the odd metric and graduate to a tidy little dashboard. If you’re dedicated you might even end up with degree level rules and alarms.

CloudWatch dashboards are fairly impressive, given how cheap they are to run. They’re a bit rough around the edges, and I wouldn’t want to hand them over to anyone non-technical; but in the age of devops, they’re an invaluable tool to help me keep en eye on our key system performance metrics, and spot issues before they become problems.

As you start to split across multiple environments (we’ve thus far managed to keep it down to development, staging and production), you’ll probably want a dashboard for each. And at that point you’ll notice a missing feature- templating.

Sure- you can export the dashboard as JSON, and do a cheeky find and replace and copy it back… But what programmer doesn’t enjoy a bit of automation?

The above script will synchronise a dashboard template across multiple environments (e.g. dashboard-one-master, dashboard-one-staging, dashboard-one-production) by replacing the environment name across all your resources (e.g. awesome-lambda-master will become awesome-lambda-staging, al la the Serverless Framework).

I’ve omitted the command line, as it’s part of a bigger suite of tools for us, but, as anything shared here, feel free to take it and tailor it to your needs.

Get dashboard’ing!

--

--