DEV Community

Cover image for AWS CloudWatch Dashboard Builder - Namespace Template

AWS CloudWatch Dashboard Builder - Namespace Template

This is the second post in the CloudWatch Dashboard Builder series. In this post, I'll walk you through the Namespace query template, which is the foundation for the AWS CloudWatch Dashboard Builder tool

The namespace query template defines the metric queries for different AWS services. SQL expressions can be used in metric queries. Examples of queries with and without a SQL expression are provided below.

Image description

Image description

As long as a naming standard is followed, the namespace template can be customized to match your needs. Certain keywords must be retained when modifying or creating a new namespace template for usage with the Cloudwatch dashboard builder tool.

The root object of the namespace template is called "cloudwatch_template" and it is a keyword. Under the root object, you can have multiple child objects, which are called namespaces. Each namespace object has a "schema" name and different "templates". Templates are the unique queries for the namespace. The template contains three keys:

  • name: Name of the template. This name is used as the widget title in the Cloudwatch dashboard.
  • desc: A short description of the template. Tells what the query template does, reports or measures.
  • query: A query that will be executed in Cloudwatch to report on the metrics of the namespace.

The namespace template is located in the template folder. For queries that have double quotes in them, they will need to be escaped for the query to work correctly. So special care needs to be taken when updating or creating the template.

Here is another example of a complex namespace template.

Image description

Now that you're familiar with the Namespace template, we can go on to the last post, which explains how to use the tool.

Latest comments (0)