Who knew one character could make such a huge impact!
What it is: Query multiple metrics using NRQL’s wildcard character (%)
- Makes it faster and easier to query and chart multiple metrics together.
- 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)
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::
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:
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.