📖 Scenario: You are a cloud engineer setting up monitoring for a web application hosted on AWS. You want to create a CloudWatch dashboard to visualize key metrics like CPU utilization and network traffic.
🎯 Goal: Build a CloudWatch dashboard JSON configuration that shows two widgets: one for CPU utilization and one for network in/out for an EC2 instance.
📋 What You'll Learn
Create a dashboard body JSON structure with widgets array
Add a widget for CPUUtilization metric from EC2 namespace
Add a widget for NetworkIn and NetworkOut metrics from EC2 namespace
Use correct metric dimensions with InstanceId
Use valid JSON structure deployable to AWS CloudWatch
💡 Why This Matters
🌍 Real World
CloudWatch dashboards help visualize and monitor AWS resource metrics in one place, making it easier to spot issues and optimize performance.
💼 Career
Cloud engineers and DevOps professionals often create and maintain dashboards to ensure system health and respond quickly to alerts.
Progress0 / 4 steps
1
Create the initial dashboard JSON structure
Create a variable called dashboard_body and assign it a JSON string with an empty widgets array: {"widgets": []}.
AWS
Hint
Use single quotes outside and double quotes inside for the JSON string.
2
Add a CPU Utilization widget configuration
Add a variable called cpu_widget and assign it a JSON object string representing a CloudWatch metric widget for CPUUtilization metric in the AWS/EC2 namespace with dimension InstanceId set to i-1234567890abcdef0. The widget should have a width of 6 and height of 6.
AWS
Hint
Follow AWS CloudWatch metric widget JSON format with properties including metrics array.
3
Add a Network In/Out widget configuration
Add a variable called network_widget and assign it a JSON object string representing a CloudWatch metric widget for NetworkIn and NetworkOut metrics in the AWS/EC2 namespace with dimension InstanceId set to i-1234567890abcdef0. The widget should have a width of 6 and height of 6.
AWS
Hint
Include both NetworkIn and NetworkOut metrics in the metrics array.
4
Combine widgets into the dashboard body
Update the dashboard_body variable to include the cpu_widget and network_widget JSON objects inside the widgets array. Use Python's json module to parse and combine the JSON strings properly.
AWS
Hint
Use json.loads() to convert strings to objects, append widgets, then json.dumps() to convert back to string.
Practice
(1/5)
1. What is the main purpose of an AWS CloudWatch dashboard?
easy
A. To deploy new cloud servers automatically
B. To store backups of cloud data
C. To visually display cloud resource metrics in one place
D. To manage user permissions for AWS services
Solution
Step 1: Understand CloudWatch dashboard function
CloudWatch dashboards collect and show metrics visually for easy monitoring.
Step 2: Compare options with dashboard purpose
Only To visually display cloud resource metrics in one place describes visual display of metrics; others describe unrelated tasks.
Final Answer:
To visually display cloud resource metrics in one place -> Option C
Quick Check:
Dashboard = Visual metrics display [OK]
Hint: Dashboards show metrics visually, not manage or store data [OK]
Common Mistakes:
Confusing dashboards with backup storage
Thinking dashboards manage permissions
Assuming dashboards deploy servers
2. Which JSON element is required to add a widget to a CloudWatch dashboard?
easy
A. "widgets" array containing widget objects
B. "servers" array listing EC2 instances
C. "permissions" object defining access rights
D. "backups" array for snapshot data
Solution
Step 1: Identify JSON structure for dashboards
CloudWatch dashboards use a "widgets" array to hold widget definitions.
Step 2: Eliminate unrelated JSON elements
Options A, B, and D relate to servers, permissions, or backups, not widgets.
Final Answer:
"widgets" array containing widget objects -> Option A
Quick Check:
Widgets array = dashboard widgets [OK]
Hint: Widgets array holds dashboard widgets in JSON [OK]
Common Mistakes:
Using 'servers' instead of 'widgets'
Confusing permissions with widget data
Including backups in dashboard JSON
3. Given this widget JSON snippet for a CloudWatch dashboard: