Courseiva
Monitoring and Logging →hardMultiple Choice

DOP-C02 Monitoring and Logging Practice Question

A company runs a containerized application on Amazon ECS Fargate. The DevOps team wants to collect custom application metrics (e.g., request count, error rate) and send them to Amazon CloudWatch. The team wants to minimize changes to the application code. Which solution should be used?

⚠ Common exam trap

It's easy for candidates to assume the ECS agent or CloudWatch agent must be installed on the host, but in Fargate, the sidecar pattern is the only way to run the CloudWatch agent without modifying the application code.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Run the CloudWatch agent as a sidecar container in the ECS task definition, configured to collect StatsD metrics from the application container.

The CloudWatch agent can run as a sidecar container in the same ECS task definition and listen for StatsD metrics (over UDP port 8125) from the application container. This approach requires zero changes to the application code—the application simply emits StatsD-formatted metrics, and the CloudWatch agent forwards them to CloudWatch via the PutMetricData API. It minimizes operational overhead while enabling custom metric collection from containerized workloads on Fargate.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Have the application call the CloudWatch PutMetricData API directly.

    Why it's wrong here

    Calling the CloudWatch PutMetricData API directly requires embedding the AWS SDK into the application and adding instrumentation code at every metric emission point. This couples business logic to AWS-specific API calls, forces you to manage credentials, batching, and retries, and is exactly the code change the requirement rules out. It also prevents using a standard agent-based collection layer, making the solution brittle and hard to migrate.

  • ✓

    Run the CloudWatch agent as a sidecar container in the ECS task definition, configured to collect StatsD metrics from the application container.

    Why this is correct

    The CloudWatch agent can run as a sidecar container in the same ECS task, and with the default awsvpc network mode all containers share a localhost network namespace. Configure the agent with a StatsD stanza so it listens on port 8125, and the application simply sends UDP messages in the StatsD format—no SDK, no logging changes, and no application code modifications. The agent buffers, batches, and forwards these metric points to CloudWatch as a single API consumer, preserving the existing application behavior.

  • ✗

    Use the ECS agent's built-in metric collection feature.

    Why it's wrong here

    The ECS agent (or in Fargate, the underlying managed infrastructure) only exposes container-level telemetry such as CPU utilization, memory usage, and network I/O from Docker runtime stats. It has no mechanism to parse StatsD, StatsD-like UDP payloads, or any application-defined counters and gauges. Custom application metrics, especially those based on application logic or dimensions, are simply outside the scope of what the ECS agent collects, so relying on it leaves the needed metrics unavailable.

  • ✗

    Modify the application to send logs using the embedded metric format.

    Why it's wrong here

    The embedded metric format (EMF) is a powerful pattern that turns structured logs into CloudWatch metrics, but it requires the application to rewrite its logging calls to emit JSON documents with a specific _aws section containing the metric definitions. This is a code change to the application's logging layer and a change to operational behavior, which the requirement explicitly prohibits. Additionally, when running on Fargate you typically need the CloudWatch agent or a separate EMF exporter to decode the logs, so it is not simpler than the sidecar approach.

About these practice questions

Courseiva writes every DOP-C02 question from scratch — 1,298 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This DOP-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DOP-C02 exam.