AWS Builder Center
Day 45: Observability – CloudWatch Logs Insights, Tracing with OpenTelemetry and X-Ray, and Application Signals

Day 45: Observability – CloudWatch Logs Insights, Tracing with OpenTelemetry and X-Ray, and Application Signals

Day 45 of my 90-day AWS challenge: how logs, metrics, and traces work together to find the cause of a problem, how to query logs with CloudWatch Logs Insights, and why AWS now recommends OpenTelemetry for tracing, with Application Signals on top.

Recap of Day 44

Backups let me recover after something goes wrong. Observability helps me find out what is going wrong, and why, while it is happening. On Day 9 I met CloudWatch metrics, logs, and alarms. Today I go further, because an alarm only says that something is wrong.

The three pillars

Signal
What it tells me
Example
Metrics
Numbers over time
Error rate, latency, CPU
Logs
Detailed events
 ERROR Payment failed for order 123 
Traces
The path of one request across services
API Gateway → Lambda → DynamoDB, with the time spent in each
A typical investigation uses all three: an alarm (metric) fires, a trace shows which service is slow, and the logs of that service show the cause.

CloudWatch Logs Insights

Logs Insights lets me search and analyze log groups with a query language, with results in seconds.
Find the 20 most recent errors:
fields @timestamp, @message
| filter @message like /ERROR/
| sort @timestamp desc
| limit 20
Count errors in five-minute buckets:
filter @message like /ERROR/
| stats count(*) as errors by bin(5m)
Tips:
  • Structured (JSON) logs are much easier to query than free text, because fields can be filtered directly
  • Choose the time range and the log groups before running, because queries are billed by the amount of data scanned
  • Queries can be saved and added to a dashboard (Day 9)

Other useful log features

  • Metric filters turn a log pattern, such as  ERROR , into a metric that an alarm can watch (Day 9)
  • Subscription filters stream logs to Firehose or Lambda (Day 31), for example into S3 for Athena (Day 29)
  • Retention settings control how long logs are kept and how much they cost (Day 9)

Tracing

A trace follows one request through every service it touches. It is made of spans (called segments and subsegments in X-Ray), each recording one operation and its duration. A trace ID is passed from service to service so the pieces can be joined.

AWS X-Ray

X-Ray stores traces and shows a service map of how my services call each other, with latency and error rates on each link. It works with Lambda (Day 8), API Gateway (Day 15), and other services.

OpenTelemetry is now the recommended way

  • The X-Ray SDKs and daemon entered maintenance mode on February 25, 2026: they get security fixes only, and no new features
  • The X-Ray service itself is still supported, and AWS recommends OpenTelemetry (OTel) to instrument applications and send traces to it
  • OpenTelemetry is an open standard, so the same instrumentation works with other tools too
  • AWS provides the AWS Distro for OpenTelemetry (ADOT) and support in the CloudWatch agent, and Transaction Search to explore trace data
For a new project, I should choose OpenTelemetry rather than the older X-Ray SDK.

CloudWatch Application Signals

Application Signals builds on OpenTelemetry to give an application-centric view:
  • Automatic instrumentation for supported languages, including Java, without changing code
  • Standard metrics for each service and operation: request count, latency, and errors
  • A service map of applications and their dependencies
  • Service level objectives (SLOs): targets such as "99.9% of requests succeed", with alerts when they are at risk
  • Links from a problem to the related traces and logs
It supports Lambda, ECS, EKS, and EC2.
For a Java application, auto-instrumentation typically means starting it with the AWS OpenTelemetry agent and a few settings. This is an illustrative sketch, and the exact files and variables are in the Application Signals documentation:
export OTEL_RESOURCE_ATTRIBUTES="service.name=my-java-service"
export OTEL_AWS_APPLICATION_SIGNALS_ENABLED=true
java -javaagent:aws-opentelemetry-agent.jar -jar app.jar

Other CloudWatch tools

  • Synthetics canaries: scripts that test an endpoint on a schedule, like a robot user
  • Real User Monitoring (RUM): performance data from real browsers
  • Container Insights and Lambda Insights: deeper metrics for containers and functions
  • Composite alarms: combine several alarms to reduce noise
  • Cross-account observability: view data from many accounts in one place, which suits the multi-account setup from Day 40

A debugging walk-through

  1. An alarm on the error rate fires and sends a notification through SNS (Days 9 and 13)
  1. The dashboard shows errors started after a deployment
  1. The service map shows the checkout service calling a slow database
  1. A trace shows most of the request time is spent in one query
  1. Logs Insights on that service reveals the exact error message, so I can fix it

Cost

Observability data adds up: log ingestion and storage per GB, custom metrics, trace data, and Application Signals each have charges. Set retention on every log group, use sampling for traces, be careful with verbose debug logging, and set a budget (Day 26).

How it connects to earlier days

  • Day 9: alarms, dashboards, and retention are the base
  • Day 8 and 15: Lambda and API Gateway can send traces
  • Day 17 and 37: container logs and metrics flow to CloudWatch
  • Day 20: CloudTrail answers who did what, while observability answers how the system behaved

What I practiced today

  1. Ran Logs Insights queries on the logs of a small Lambda function
  1. Created a metric filter for errors and an alarm on it
  1. Enabled active tracing on a Lambda function and viewed a trace and the service map
  1. Explored the Application Signals setup screen without leaving agents running
  1. Deleted the log groups, filters, alarms, and test functions afterwards

Key takeaways

  • Metrics say that something is wrong, traces say where, and logs say why
  • Structured logs and a trace ID in every log line make investigations much faster
  • For new tracing work, use OpenTelemetry, because the X-Ray SDKs and daemon are in maintenance mode
  • Set log retention and trace sampling, because observability data has a real cost

Up next: Day 46

Security services: Amazon Inspector, Amazon Macie, and AWS Security Hub.
Learning AWS too? Follow along and share what you're building. #90DaysOfAWS
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article