Amazon Elastic MapReduce
Developer Guide (API Version 2009-03-31)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.Did this page help you?  Yes | No |  Tell us about it...

Configure Logging and Debugging (Optional)

One of the things to decide as you plan your cluster is how much debugging support you want to make available. When you are first developing your data processing application, we recommend testing the application on a cluster processing a small, but representative, subset of your data. When you do this, you will likely want to take advantage of all the debugging tools that Amazon EMR offers, such as archiving log files to Amazon S3.

When you've finished development and put your data processing application into full production, you may choose to scale back debugging. Doing so can save you the cost of storing log file archives in Amazon S3 and reduce processing load on the cluster as it no longer needs to write state to Amazon S3. The trade off, of course, is that if something goes wrong, you'll have fewer tools available to investigate the issue.

Default Log Files

By default, each cluster writes log files on the master node. These are written to the /mnt/var/log/ directory. You can access them by using SSH to connect to the master node as described in Connect to the Master Node Using SSH. Because these logs exist on the master node, when the node terminates — either because the cluster was shut down or because an error occurred — these log files are no longer available.

You do not need to enable anything to have log files written on the master node. This is the default behavior of Amazon EMR and Hadoop.

A cluster generates several types of log files, including:

  • Step logs — These logs are generated by the Amazon EMR service and contain information about the cluster and the results of each step. The log files are stored in /mnt/var/log/hadoop/steps/ directory on the master node. Each step logs its results in a separate numbered subdirectory: /mnt/var/log/hadoop/steps/1/ for the first step, /mnt/var/log/hadoop/steps/2/, for the second step, and so on.

  • Hadoop logs — These are the standard log files generated by Apache Hadoop. They contain information about Hadoop jobs, tasks, and task attempts. The log files are stored in /mnt/var/log/hadoop/ on the master node.

  • Bootstrap action logs — If your job uses bootstrap actions, the results of those actions are logged. The log files are stored in /mnt/var/log/bootstrap-actions/ on the master node. Each bootstrap action logs its results in a separate numbered subdirectory: /mnt/var/log/bootstrap-actions/1/ for the first bootstrap action, /mnt/var/log/bootstrap-actions/2/, for the second bootstrap action, and so on.

  • Instance state logs — These logs provide information about the CPU, memory state, and garbage collector threads of the node. The log files are stored in /mnt/var/log/instance-state/ on the master node.

Archive Log Files to Amazon S3

You can configure a cluster to periodically archive the log files stored on the master node to Amazon S3. This ensures that the log files are available after the cluster terminates, whether this is through normal shut down or due to an error. Amazon EMR archives the log files to Amazon S3 at 5 minute intervals.

To have the log files archived to Amazon S3, you must enable this feature when you launch the cluster. You can do this using the console, the CLI, or the API. How to do this is shown in the following procedures.

To archive log files to Amazon S3 using the console

  1. Sign in to the AWS Management Console and open the Amazon Elastic MapReduce console at https://console.aws.amazon.com/elasticmapreduce/vnext/.

  2. Click Create Cluster.

    Create Cluster
  3. In the Cluster Configuration section, in the Logging field, choose Enabled.

    This determines whether Amazon EMR will capture detailed log data to Amazon S3.

    For more information, see View Log Files.

  4. In the Log folder S3 location field, enter an Amazon S3 path to store your debug logs.

    When this value is set, Amazon EMR copies the log files from the EC2 instances in the cluster to Amazon S3. This prevents the log files from being lost when the cluster ends and the EC2 instances hosting the cluster are terminated. These logs are useful for troubleshooting purposes.

    For more information, see View Log Files.

  5. Click Done and proceed to create the cluster as described in Plan an Amazon EMR Cluster.

