Query infrastructure dimensional metrics with NRQL


Dimensional metrics are an industry standard for storing and querying metric data. All infrastructure metrics are stored as event data in New Relic, but you can also query them through dimensional metrics.

In this page you can learn:

Why it matters

At New Relic we report metrics in several ways, including dimensional metrics, which are used by our metric API, Telemetry SDK, some open-source integrations, and our infrastructure services.

This type of metric enables you to:

  • Enjoy an improved query experience for Infrastructure data.
  • Discover all your metrics in one place.
  • Tap into more metric sources, such as Prometheus.

For example, the query to get the maximum duration of your Lambda functions is simplified:

Query with samples
FROM ServerlessSample
SELECT max(provider.duration.Maximum)
WHERE provider = ‘LambdaFunction’
Query with metrics
FROM Metric
SELECT max(aws.lambda.function.duration)

Get started

No agent or integration updates are required to use these metrics.

NRQL alerting based on dimensional metrics is also supported, except for data coming from cloud integrations (that is metrics from AWS, GCP, and Azure).

Where and how to query dimensional metrics

All current NRQL query features are supported. Queries can use WHERE, FACET, and time selection functions such as SINCE, UNTIL, and COMPARE WITH.

The query builder in New Relic One supports metrics in both simple and advanced (NRQL) mode.

Naming conventions for metrics and attributes

All metric names and attributes for dimensional metrics follow the same naming convention in order to make them easy to find and use. Metric and attribute names are namespaced with dots: for example, the host. prefix is used for host metrics, the k8s. prefix is used for Kubernetes metrics, and aws. is used for AWS metrics.

The graphic below shows how a ProcessSample that contains three metrics (cpuPercent, ioTotalReadBytes, and ioTotalWriteBytes) is split into three separate metrics. Note the updated naming of the metrics and the attributes.

Dimensional metrics naming convention


Here are some examples of NQRL queries with and without dimensional metrics:

AWS EBS query example

Get the total write time by EBS Volume.

Query with samples
FROM BlockDeviceSample
SELECT sum('provider.volumeTotalWriteTime.Sum')
WHERE provider = ‘EbsVolume’
FACET entityName
Query with metrics
FROM Metric
SELECT sum(aws.ebs.volume.TotalWriteTime)
FACET entity.name
Azure Service bus query example

Maximum number of messages in an Azure Service Bus topic by resource group.

Query with samples
FROM AzureServiceBusTopicSample
SELECT max(activeMessages.Maximum)
FACET resourceGroupName
Query with metrics
FROM Metric
SELECT max(azure.servicebus.topic.activeMessages)
FACET azure.resourceGroup
Azure functions query example

Number of function executions Azure Functions over the past 6 hours by region over time.

Query with samples
FROM AzureFunctionsAppSample
SELECT sum(functionExecutionCount.Total)
FACET regionName
Query with metrics
FROM Metric
SELECT sum(azure.functions.app.functionExecutionCount)
FACET azure.region
Azure VMs query example

Compare the number of Azure VMs over the past thirty minutes with the same time a week ago.

Query with samples
FROM AzureVirtualMachineScaleSetSample
SELECT uniqueCount(vMName)
FACET name
Query with metrics
FROM Metric
SELECT uniqueCount(azure.vms.vmName)
FACET azure.resourceName
WHERE azure.resourceType='Microsoft.Compute/virtualMachineScaleSets'
NGINX query example

The average number of NGINX requests per second over time.

Query with samples
FROM NginxSample
SELECT average(net.requestsPerSecond)
Query with metrics
FROM Metric
SELECT average(nginx.server.net.requestsPerSecond)
MySQL query example

The maximum number of used MySQL connections.

Query with samples
FROM MysqlSample
SELECT max(net.maxUsedConnections)
Query with metrics
FROM Metric
SELECT max(mysql.node.net.maxUsedConnections)

Known limitations

  • Metric queries with * do not return Infrastructure sample data (for example, SELECT * FROM Metric).
  • In order to select attributes starting with tags. a metric name has to be provided. For example, SELECT uniques(tags.environment) FROM Metric WHERE metricName=’aws.lambda.function.duration’ does not work without the WHERE clause.
  • Results may not be complete if the selection criteria matches too many samples. For example, SELECT uniqueCount(entity.guid) FROM Metric maps to all Infrastructure samples, and may return incomplete results.
  • Initially there is no support for the newly introduced metric wildcarding feature (for example, SELECT average(host.swap%Bytes) FROM Metric).

For more help

If you need more help, check out these support and learning resources: