Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Relic Solution: NRQL feature release: Aggregate or separate metrics with Wildcards

product
product-update

#1

Who knew one character could make such a huge impact!

TL;DR

What it is: Query multiple metrics using NRQL’s wildcard character (%)

Why

  1. Makes it faster and easier to query and chart multiple metrics together.
  2. Eliminates the need to manually add individual metrics to a query when new metrics are created that follow a similar naming pattern.

How: By using the ‘%’ character to represent a wildcard in the metric name (see Docs site)

Background
Hierarchical naming patterns are commonly used to add structure to metric data and make it easy to understand what a metric is measuring at a glance. For example::

  • jvm.memory.heap.used
  • jvm.memory.heap.committed
  • algorithm.A.duration
  • algorithm.B.duration

With NRQL’s old syntax, charting the average of algorithms A and B (from above) required the following:

FROM Metric SELECT average(algorithm.A.duration), average(algorithm.B.duration) TIMESERIES

Wildcards to the rescue
Let’s say you have the following metrics, which show the duration of different algorithms related to a single process:

  • algorithm.A.duration
  • algorithm.B.duration
  • algorithm.C.duration

Now, you can use wildcarding to query all three algorithms with ease, and facet according to the structure of the rest of the query.

Scenario 1: Aggregate average duration as a single value:

FROM Metric SELECT average(algorithm.%.duration) TIMESERIES

Scenario 2: Facet average duration by metric:

FROM Metric SELECT average(algorithm.%.duration) FACET metricName TIMESERIES

In both scenarios, the wildcard (%) is processed as a variable. Thus, any metric with a metricName that starts with algorithm and ends with duration will be returned.