Step 2—Add dimensions to metric data

We can specify dimensions with the put-metric-data sub-command using its dimensions property. Add a dimension with two different values using the following code:

aws cloudwatch put-metric-data 
--namespace 'ServerlessProgrammingCookbook'
--metric-name 'FailedLogins'
--value 1
--dimensions 'Device=Mobile'
--region us-east-1
--profile admin

aws cloudwatch put-metric-data
--namespace 'ServerlessProgrammingCookbook'
--metric-name 'FailedLogins'
--value 1
--dimensions 'Device=Laptop'
--region us-east-1
--profile admin

aws cloudwatch put-metric-data
--namespace 'ServerlessProgrammingCookbook'
--metric-name 'FailedLogins'
--value 1
--dimensions 'Device=Laptop'
--region us-east-1
--profile admin

We can verify our metric from AWS Management Console as follows:

  1. When we click on our custom namespace, ServerlessProgrammingCookbook, we should see a link for our new dimension along with a link for the ones without a dimension, as shown in the following screenshot:

  1. Click on the Device link. This will show our metrics for each value of the Device dimension, as shown in the following screenshot:

  1. We can now click on the dropdown next to any of these dimension values (as shown in the following screenshot) to perform all operations that we can perform on an automatically generated metric:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.12.232