

# Monitor Amazon Location Service with Amazon CloudWatch
<a name="monitoring-using-cloudwatch"></a>

Amazon CloudWatch monitors your AWS resources and the applications that you run on AWS in near-real time. You can monitor Amazon Location resources using CloudWatch, which collects raw data and processes metrics into meaningful statistics in near-real time. You can view historical information for up to 15 months, or search metrics to view in the Amazon CloudWatch console for more perspective about your Amazon Location resources. You can also set alarms by defining thresholds, and send notifications or take actions when those thresholds are met. 

 For more information, see the [Amazon CloudWatch User Guide](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/)

**Topics**
+ [Amazon Location Service metrics exported to Amazon CloudWatch](#metrics-exported-to-cloudwatch)
+ [View Amazon Location Service metrics](#view-metrics)
+ [Create CloudWatch alarms for Amazon Location Service metrics](#create-alarms)
+ [Use CloudWatch to monitor usage against quotas](#alarms-on-quotas)
+ [CloudWatch metric examples for Amazon Location Service](#example-alarms)

## Amazon Location Service metrics exported to Amazon CloudWatch
<a name="metrics-exported-to-cloudwatch"></a>

Metrics are time-ordered data points that are exported to CloudWatch. A dimension is a name/value pair that identifies the metric. For more information, see [Using CloudWatch metrics](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/working_with_metrics.html) and [CloudWatch](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Dimension) dimensions in the Amazon CloudWatch User Guide.

The following are metrics that Amazon Location Service exports to CloudWatch in the `AWS/Location` namespace.


| Metric | Description | 
| --- | --- | 
|  `CallCount`  |  The number of calls made to a given API endpoint.  Valid Dimensions: Amazon Location Service API names Valid Statistic: Sum Units: Count  | 
|  `ErrorCount`  |  The number of error responses from calls made to a given API endpoint. Valid Dimensions: Amazon Location Service API names Valid Statistic: Sum Units: Count  | 
|  `SuccessCount`  |  The number of successful calls made to a given API endpoint.  Valid Dimensions: Amazon Location Service API names Valid Statistic: Sum Units: Count  | 
|  `CallLatency`  | The amount of time the operation takes to process and return a response when a call is made to a given API endpoint. Valid Dimensions: Amazon Location Service API names Valid Statistic: AverageUnits: Milliseconds | 

## View Amazon Location Service metrics
<a name="view-metrics"></a>

You can view metrics for Amazon Location Service on the Amazon CloudWatch console or by using the Amazon CloudWatch API.

**To view metrics using the CloudWatch console**

**Example**  

1. Open the CloudWatch console at [https://console.aws.amazon.com/cloudwatch/](https://console.aws.amazon.com/cloudwatch/).

1. In the navigation pane, choose **Metrics**.

1. On the **All metrics tab**, choose the Amazon Location namespace.

1. Select the type of metric to view.

1. Select the metric and add it to the chart.
For more information, see [View Available Metrics](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/viewing_metrics_with_cloudwatch.html) in the *Amazon CloudWatch User Guide*. 

## Create CloudWatch alarms for Amazon Location Service metrics
<a name="create-alarms"></a>

You can use CloudWatch to set alarms on your Amazon Location Service metrics. For example, you can create an alarm in CloudWatch to send an email whenever an error count spike occurs. 

The following topics give you a high-level overview of how to set alarms using CloudWatch. For detailed instructions, see [Using Alarms](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html) in the *Amazon CloudWatch User Guide*. 

**To set alarms using the CloudWatch console**

**Example**  

1. Open the CloudWatch console at [https://console.aws.amazon.com/cloudwatch/](https://console.aws.amazon.com/cloudwatch/).

1. In the navigation pane, choose **Alarm**.

1. Choose **Create Alarm**.

1. Choose **Select metric**.

1. On the **All metrics** tab, select the Amazon Location namespace.

1. Select a metric category.

1. Find the row with the metric you want to create an alarm for, then select the check box next to this row.

1. Choose **Select metric**.

1. Under **Metric**, fill in the values .

1. Specify the alarm **Conditions** .

1. Choose **Next**.

1. If you want to send a notification when the alarm conditions are met:
   + Under **Alarm state trigger**, select the alarm state to prompt a notification to be sent.
   + Under **Select an SNS topic**, choose **Create new topic** to create a new Amazon Simple Notification Service (Amazon SNS) topic. Enter the topic name and the email to send the notification to. 
   + Under **Send a notification to** enter additional email addresses to send the notification to.
   + Choose** Add notification**. This list is saved and appears in the field for future alarms.

1. When done, choose **Next**.

1. Enter a name and description for the alarm, then choose **Next**.

1. Confirm the alarm details, then choose **Next**.

**Note**  
When creating a new Amazon SNS topic, you must verify the email address before a notification can be sent. If the email is not verified, the notification will not be received when an alarm is initiated by a state change.

For more information about how to set alarms using the CloudWatch console, see [Create an Alarm that Sends Email](https://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/AlarmThatSendsEmail.html) in the *Amazon CloudWatch User Guide*. 

## Use CloudWatch to monitor usage against quotas
<a name="alarms-on-quotas"></a>

You can create Amazon CloudWatch alarms to notify you when your utilization of a given quota exceeds a configurable threshold. This enables you to recognize when you are close to your quota limits, and either adapt your utilization to avoid cost overruns, or request a quota increase, if needed. For information about how to use CloudWatch to monitor quotas, see [ Visualizing your service quotas and setting alarms](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Quotas-Visualize-Alarms.html) in the * Amazon CloudWatch User Guide*.

## CloudWatch metric examples for Amazon Location Service
<a name="example-alarms"></a>

You can use the [GetMetricData](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricData.html) API to retrieve metrics for Amazon Location. 
+ For example, you can monitor `CallCount` and set an alarm for when a drop in number occurs. 

  Monitoring the `CallCount` metrics for `SendDeviceLocation` can help give you perspective on tracked assets. If the `CallCount` drops, it means that tracked assets, such as a fleet of trucks, have stopped sending their current locations. Setting an alarm for this can help notify you an issue has occurred.
+ For another example, you can monitor `ErrorCount` and set an alarm for when a spike in number occurs.

  Trackers must be associated with geofence collections in order for device locations to be evaluated against geofences. If you have a device fleet that requires continuous location updates, seeing the `CallCount` for `BatchEvaluateGeofence` or `BatchPutDevicePosition` drop to zero indicates that updates are no longer flowing.

The following is an example output for [GetMetricData](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricData.html) with the metrics for `CallCount` and `ErrorCount` for creating map resources.

```
{
  "StartTime": 1518867432,
  "EndTime": 1518868032,
  "MetricDataQueries": [
    {
      "Id": "m1",
      "MetricStat": {
        "Metric": {
          "Namespace": "AWS/Location",
          "MetricName": "CallCount",
          "Dimensions": [
            {
              "Name": "SendDeviceLocation",
              "Value": "100"
            }
          ]
        },
        "Period": 300,
        "Stat": "SampleCount",
        "Unit": "Count"
      }
    },
    {
      "Id": "m2",
      "MetricStat": {
        "Metric": {
          "Namespace": "AWS/Location",
          "MetricName": "ErrorCount",
          "Dimensions": [
            {
              "Name": "AssociateTrackerConsumer",
              "Value": "0"
            }
          ]
        },
        "Period": 1,
        "Stat": "SampleCount",
        "Unit": "Count"
      }
    }
  ]
}
```