Creating AWS CloudWatch Dashboards
Using Go SDK
I needed a way to create and update custom AWS CloudWatch dashboards. I built a CLI tool called awsdash to help me with that.
The tool installation and usage is very simple:
$ go install github.com/go-monk/awsdash@latest
$ awsdash -hIf you want to look inside (to understand and maybe contribute) first you need to understand CloudWatch dashboards a bit. They are composed of widgets that are marshalled into JSON. Awsdash supports text and metrics widgets. Text widgets show text in markdown format. Metric widgets display some metric, like number of requests.
Here’s an example code snippet:
dashboard.Put(ctx, cfg, tags,
widget.Text("## Amplify Apps", 24, 1),
widget.Metric(apps.Requests(cfg.Region), 8, 5),
widget.Metric(apps.Errors4xx(cfg.Region), 8, 5),
widget.Metric(apps.Errors5xx(cfg.Region), 8, 5),
)We have a text widget and three metrics widgets that have the width of 8 and the height of 5. The total page width is 24. This code would create a dashboard like:
See the full code here.


