Dynatrace Log Monitoring gives you the ability not only to view and analyze logs, but also to create metrics based on log data and use them throughout Dynatrace like any other metric. You can add them to your dashboard, include them in an analysis, and even create custom alerts.
Log metric pricing is based on the Davis data units (DDUs) model. Check DDUs for custom metrics to find out how you can estimate and track DDU consumption for log metrics.
Depending on the options you select during log metric creation, the new metric value can represent:
- Occurrence of log records (available in Dynatrace version 1.206+)
The metric value will represent a count of occurrences of log records that match the query.
- Attribute value (available in Dynatrace version 1.229+)
The metric value can represent one of the aggregations that you can specify in Data explorer.
When Dynatrace ingests log data, it applies the defined query to the log data and, based on your log metric Measure selection, the metric value will therefore represent either a count of the log records that match the query or one of the following values for the specified attribute:
Percentile 75th, or
Percentile 90th. The specified attribute must be of numeric type. Dynatrace will attempt to convert string type attributes to numbers as long as they match the following pattern:
Attributes holding more than one value are not converted to attribute-based metrics.
Creating log metric
All metrics based on a Log Monitoring query have a metric key with the
A created log metric is available only when new log data is ingested and it matches the log query defined during log metric creation. Ensure that new log data has been ingested before utilizing the log metric in other areas of Dynatrace.
There are two ways to create a metric based on log data:
Create metric using settings
- Go to Settings > Log Monitoring > Log metrics and select Add log metric.
- In Key, append the metric name to the
- In Query, enter the Log Monitoring query to filter the log data for your metric. For details, see Log viewer.
- Select a Measure:
- Occurrence of log records—a count of occurrences of log records that match the query.
- Attribute value—the collection of measures for the attribute value of log records that match the query. If you select this option, you need to also set Attribute to the attribute whose values will be gauged.
- optional Select Add dimension one or more times to add dimensions for your query result.
Adding dimensions allows you to split the log metric occurrences by a specific log data attribute. If the attribute contains more than one value, the first attribute value will act as the metric dimension. For details, see Log viewer.
- Select Save changes to create the log metric.
Create metric using log viewer
- In the Dynatrace menu, go to Logs.
- Create a log viewer query or use log viewer facets to extract the log data that interests you. For details, see Log viewer.
In the advanced mode, you can specify more complex criteria for log events by using combinations of keywords, phrases, logical operators, and parentheses. If you use an advanced query and manually modify the query, select Run query to update the results table.
- Select Create metric. Your log viewer query is now displayed on the Log metrics page.
- Optionally, add dimensions for your query result.
Adding dimensions allows you to split the log metric occurrences according to specific log data attribute. For details, see Log viewer.
- Append the metric name to the metric key
log.and save changes to create the log metric.
Editing log metric
To list, enable, disable, delete, or modify metrics created from log data, go to Settings > Log Monitoring > Log metrics.
Editing a metric key will generate a new metric. As a result, historical data will be accessible only with the old metric key.
In this example, we create and chart a log metric, save it to a dashboard, and create an alert.
- In the Dynatrace menu, go to Logs to display the log viewer.
- Create a query that filters the data that you are interested in. For this example, to filter all log entries for
error, enter this query:
- Select Create metric.
The Log metrics page is displayed with Query set to your query.
- Type in the metric key (a unique name for the metric). By default, each metric key begins with
log.prefix. All log metrics based on logs must have a key starting with this prefix.
For this example, set key to:
- Select Add dimension and then select the
dt.entityprocess_group_instancedimension from the list.
Note: If you saved the metric without adding a dimension, Dynatrace would count errors globally. But in this example, we want to see how the error status is distributed across process group instances. Adding the
dt.entityprocess_group_instancedimension will make Dynatrace count the number of error statuses for each process group instance. This allows you to view precisely where the error status occurred and to create an alert for a particular dimension.
- Save changes.
Now that you have defined the metric, you can chart it, pin it to a dashboard, and even create an alert based on it.
- Chart: Go to Explore data, set Select metric… to
log.error_PGI, and select Run query.
- Dashboard: After you create a chart, select Pin to dashboard to add the chart to one of your dashboards.
- Alert: Go to Settings > Anomaly detection > Custom events for alerting, select Create custom event for alerting, and create a custom event based on