Menu
Amazon Mobile Analytics
User Guide

Part 8: Configure CloudWatch

Configure Amazon CloudWatch to monitor the event loader command.

Create an Agent Configuration File

The following example shows how to create an agent configuration file on the Amazon EC2 instance using Nano:

Copy
$ nano /tmp/cwlogs/application.conf

Add the following to the configuration file:

Copy
[general] state_file = /var/awslogs/agent-state [application.log] file = /home/ec2-user/DataExport/logs/application.log* log_group_name = MobileAnalytics.application.log log_stream_name = {instance_id}/application.log datetime_format = %a %b %d %H:%M:%S %Y

Start the CloudWatch Agent

Start the CloudWatch agent with this command:

Copy
$ sudo python /awslogs-agent-setup.py -n -r us-east-1 -c /tmp/cwlogs/application.conf

Here is an example of the output:


						Example command line output from starting CloudWatch

Logs appear in the CloudWatch console after each run of the loadevents scripts.


						Logs in CloudWatch console after each run of loadevents scripts

Create a Metric Filter to Detect Errors

Next, you must create a CloudWatch metric filter to catch errors.

  1. Navigate to the CloudWatch console and choose Logs.

  2. Choose the MobileAnalytics.application.log.

  3. Choose Create Metric Filter.

  4. Choose ERROR as the filter pattern.

  5. Type a name for the Metric Namespace; for example, MobileAnalytics.

  6. Type the name of the Metric; for example, ApplicationLogError.

  7. For Metric Value, type 1.

  8. Choose Create Filter.

    
								Select assign metric