Datadog Logs to Metrics - Keep the Counts Before Dropping Logs

The feature that generates metrics from logs works on all ingested logs, rolling up counts and numeric attributes into points every 10 seconds, so you can keep 15 months of trends even after discarding the logs themselves. This guide walks through how to create them, centered on the group by dimensions that determine the number of metrics and on how they are ordered relative to exclusion filters.

Keep the log text, or keep only the numbers

If you turn logs into metrics, you can graph trends in counts and values without putting the original logs into an index. The granularity is 10 seconds, and the data is kept for 15 months (as of October 2026; source: Generate Metrics from Ingested Logs). On the other hand, uses that involve rereading individual entries later cannot be replaced with numbers, so those logs have to be kept as logs. The dividing line is whether the questions you ask of a log can be answered with "how many" and "how large a value," or whether you need "what happened." In the author's view, sorting your questions into the following three before deciding what to create helps you avoid both creating too much and keeping too much.

Questions asked of logs and the form to keep (as of October 2026)
QuestionForm to keepExample
How many occurredA count metric (* as what to count)The number of logs whose status is error
How large a valueA distribution metric built from a numeric attributeThe p95 of request processing time
What happenedKeep as logs in an indexError text reread during incident investigation
Organized based on Generate Metrics from Ingested Logs

Logs that fall into the top two rows of the table are candidates for removal from index storage after you create metrics. The setting for removing them is covered in the Exclusion Filter glossary entry. With metrics in place, you can keep watching increases and decreases in errors and changes in latency with monitors even after narrowing what you store, which makes it easier to commit to reducing log volume.

Three things to decide on the generation screen - query, what to count, and name

You create them on the Generate Metrics page in the log configuration, starting from + New Metric on the Generate Metrics tab. From search results in Log Explorer's Analytics, you can also reach the same settings with Generate new metric in the Export menu. The search query you write first uses the same search syntax as Log Explorer, but it is evaluated against the ingestion stream, not against indexed logs. Some forms, such as the full-text search *:search_term, cannot be used, and a query that returns results in Log Explorer may match nothing here. Only logs with a timestamp within the past 20 minutes are included in the aggregation (as of October 2026).

  • Narrow down the target logs with a search query
  • Choose what to count (* for a count, a numeric attribute for a distribution)
  • Add the tags to put in group by
  • For a distribution, decide whether you need percentiles
  • Name it following the naming conventions
Source: the procedure in Generate Metrics from Ingested Logs

If you choose * as what to count, the metric becomes the number of logs that match the query. If you choose a numeric attribute such as @network.bytes_written, count / min / max / sum / avg aggregations are built from its values. If that attribute's facet is a measure, the metric's value is the attribute's value itself. Naming follows the same naming conventions as custom metrics (source: Custom Metrics). The type and name cannot be changed after saving; to change them, you create the metric again.

The dimensions in group by determine the number of metrics

Unless you explicitly add them, metrics generated from logs carry no tags. What you can add to group by is attributes or tags present in the logs, and the tag name on the metric side is the attribute name with the leading @ removed. This is the stage where the count grows: each combination of tag values is counted as a separate time series. For example, if env has 2 values and service has 10, there can be up to 20 combinations. Metrics generated from logs are also treated as custom metrics for billing, and how they are counted is summarized in the Custom Metrics glossary entry.

Candidates for group by and their effect on the count (as of October 2026)
Example dimensionNumber of valuesPut in group by
envAs many as there are environmentsCandidate
serviceAs many as there are servicesCandidate
statusAs many as there are levels such as info and warningCandidate
Response codeAs many as the kinds of codes returnedOnly when your question needs it
User ID / request ID / session ID / timestampUnboundedDo not include
Organized based on the warnings in Generate Metrics from Ingested Logs

The last row of the table lists attributes the official documentation explicitly warns against, and time series keep growing as long as their values keep growing. If you accept that questions needing a per-user breakdown are questions to search for on the log side rather than in metrics, the count stays within a range you can estimate. group by can be changed after saving, so you can remove dimensions that have grown too large and keep the count down later. Deciding which dimensions to keep is easier if you work backward from the units by which you want to split the monitors that will alert on that metric.

Adding percentiles to a distribution increases the count by another step

Metrics built from numeric attributes are of the distribution type, and the count / sum / min / max / avg aggregations are each counted per tag combination. Enabling percentile calculation on the creation screen adds p50 / p75 / p90 / p95 / p99, and these are also counted as custom metrics for the same combinations (source: Custom Metrics Billing). Because distributions are aggregated on the server side from the raw values of all hosts, you get percentiles across the whole set rather than an average of per-host values, and they can also be used as thresholds in metric monitors (source: Distributions). Percentiles are effective for watching the slow end of processing time, and how to read them is left to the Percentile glossary entry. After saving, unchecking Calculate percentiles removes only the percentile portion, so starting without them and adding them when needed works fine.

Logs excluded from indexes are still counted at ingestion

Metrics are based on all ingested logs and are counted independently of the decision about whether to store them in an index. The official documentation says that even if you narrow the stored logs with exclusion filters, you can graph trends and anomalies across all logs. The procedure also asks you not to include index conditions in the query. Thanks to this ordering, if you create metrics first and add exclusions later, you can reduce the logs you store while keeping the counts continuous. How many logs are going to exclusion can be checked with the tags on the log usage metrics.

Tags on log usage metrics (as of October 2026)
TagWhat it represents
datadog_indexThe routing query that sent the log to an index
datadog_is_excludedWhether the log matched an exclusion query
serviceThe log's service attribute
status (datadog.estimated_usage.logs.ingested_events only)The log status, such as info or warning
Source: Logs usage metrics in Generate Metrics from Ingested Logs

Logs whose datadog_index and datadog_is_excluded values are N/A were ingested but matched neither any index condition nor any exclusion condition. Splitting the usage metrics by datadog_is_excluded and service shows the volume going to exclusion per service, letting you show in numbers the effect of replacing logs with metrics. If the N/A volume is large, it is also material for reviewing your index routing conditions.

Counts kept for 15 months, and log retention set per index

Logs you assigned to numbers in the opening table can be referenced as metrics for 15 months. In contrast, the retention period of the logs themselves is a per-index setting, chosen from the values your contract allows (source: Indexes). The relationship between retention tiers and cost is covered in the article on how log pricing works. The higher the volume and the fewer the occasions to read entries one by one, the more effective the combination of keeping counts long and holding the text briefly. For example, for load balancer access logs, if you turn the counts per response code and the distribution of processing time into metrics, storing the text for the short period used for investigation is enough. The steps for sending access logs to Datadog are in the article on ingesting AWS access logs. Note that this feature targets logs ingested on the cloud side; for generating metrics from on-premises logs, the official documentation for Observability Pipelines provides guidance.

If the metric line continues after applying exclusions, you can drop the text

The official documentation recommends confirming in Metrics Explorer that data points are appearing before relying on the metric in graphs or monitors. If the query matches in Log Explorer but the metric stays empty, rewrite it with the terms enclosed in quotation marks. The example given is the form message:"Database operation failed.". count unique counts only the values within a 10-second interval. Once points start appearing, place the usage metric datadog.estimated_usage.logs.ingested_events split by datadog_is_excluded on the same dashboard. Then apply an index exclusion to the source logs and watch whether the metric line you created continues without breaks even as the excluded volume rises. Logs whose line continues can be moved to the side you track by numbers even after dropping the text. Widen the exclusion targets in the Log Management UI only after completing this check.

References

Share