Introduction to creating metric data from non-metric data
You can generate metric-type data from other types of data in New Relic, including events, logs, and spans. Metrics are aggregates of your data and are optimal for analyzing and monitoring trends over long time periods.
Using metrics allows for more efficient data storage. This in turn allows you to query your data and build charts more easily. The difference between metrics and other types of data in New Relic is based on time. For more information, see Understand data types.
Events, logs, spans: These types of data represent a single record at a specific moment in time. For example, you may have an event for every request to the system. This data is ideal for in-depth troubleshooting and analysis.
Metrics: These provide an aggregated view of your events, logs, or spans. Metrics are better for showing trends over longer time ranges. For example, you can aggregate the total number of requests per service to one metric and then examine this information month over month.
Why use metrics?
Metrics are dimensional. You can choose what metadata (like host name or app name) is attached to them.
Common metric measurements, like average, sum, minimum, and maximum, are already calculated.
Data aggregation and retention
The data has already been pre-aggregated into longer-period time buckets.
To show, create, and delete rules for generating metrics from events, logs, or spans, use NerdGraph, our GraphQL-format API. Before performing any operation, we recommend reading Intro to NerdGraph and exploring your data with the GraphiQL API tool.
Here you define the data returned by a success or failure. Available parameters for these blocks:
id (or ruleId for submitted)
Example response for the request:
"name": "Test Rule",
"nrql": "select summary(duration) as 'server.responseTime' from Transaction where appName = 'Data Points Staging' facet name, appName, host"
This operation modifies production settings, so we recommend thoroughly reviewing your changes before you run the operation.
To enable or disable an existing rule for events to metrics, logs to metrics, or spans to metrics, use the same eventsToMetricsUpdateRule operation. The only difference is whether enabled is set to true or false.
Example request to enable an existing metrics rule: