Bird
Raised Fist0
AWScloud~5 mins

Default vs custom metrics in AWS - CLI Comparison

Choose your learning style10 modes available
Introduction
Metrics help you watch how your cloud resources behave. Default metrics are ready-made and track basic things automatically. Custom metrics let you track special details that matter to your app or service.
When you want to see CPU or memory use of your server without extra setup
When you need to track how many users logged into your app every hour
When you want to monitor error rates specific to your application logic
When you want alerts on unusual activity not covered by default metrics
When you want to compare performance between different versions of your app
Commands
This command lists default metrics for EC2 instances that AWS collects automatically.
Terminal
aws cloudwatch list-metrics --namespace AWS/EC2
Expected OutputExpected
METRICS { "Metrics": [ { "Namespace": "AWS/EC2", "MetricName": "CPUUtilization", "Dimensions": [ { "Name": "InstanceId", "Value": "i-0123456789abcdef0" } ] }, { "Namespace": "AWS/EC2", "MetricName": "DiskReadOps", "Dimensions": [ { "Name": "InstanceId", "Value": "i-0123456789abcdef0" } ] } ] }
→
--namespace - Filters metrics to show only those in the AWS/EC2 category
This command sends a custom metric named UserLogins with a value of 5 to CloudWatch under the CustomApp namespace.
Terminal
aws cloudwatch put-metric-data --namespace CustomApp --metric-name UserLogins --value 5 --dimensions AppName=myapp
Expected OutputExpected
No output (command runs silently)
→
--namespace - Defines the category for the custom metric
→
--metric-name - Names the custom metric
→
--value - Sets the metric's value
→
--dimensions - Adds extra info to identify the metric source
This command retrieves the sum of UserLogins custom metric values for the specified time range and app name.
Terminal
aws cloudwatch get-metric-statistics --namespace CustomApp --metric-name UserLogins --start-time 2024-06-01T00:00:00Z --end-time 2024-06-01T01:00:00Z --period 60 --statistics Sum --dimensions Name=AppName,Value=myapp
Expected OutputExpected
{ "Label": "UserLogins", "Datapoints": [ { "Timestamp": "2024-06-01T00:00:00Z", "Sum": 5.0, "Unit": "Count" } ] }
→
--start-time - Sets the beginning of the time range
→
--end-time - Sets the end of the time range
→
--period - Defines the granularity in seconds
→
--statistics - Chooses the type of statistic to retrieve
Key Concept

If you remember nothing else from this pattern, remember: default metrics track common resource data automatically, while custom metrics let you track what matters most to your app.

Common Mistakes
Trying to send custom metrics without specifying a namespace
CloudWatch requires a namespace to organize metrics; missing it causes the command to fail
Always include the --namespace flag with a meaningful name when sending custom metrics
Using default metric names when trying to send custom data
Default metric names are reserved and cannot be overwritten by custom data
Choose unique metric names under your custom namespace to avoid conflicts
Not specifying dimensions when retrieving custom metrics
Dimensions help identify the exact metric; missing them can return no data or wrong data
Always include the correct dimensions when querying custom metrics
Summary
Use 'aws cloudwatch list-metrics' to see default metrics AWS collects automatically.
Send custom metrics with 'aws cloudwatch put-metric-data' including namespace, metric name, value, and dimensions.
Retrieve custom metric data using 'aws cloudwatch get-metric-statistics' with proper time range and dimensions.

Practice

(1/5)
1. Which statement best describes AWS default metrics in CloudWatch?
easy
A. They are automatically collected and free within certain limits.
B. They require manual setup and extra charges.
C. They only track custom application data.
D. They are disabled by default and need activation.

Solution

  1. Step 1: Understand default metrics collection

    AWS CloudWatch automatically collects default metrics for many services without extra setup.
  2. Step 2: Recognize cost and availability

    These default metrics are free within certain usage limits, making them easy to use.
  3. Final Answer:

    They are automatically collected and free within certain limits. -> Option A
  4. Quick Check:

    Default metrics = automatic + free [OK]
Hint: Default metrics are automatic and free within limits [OK]
Common Mistakes:
  • Thinking default metrics need manual setup
  • Assuming default metrics track custom data
  • Believing default metrics are disabled by default
