Generate Metrics from Spans

이 페이지는 아직 영어로 제공되지 않습니다. 번역 작업 중입니다.
현재 번역 프로젝트에 대한 질문이나 피드백이 있으신 경우 언제든지 연락주시기 바랍니다.
Span-based metrics

Generate custom metrics from ingested spans to track trends, power dashboards, and trigger monitors—even for spans that are not retained for full trace analysis.

Span-based metrics are created from spans that have been ingested by Datadog APM, regardless of whether those spans are indexed by a retention filter. These metrics allow you to extract numeric values (such as counts, durations, or custom tags) from spans and store them as long-lived custom metrics with a 15-month retention period.

Note: The set of spans available for metric generation depends on your APM ingestion control settings. Spans dropped due to sampling or filtering are not ingested, and therefore cannot be used to generate metrics.

Use span-based metrics when you:

  • Need long-term visibility into span-level patterns, such as request volume, latency, or error rates
  • Want to power anomaly or forecast monitors with low-latency, high-resolution metrics
  • Don’t need to retain the full trace, but want to extract key signals for trending or alerting

Span-based metrics are considered custom metrics and are billed accordingly. To avoid high costs, do not group metrics by high-cardinality values such as user IDs or request IDs.

Create a span-based metric

How to create a metric
  1. Define the metric query: Start by adding a query for filtering to your required dataset. The query syntax is the same as APM Search and Analytics.

  2. Define the field you want to track: Select * to generate a count of all spans matching your query or enter an attribute (for example, @cassandra_row_count) to aggregate a numeric value and create its corresponding count, minimum, maximum, sum, and average aggregated metrics. If the attribute type is a measure, the value of the metric is the value of the span attribute.

    Note: Span attributes that are not numerical values cannot be used for aggregation. To generate a metric that counts the distinct values of a span attribute (for instance count the number of user IDs hitting a specific endpoint), add this dimension to the group by selector, and use the count_nonzero function to count the number of tag values.

  3. Specify the group-by dimension: By default, metrics generated from spans will not have any tags unless explicitly added. Any attribute or tag that exists in your spans can be used to create metric tags.

  4. Check the Live Analytics and Search Query preview: You can view the impact of your query in real-time on the data visualization, and the matching spans considered for your query in a live preview.

  5. Name your metric: Metric names must follow the metric naming convention. Metric names that start with trace.* are not permitted and will not be saved.

Span-based metrics are considered custom metrics and billed accordingly. Avoid grouping by unbounded or extremely high cardinality attributes like timestamps, user IDs, request IDs, or session IDs to avoid impacting your billing.

Update existing span-based metrics

Edit an existing metrics

After a metric is created, only two fields can be updated:

FieldReason
Stream filter queryChange the set of matching spans to be aggregated into metrics.
Aggregation groupsUpdate the tags to manage the cardinality of generated metrics.

Note: To change the metric type or name, create a new metric and delete the old one.

Further Reading

PREVIEWING: patrickliang/add_double_dash_on_cluster_agent_commands