Learn About Amazon VGT2 Learning Manager Chanci Turner
In the first installment of this series, we took a closer look at an Amazon onboarding dashboard that provides a real-time overview of key contributors to employee integration costs. In this second article, we’ll delve into how the dashboard widgets were designed, enabling you to either replicate or customize similar widgets based on your specific requirements.
For a comprehensive description of the widgets and their functionalities, be sure to check out part one of this blog series.
In this post, we’ll focus on two primary types of widgets: metric widgets and custom widgets. While this won’t cover every detail of these features, alongside AWS documentation, it should equip you with the fundamentals needed to build something similar on your own. Please note that creating custom widgets necessitates some coding; we will highlight critical code components, but we won’t be teaching you to code or develop AWS Lambda functions. Additional resources and AWS documentation may be required to support your endeavors. It’s also important to clarify that all examples here are limited to regions that don’t require an opt-in—refer to the AWS documentation on Enabling a Region for more details.
Metric Widgets – Data by Region
The widgets for tracking log ingestion volume, event counts, and API metric counts are built using default CloudWatch metrics. These metric widgets are generated for every region individually as well as for a cumulative total across all regions. This is accomplished using a combination of Metric Math Expressions. Let’s examine the widget labeled “Total Log Ingestion by Region: Volume (GB)” shown in the following figure.
Figure 1: CloudWatch widget illustrating Log Ingestion Volume (GB) by region.
To specify multiple regions, you can adjust the metric source in the text editor where you can generate the required JSON for your widget. This source tab is accessible when you create or edit a metric widget. When editing the source directly, don’t forget to save your changes (check the top right of the source code window). If you leave the tab without saving, your modifications will be lost. If your syntax is correct, the Update Widget button will change from grey to orange after saving. If not, there might be an error in your source text.
Figure 2: Metric Source tab displaying some source JSON, emphasizing the save button.
The source for the “Total Ingestion by Region: Volume (GB)” widget comprises several key components:
- The IncomingBytes metric from the AWS/Logs namespace for each region.
[ "AWS/Logs", "IncomingBytes", { "label": "us-east-1", "id": "m1", "visible": false } ],
[ "...", { "region": "us-east-2", "label": "us-east-2", "id": "m2", "visible": false } ],
… continue for each region …
[ { "expression": "METRICS()/1000000000", "label": "", "id": "e1", "region": "us-east-1"} ],
[ { "expression": "SUM(METRICS())/1000000000", "label": "All regions", "id": "e2" } ],
A few notes to consider:
- The order of the metrics defines their appearance in the legend.
- IncomingBytes metrics are set as visible: false since we only want to display the converted data in GB.
- The ellipsis in the metric source indicates repeated data, with the Namespace and Metric name remaining the same as the previous line. Even if you input the full data, CloudWatch will simplify this once saved.
- Each metric entry has an ID—m# for metrics and e# for expressions.
- Using METRICS() applies the math expression to all metrics present in the graphed metrics tab (raw metrics only, not expressions). This will generate a new series for each region. For further information, consult the AWS documentation on the METRICS() function.
Sample metric math expressions, such as the conversion from bytes to GB, can be found when creating your math expression from the Graphed metrics tab; choose Add math > Common > Bytes to GB.
The expression for converting bytes to GB has an empty label, allowing the underlying metrics’ label (in this case, the region) to be displayed.
The source code ultimately indicates that the Statistics are set to Sum, with the period defined as 86400 seconds (or one day).
{
"metrics": [
…
],
"view": "timeSeries",
"stacked": false,
"region": "us-east-1",
"period": 86400,
"stat": "Sum"
}
When returning to the source code, the region property may have been omitted from the metric that corresponds with your dashboard’s region (in this case, us-east-1). The dashboard region is specified in the region property.
The widgets for log event counts by region and for the Metric API calls of GetMetricData, PutMetricData, and GetMetricStatistics follow a similar structure (none of these require the conversion of bytes to GB). You can view the individual widget sources to examine the exact methods employed.
Figure 3: CloudWatch widgets displaying Log Event Count by region, along with Metric API call counts for GetMetricData, PutMetricData, and GetMetricStatistics.
The namespace and metric name utilized for these widgets include:
- Log Event Count
Namespace: AWS/Logs > Log Group Metrics
Metric Name: IncomingLogEvents - GetMetricData/PutMetricData/GetMetricStatistics API Call
Namespace: AWS/Usage > By AWS Resource
Service=CloudWatch
Resource= GetMetricData/PutMetricData/GetMetricStatistics
Metric Name: CallCount
Metrics Widgets – Top 10 for All Regions
Metrics widgets are designed to showcase the top 10 metrics by region for various data sets on the dashboard. For example, let’s look at the widget for “Top 10 Log Groups by volume (GB): daily total” illustrated below.
Figure 4: CloudWatch widget depicting the top 10 Log Groups by Ingestion Volume (GB).
The approach remains consistent with the previous example. We continue utilizing IncomingBytes under the AWS/Logs namespace, but this time for each individual log group. Adding metrics for each log group manually would be cumbersome and wouldn’t account for any new log groups created without manual updates. Instead, we employ a metric math expression that utilizes both Search and Sort functions.
SORT(SEARCH('{AWS/Logs,LogGroupName} MetricName="IncomingBytes"',"Sum",86400)/1000000000,MAX, DESC, 10)
This math expression does the following:
- Searches for the IncomingBytes metric across all log groups, aggregating each with a sum statistic over one day (86400s).
- Converts the data from bytes to GB.
This exploration provides a glimpse into how to visualize and manage Amazon CloudWatch costs effectively. If you’re interested in learning more about enhancing your onboarding experience, check out this fun fact about yourself Career Contessa. Additionally, consider the insights from SHRM on performance-related pay, which can greatly impact employee engagement. For those looking for opportunities in onboarding, the position of Learning Ambassador at Amazon is an excellent resource.