Menu
AWS Lambda
Developer Guide

Step 2.2: Invoke the Lambda Function Manually and Verify Results, Logs, and Metrics

Follow the steps to invoke your Lambda function using the sample event data provided in the console.

  1. On the Lambda > Functions > HelloWorld page, choose Test.

  2. In the Input test event page, choose Hello World from the Sample event template list. The following sample event template appears in the window.

    Copy
    { "key3": "value3", "key2": "value2", "key1": "value1" }

    You can change key and values in the sample JSON, but don't change the event structure. If you do change any keys and values, you must update the sample code accordingly. Choose Save and test.

  3. AWS Lambda executes your function on your behalf. The handler in your Lambda function receives and then processes the sample event.

  4. Upon successful execution, view results in the console.

    Note the following:

    • The Execution result section shows the execution status as succeeded and also shows the function execution results, returned by the return statement.

      Note

      The console always uses the RequestResponse invocation type (synchronous invocation) when invoking a Lambda function which causes AWS Lambda to return a response immediately. For more information, see Invocation Types.

    • The Summary section shows the key information reported in the Log output section (the REPORT line in the execution log).

    • The Log output section shows the log AWS Lambda generates for each execution. These are the logs written to CloudWatch by the Lambda function. The AWS Lambda console shows these logs for your convenience.

    Note that the Click here link shows logs in the CloudWatch console. The function then adds logs to Amazon CloudWatch in the log group that corresponds to the Lambda function.

  5. Run the Lambda function a few times to gather some metrics that you can view in the next step.

  6. Choose the Monitoring tab to view the CloudWatch metrics for your Lambda function. This page shows four CloudWatch metrics.

    Note the following:

    • The X-axis shows the past 24 hours from the current time (for example, 2:00 pm as shown in the screen shot).

    • Invocation count shows the number of invocations during this interval.

    • Invocation duration shows how long it took for your Lambda function to run. It shows minimum, maximum, and average time of execution.

    • Invocation errors show the number of times your Lambda function failed. You can compare the number of times your function executed and how many times it failed (if any).

    • Throttled invocation metrics show whether AWS Lambda throttled your Lambda function invocation. For more information, see AWS Lambda Limits.

    • The AWS Lambda console shows these CloudWatch metrics for your convenience. You can see these metrics in the Amazon CloudWatch console by clicking any of these metrics.

Next Step

Step 2.3: (Optional) Create a Lambda Function Authored in Java