Skip to main content
In this lesson you’ll learn how to perform real-time log analysis using AWS CloudWatch Logs Insights Live Tail and structured queries to inspect logs produced by an AWS Lambda function. This workflow is ideal for troubleshooting, debugging cold starts, or verifying application behavior as events arrive.

What you’ll do

  1. Open CloudWatch Log Analytics (Logs → Log Analytics).
  2. Select the Lambda log group you want to examine.
  3. Use Live Tail for near real-time visibility while invoking the Lambda.
  4. Switch to Logs Insights to run structured queries and filters to analyze results.
Start by opening the AWS CloudWatch console and navigating to Log Analytics under Logs. To get an initial catalog of the log data, use a Logs Insights SOURCE query like this:
Once you’ve chosen the correct data source, switch to Log groups if needed and then select the AWS Lambda log group you are working with (for this demo, select the /aws/lambda/xray-demo log group). Click outside the dropdown to confirm the selection.
A screenshot of the AWS CloudWatch Log Analytics console showing a "Log group" dropdown with several Lambda log groups (e.g., /aws/lambda/xray-demo) and time-range controls. The query/filter area and account/region header are also visible.

Enable Live Tail (near real-time streaming)

With the log group selected, enable Live Tail in CloudWatch Logs Insights to view new log events as they are ingested. Live Tail establishes a streaming connection to the selected log stream and displays new entries as they arrive. Example SOURCE for a specific log-group ARN:
Click Live Tail and wait for the connection to establish. While Live Tail is running, generate activity from your Lambda function to populate the stream:
  • Open the AWS Lambda console.
  • Select the function (XRayDemo).
  • Invoke it via the Test button (each invocation creates new log events).
Screenshot of the AWS Lambda console on the Test tab for a function named "xray-demo," showing a green "Executing function: succeeded" message. The page displays test event options and buttons like Delete, CloudWatch Logs Live Tail, Save, and a highlighted Test button.
As invocations occur, Live Tail will display entries similar to the following:
Live Tail is excellent for troubleshooting because it shows initialization, start/stop events, and REPORT lines (duration, billed duration, memory) as they happen.

Analyze with Logs Insights queries

While Live Tail is useful for immediate visibility, Logs Insights lets you run structured queries to aggregate, filter, and pivot on log data across time windows. You can keep Live Tail open in one tab and open Logs Insights in another. A common starting query is to show timestamp and message, newest first:
Running that query returns a concise list of recent log events:

Filtering for specific tokens

Filtering narrows results to events that matter. For example, find ERROR messages:
If no results appear, try filtering for other tokens that you know exist (for example, START):
A successful START filter returns lines such as:

Quick reference — Logs Insights building blocks

Best practices and troubleshooting tips

  • Use Live Tail for interactive debugging and quick feedback during tests or incident response.
  • Run Logs Insights queries to aggregate across many events and identify patterns (e.g., error rates, latencies).
  • Parse REPORT, START, and INIT lines to extract runtime metrics (duration, memory usage, cold start indicators).
  • If filters return zero results, broaden the time range or remove the filter to confirm expected tokens exist.
  • Save useful queries and pin dashboards for recurring investigations.
Takeaways
  • Live Tail (Logs Insights) provides near real-time visibility of incoming log events — ideal for immediate troubleshooting.
  • Logs Insights supports flexible, powerful queries (fields, filter, sort, limit, parse, stats) to analyze logs at scale.
  • Use filters and parsing to focus on error messages, lifecycle events (START/INIT/REPORT), or custom application markers.
Use Live Tail for immediate visibility during testing or incident response, then run Logs Insights queries to aggregate and analyze patterns across many events.

Watch Video

Practice Lab