Arkinu
AWS service comparison

Amazon CloudWatch vs AWS X-Ray: differences and when to use each

Amazon CloudWatch
AWS X-Ray

Often confused on the examQuestions tend to offer one as a distractor for the other: look for the phrase in the scenario that tips the balance.

Management and Governance

Amazon CloudWatch

Service for monitoring AWS resources and applications in real time. It collects metrics and logs, displays dashboards, and triggers alarms that notify you or take actions when a threshold is breached.

Exam phrases that point here

  • «monitor performance metrics and get an alert when a threshold is exceeded»

    CloudWatch collects metrics from AWS resources and applications, and its alarms compare each metric against a threshold to send a notification (for example, with Amazon SNS) or take action.

    When not: If the question is who made an API call or which user changed something, the clue points to AWS CloudTrail; if it is whether a resource's configuration complies with a policy, to AWS Config.

  • «collect memory and disk metrics from EC2 instances»

    The metrics that EC2 sends by default are measured from outside the instance. For guest operating system metrics, such as memory or disk usage, you install the CloudWatch agent, which also works for on-premises servers.

    When not: If what is asked for is the API calls on those instances, it is CloudTrail. And if the team wants container metrics in Prometheus format queried with Prometheus tools, Amazon Managed Service for Prometheus may be a better fit.

  • «centralize application logs and query them interactively»

    CloudWatch Logs receives logs from the agent and from many AWS services, and CloudWatch Logs Insights lets you query them without any prior preparation.

    When not: If the record of interest is the account's API call history for auditing, it is CloudTrail. If the question asks for full-text search and large-scale log analytics dashboards, Amazon OpenSearch Service may also appear.

  • «automatically stop, reboot, or recover an EC2 instance when a check fails»

    An alarm on an EC2 metric can directly run an action on the instance: stop it, terminate it, reboot it, or recover it.

    When not: If the goal is to replace unhealthy instances within a fleet, this is usually done by an Amazon EC2 Auto Scaling group with its health checks, not an alarm per instance.

  • «count the number of times an error appears in the logs and alert when it keeps happening»

    A metric filter turns the log lines that match a pattern into a CloudWatch metric, and an alarm is created on that metric.

    When not: The metric filter only counts events after its creation. If the error to detect is a specific API call (for example, deleting a trail), you can react to the CloudTrail event with Amazon EventBridge.

Often paired with

  • Amazon SNS
  • Amazon EC2 Auto Scaling
Study Amazon CloudWatch →

Developer Tools

AWS X-Ray

On the radar· The X-Ray SDKs and daemon are in maintenance mode

Tracing service that collects data about the requests your application serves and about the calls it makes to other services, databases, and APIs. With its trace map, it helps you find bottlenecks, latency spikes, and other issues.

Exam phrases that point here

  • «follow a request end to end across multiple microservices»

    X-Ray gathers, under a single trace ID, the data sent by each service the request touches, so you see the full path and how long each hop takes.

    When not: If what is asked for is metrics, alarms, or logs for a resource, the answer is Amazon CloudWatch; and if it is who made an AWS API call, AWS CloudTrail.

  • «see a map of the application's services with the latency and errors between them»

    With the segments it receives, X-Ray builds a service graph: each component is a node and each call is an edge with its latency and errors.

    When not: An infrastructure diagram (VPC, subnets, deployed resources) is not a trace map: the trace map shows only what requests actually travel through, and it requires instrumenting the application or turning on tracing in the services.

  • «find which component of a distributed application is causing the slowness or errors»

    In the trace you can see the time of each segment and subsegment and which hop returns errors (4xx), faults (5xx), or throttling (429), with the exception stack trace if there is one.

    When not: If the suspected cause is a lack of capacity in a resource (CPU, memory), look at the CloudWatch metrics; if the goal is to adjust the size of the resource (rightsizing), look at AWS Compute Optimizer.

  • «filter traces by a business value, such as the customer ID»

    Annotations are indexed key-value pairs that can be used in filter expressions and in groups.

    When not: Metadata is also stored in the trace, but it is not indexed: it cannot be used for searching. X-Ray indexes at most 50 annotations per trace.

  • «reduce the volume and cost of traces without losing sight of problems»

    Sampling rules decide what fraction of requests is traced: by default, the first request each second and 5% of the rest, and they can be tuned by service, route, or method.

    When not: The sampling decision is made only once, at the first service that handles the request: a rule defined for a downstream service does not apply. In Lambda the sampling rate is not configurable.

Often paired with

  • AWS Lambda
  • Amazon API Gateway
Study AWS X-Ray →