0
0
AWScloud~10 mins

CloudWatch metrics in AWS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the namespace when creating a CloudWatch metric.

AWS
metric = cloudwatch.Metric(namespace=[1], metric_name="PageViews")
Drag options to blanks, or click blank then click option'
A"MyApp/Metrics"
B"AWS/EC2"
C"EC2"
D"CloudWatch"
Attempts:
3 left
💡 Hint
Common Mistakes
Using AWS default namespaces for custom metrics
Omitting quotes around the namespace string
2fill in blank
medium

Complete the code to create a CloudWatch alarm that triggers when CPU utilization exceeds 80%.

AWS
alarm = cloudwatch.Alarm(threshold=[1], comparison_operator="GreaterThanThreshold")
Drag options to blanks, or click blank then click option'
A50
B100
C20
D80
Attempts:
3 left
💡 Hint
Common Mistakes
Setting threshold too low or too high
Confusing comparison operators
3fill in blank
hard

Fix the error in the code to correctly publish a custom metric value to CloudWatch.

AWS
cloudwatch.put_metric_data(Namespace="MyApp", MetricData=[[1]])
Drag options to blanks, or click blank then click option'
A{"MetricName": "Errors", "Values": [5]}
B{"Name": "Errors", "Value": 5}
C{"MetricName": "Errors", "Value": 5}
D{"Metric": "Errors", "Value": 5}
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect key names like 'Name' or 'Metric'
Using 'Values' instead of 'Value'
4fill in blank
hard

Fill both blanks to create a CloudWatch metric filter that matches error logs and extracts the error code.

AWS
filter = cloudwatch.MetricFilter(log_group_name=[1], filter_pattern=[2])
Drag options to blanks, or click blank then click option'
A"/aws/lambda/my-function"
B"ERROR"
C"[timestamp, level=ERROR, message, errorCode]"
D"[timestamp, level=INFO, message]"
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect filter pattern syntax
Using wrong log group names
5fill in blank
hard

Fill all three blanks to define a CloudWatch dashboard widget showing average CPU utilization for an EC2 instance.

AWS
widget = cloudwatch.DashboardWidget(type=[1], properties={"metrics": [[[2], "CPUUtilization", "InstanceId", [3]]], "period": 300, "stat": "Average"})
Drag options to blanks, or click blank then click option'
A"metric"
B"AWS/EC2"
C"i-1234567890abcdef0"
D"log"
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'log' instead of 'metric' for widget type
Using incorrect namespace or instance ID format