2. Which of the following is the correct way to send a custom metric to AWS CloudWatch using the AWS CLI?
easy
A. aws cloudwatch send-metric --name CPUUtilization --value 70
B. aws cloudwatch add-metric-data --metric-name CPUUtilization --value 70
C. aws cloudwatch create-metric --metric CPUUtilization --value 70
D. aws cloudwatch put-metric-data --metric-name CPUUtilization --namespace AWS/EC2 --value 70

Solution

  1. Step 1: Identify the correct AWS CLI command

    The correct command to send custom metric data is put-metric-data under aws cloudwatch.
  2. Step 2: Check the syntax and parameters

    The command requires --metric-name, --namespace, and --value parameters as shown in aws cloudwatch put-metric-data --metric-name CPUUtilization --namespace AWS/EC2 --value 70.
  3. Final Answer:

    aws cloudwatch put-metric-data --metric-name CPUUtilization --namespace AWS/EC2 --value 70 -> Option D
  4. Quick Check:

    Use put-metric-data with metric-name and namespace [OK]
Hint: Use 'put-metric-data' with metric-name and namespace [OK]
Common Mistakes:
  • Using incorrect command names like send-metric or create-metric
  • Omitting the namespace parameter
  • Confusing metric creation with data sending
3. Given the following AWS CloudWatch custom metric data sent every minute:
aws cloudwatch put-metric-data --metric-name PageViews --namespace MyApp --value 5

What will be the average value shown in CloudWatch after 3 minutes if the command is run 3 times with values 5, 7, and 8 respectively?
medium
A. 6.67
B. 7
C. 20
D. 5

Solution

  1. Step 1: Sum the metric values sent

    The values sent are 5, 7, and 8. Their sum is 5 + 7 + 8 = 20.
  2. Step 2: Calculate the average over 3 data points

    Average = Total sum / Number of data points = 20 / 3 ≈ 6.67.
  3. Final Answer:

    6.67 -> Option A
  4. Quick Check:

    Average = sum/3 = 6.67 [OK]
Hint: Average = sum of values divided by count [OK]
Common Mistakes:
  • Adding values but not dividing by count
  • Taking the last value as average
  • Multiplying values instead of averaging
4. You tried to send a custom metric to CloudWatch but it does not appear in the console. Which of the following is the most likely cause?
medium
A. CloudWatch only shows metrics after 24 hours delay.
B. You forgot to specify the metric namespace in the command.
C. Custom metrics are automatically visible without sending data.
D. Default metrics do not require namespaces, so this is normal.

Solution

  1. Step 1: Check required parameters for custom metrics

    Custom metrics require a namespace to organize and display them properly in CloudWatch.
  2. Step 2: Understand impact of missing namespace

    If the namespace is missing, CloudWatch cannot categorize the metric, so it won't appear in the console.
  3. Final Answer:

    You forgot to specify the metric namespace in the command. -> Option B
  4. Quick Check:

    Missing namespace hides custom metric [OK]
Hint: Always specify namespace when sending custom metrics [OK]
Common Mistakes:
  • Assuming default metrics need namespaces
  • Expecting immediate visibility without data sent
  • Believing CloudWatch delays metric display by 24 hours
5. You want to monitor a custom application metric that tracks the number of user logins per hour. The default AWS metrics do not provide this data. What is the best approach to achieve this?
hard
A. Enable detailed monitoring on EC2 instances to get user login data.
B. Use the default CPUUtilization metric to estimate user logins.
C. Send custom metric data for user logins to CloudWatch using a unique namespace and metric name.
D. Create an alarm on default network metrics to infer user logins.

Solution

  1. Step 1: Identify the need for custom data

    User logins per hour is specific to the application and not tracked by default AWS metrics.
  2. Step 2: Use custom metrics for application-specific data

    Sending custom metric data with a unique namespace and metric name allows tracking exactly this information in CloudWatch.
  3. Final Answer:

    Send custom metric data for user logins to CloudWatch using a unique namespace and metric name. -> Option C
  4. Quick Check:

    Custom metrics track app-specific data [OK]
Hint: Use custom metrics for app-specific tracking [OK]
Common Mistakes:
  • Trying to use unrelated default metrics for app data
  • Assuming detailed monitoring tracks application events
  • Using alarms on unrelated metrics to guess user activity
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard