APM & Distributed Tracing Fundamentals Certification / 04 / 04

Troubleshooting Applications Using APM

What this domain covers

In this domain, you learn how to use Datadog APM while an incident is in progress and how to set up detection. The first half is Using Trace Search (during incident). It covers the procedure of narrowing down all ingested spans of the last 15 minutes in Live Search by customer ID or error, finding the spans that raised errors and the places where execution time concentrates in the flame graph, moving to correlated logs, and following the scope of impact in the Service Map. The second half is Monitors & Alerting. It covers the differences between APM Metrics monitors based on trace metrics, Trace Analytics monitors that count indexed spans, and Error Tracking monitors that fire per Issue, as well as Downtime and linking monitors to the Service page. The exam asks questions such as which screen to use in a given situation, what a given monitor evaluates, and why a monitor does not fire.

Topics listed in the official guide

  • Using Trace Search (during incident)
  • Monitors & Alerting

Key points

  • Live Search shows all ingested spans of the last 15 minutes without sampling and matches on any tag of any span. During an incident, you can follow every request of a specific customer.
  • In searches, reserved attributes such as env, service, and status are written without @, while attributes added by instrumentation (for example @customer.tier) are written with @.
  • The Trace Explorer surfaces tags that Watchdog determined to appear statistically skewed toward errors or high latency, in the OUTLIERS section of the facet list and as search suggestions.
  • The flame graph can highlight error spans with Errors under Filter Spans. The Logs tab at the bottom lets you move to correlated logs from the same time.
  • Logs and traces are linked through injection of the trace ID and similar fields, but the two are sampled independently. A trace ID in a log with no corresponding trace is not a misconfiguration.
  • Red or yellow node borders in the Service Map represent Service Health, and in the inspection view the left side is closer to the customer while the right side is more likely to be the root cause.
  • APM Metrics monitors watch request count, error count, Apdex, error rate, and p50 to p99 latency with a threshold or anomaly detection.
  • The evaluation source of a Trace Analytics monitor is indexed (retained) spans, not all ingested spans.
  • Error Tracking monitors have two conditions, New Issue and High Impact, and the intended use is a multi alert that notifies per Issue.
  • A Downtime only stops notifications and does not stop monitor status transitions. Adding service:<SERVICE_NAME> to the group scope silences only the portion for a specific service.

Terms and concepts

Live Search during an incident

The first thing to open during incident response is Live Search in the Trace Explorer. Spans just sent by the Agent are all displayed in a rolling window of the last 15 minutes, before they are selected by retention filters. The official documentation positions this property for use cases such as searching 100% of ingested traces for a problem tied to a specific org_id or customer_id, or checking by version_id whether a new deployment is healthy. In high-throughput environments only a subset of spans is drawn on the screen, but the search query is evaluated against all spans.

Building filter queries

When narrowing down errors or slow requests, the key point is distinguishing reserved attributes from everything else. Reserved attributes such as env, service, status, and resource_name are written without @, while attributes added by instrumentation are written with @, as in @customer.tier:gold. Numeric attributes can be narrowed down with ranges or comparisons such as @http.status_code:[500 TO 599], and - excludes. In addition, Group by with up to 4 dimensions lets you compare REQUESTS, ERRORS, and P95 Latency per group, and Latency Breakdown shows which service the time is spent in.

Outliers surfaced by Watchdog

The Trace Explorer combines Watchdog outlier detection with tag analysis to automatically find tags that appear statistically skewed toward spans with errors or high latency. Suggestions in the search bar are marked as correlated with errors or latency, the relevant facets are highlighted among the Group by candidates, an OUTLIERS section is gathered at the top of the facet list, and the Analyze button next to the error and latency graphs is highlighted. During an incident, this is a shortcut to forming a hypothesis about which version, which AZ, or which customer the problem is skewed toward. Watchdog itself requires no configuration; it is the Datadog mechanism that detects deviations from the baseline.

Pinpointing the cause in the flame graph

When you open a single trace, the flame graph is displayed by default; the parent-child relationships of calls are read from top to bottom and the duration from the width. In the legend, you can group by Service (default), Base service, Host, or Container, and display either % Exec Time or Spans (span count) per group. In a trace that has errors, checking Errors under Filter Spans highlights only the error spans, so you can quickly find the failure point buried deep in the hierarchy. The Logs tab at the bottom lists correlated logs from the same time.

Correlating logs and traces

You can move from a trace to its logs because the trace ID, span ID, env, service, and version are injected into the logs as attributes. As a prerequisite, the logs must be parsed as JSON or by a language-specific log processor and turned into Datadog attributes. The point to note is that traces and logs are sampled independently. When a log has a trace ID but the corresponding trace cannot be found, it simply was not ingested or retained, and this is not necessarily a misconfiguration.

Following the scope of impact in the Service Map

The Service Map draws the dependencies between services in real time from APM and RUM data. Red or yellow node borders are the Service Health status, a signal that consolidates Watchdog anomalies, alerts from monitors with paging integrations, and ongoing incidents into one. When you click a service to enter the inspection view, only its callers and callees remain; the left side is closer to the customer, and the right side holds the services more likely to be the root cause. You view the map by switching env. A node disappears when it has had no traces for 30 days. When you add a service tag to a monitor, its status is displayed on the map.

APM Metrics monitors

There are two kinds of APM monitors: APM Metrics and Trace Analytics. APM Metrics is scoped by the primary tag (env), service, and resource, and targets request count, error count, Apdex, error rate, and average plus p50, p75, p90, and p99 latency. The condition is either Threshold or Anomaly, and the evaluation window is a default such as 5 minutes or a custom value from 1 minute to 48 hours. Because it is based on trace metrics, it can monitor the service as a whole regardless of sampling and retention filter settings.

Trace Analytics monitors

A Trace Analytics monitor counts the spans that match a query written in the same syntax as trace search, and compares the count, the number of unique values of a facet, or an aggregate of a measure (min, avg, sum, median, pc75 to pc99, max) against a threshold. You can group by up to 4 facets, and with a multi alert a notification is sent per group. The evaluation source is indexed (retained) spans, not all ingested spans. When you want to know that spans have stopped coming from a group, set the condition to below 1.

Error Tracking monitors

Error Tracking monitors fire per Issue. New Issue fires when an Issue in the For Review status occurs for the first time or regresses, and High Impact fires when an Issue in For Review or Reviewed has a large impact. When the target is All or Backend, the only available metric is Error Occurrences. The default evaluation window is 1 day, and the default threshold is 0, so it fires from the first occurrence. The intended use is a multi alert that notifies per Issue, and Issues set to Ignored are muted.

Downtime and linking to the Service page

To prevent false alarms during planned work, schedule a Downtime. A Downtime only silences notifications and alerts; it does not stop monitor status transitions. You select the targets by monitor name or monitor tag, and by adding a condition such as service:web-store to the group scope, you can mute only the portion for that service even on a monitor shared by all services. If the alert state persists at the moment of expiry, a notification is sent. When service:<SERVICE_NAME> is included in the monitor's tags or query, or the query is grouped by service, that monitor is reflected in the Service monitor section of the Service page.

Check your understanding

Check what you have learned with 5 questions