To archive log files to Amazon S3 using the CLI

  • Set the --log-uri argument when you launch the cluster and specify a location in Amazon S3. Alternately, you can set this value in the credentials.json file that you configured for the CLI. This will cause all of the clusters you launch with the CLI to archive log files to the specified S3 bucket. For more information about credentials.json, see "Configuring Credentials" in Install the Amazon EMR Command Line Interface.

    The following example illustrates creating a cluster that archives log files to Amazon S3. You would replace the value myawsbucket with the name of S3 bucket that you own.

    • Linux, UNIX, and Mac OS X users:

      ./elastic-mapreduce --create --log-uri s3://myawsbucket
    • Windows users:

      ruby elastic-mapreduce --create --log-uri s3://myawsbucket

Enable the Debugging Tool

The debugging tool is a graphical user interface that you can use to browse the log files from the console. When you enable debugging on a cluster, Amazon EMR archives the log files to Amazon S3 and then indexes those files. You can then use the graphical interface to browse the step, job, task, and task attempt logs for the cluster in an intuitive way. An example of using the debugging tool to browse log files is shown in View the Results.

To be able to use the graphical debugging tool, you must enable debugging when you launch the cluster. You can do this using the console, the CLI, or the API.

To enable the debugging tool using the Amazon EMR console

  1. Sign in to the AWS Management Console and open the Amazon Elastic MapReduce console at https://console.aws.amazon.com/elasticmapreduce/vnext/.

  2. Click Create Cluster.

    Create Cluster
  3. In the Cluster Configuration section, in the Debugging field, choose Enabled.

    This option creates a debug log index in SimpleDB (additional charges apply) to enable detailed debugging in the Amazon EMR console. You can only set this when the cluster is created. For more information about Amazon SimpleDB, go to the Amazon SimpleDB product description page.

  4. Click Done and proceed to create the cluster as described in Plan an Amazon EMR Cluster.

To enable the debugging tool using the CLI

  • Use the --enable-debugging argument when you create the cluster. You must also set the --log-uri argument and specify a location in Amazon S3 because archiving the log files to Amazon S3 is a prerequisite of the debugging tool. Alternately, you can set the --log-uri value in the credentials.json file that you configured for the CLI. For more information about credentials.json, see "Configuring Credentials" in Install the Amazon EMR Command Line Interface.

    The following example illustrates creating a cluster that archives log files to Amazon S3. You would replace the value myawsbucket with the name of S3 bucket that you own.

    • Linux, UNIX, and Mac OS X users:

      ./elastic-mapreduce --create --enable-debugging \
           --log-uri s3://myawsbucket
    • Windows users:

      ruby elastic-mapreduce --create --enable-debugging --log-uri s3://myawsbucket

To enable the debugging tool using the API

  • Add a step when you launch the cluster that runs s3://elasticmapreduce/libs/script-runner/script-runner.jar with the argument 3://elasticmapreduce/libs/state-pusher/0.1/fetch. This runs the Hadoop state pusher to push the state of Hadoop jobs in real time. You must also set a value for the LogUri parameter because archiving the log files to Amazon S3 is a prerequisite of the debugging tool.

    The following example illustrates creating a cluster that enables debugging. You would replace the value myawsbucket with the name of an S3 bucket that you own.

    Action=RunJobFlow&
    Name=My%20Job%20Flow&
    Timestamp=2010-05-26T11%3A25%3A40-07%3A00&
    LogUri=s3%3A%2F%2Fmyawsbucket&
    Instances.InstanceCount=1&	
    Instances.Ec2KeyName=MyKeyName&
    Instances.MasterInstanceType=m1.small&
    Instances.SlaveInstanceType=m1.small&
    Instances.KeepJobFlowAliveWhenNoSteps=true
    Steps.member.1.Name=Enable%20Debugging&
    Steps.member.1.ActionOnFailure=TERMINATE_JOB_FLOW&
    Steps.member.1.HadoopJarStep.Jar=s3%3A%2F%2Felasticmapreduce%2Flibs%2Fscript-runner%2Fscript-runner.jar&
    Steps.member.1.HadoopJarStep.Args.member.1=s3%3A%2F%2Felasticmapreduce%2Flibs%2Fstate-pusher%2F0.1%2Ffetch&
    AWSAccessKeyId=calculated value&
    SignatureVersion=2&
    SignatureMethod=HmacSHA1&
    Signature=calculated value&