diff --git a/src/content/docs/data-apis/understand-data/metric-data/query-metric-data-type.mdx b/src/content/docs/data-apis/understand-data/metric-data/query-metric-data-type.mdx index bc4fb8f6cf2..c29c658e661 100644 --- a/src/content/docs/data-apis/understand-data/metric-data/query-metric-data-type.mdx +++ b/src/content/docs/data-apis/understand-data/metric-data/query-metric-data-type.mdx @@ -201,29 +201,51 @@ If used in a query, `myNeatProcess.%.duration` will return results for all three There are [multiple types of `Metric` data](/docs/data-apis/understand-data/metric-data/metric-data-type/#metric-types) (for example, `gauge` and `count`) and each type has several associated **fields**. For details on the types of fields available, see [`getField()`](/docs/query-your-data/nrql-new-relic-query-language/get-started/nrql-syntax-clauses-functions/#func-getfield). -You can use `getField()` to extract those fields. For example, if you want to use a single value within a metric to do a comparison in a `WHERE` clause, you can use `getField(metricName, field)` or `metricName[field]`. +You can use `getField()` to extract those fields. For example, if you want to use a single value within a metric to do a comparison in a `WHERE` clause, you can use `getField(metricName, field)` or the shorthand syntax `metricName[field]`. - This example query returns a list of gauge metrics: + The average value of a metric is computed as `total` over `count`, so the following query returns metric data where the result of the `average()` value function is greater than 2. ``` - FROM Metric SELECT uniques(metricName) WHERE %[type] = 'gauge' + FROM Metric + SELECT average(apm.service.transaction.duration) + WHERE appName = 'MyApp' + AND getField(apm.service.transaction.duration, total) / getField(apm.service.transaction.duration, count) > 2 ``` - + Or, you can use the shorthand: + + ``` + FROM Metric + SELECT average(apm.service.transaction.duration) + WHERE appName = 'MyApp' + AND apm.service.transaction.duration[total] / apm.service.transaction.duration[count] > 2 + ``` + - The average value of a metric is computed as `total` over `count`, so the following query returns metric data where the result of the `average()` value function is greater than 2. + This example query returns a list of gauge metrics: ``` - FROM Metric SELECT average(apm.service.transaction.duration) WHERE appName = 'MyApp' AND apm.service.transaction.duration[total] / apm.service.transaction.duration[count] > 2 + FROM Metric + SELECT uniques(metricName) + WHERE getField(%, type) = 'gauge' + ``` + + Or, you can use the shorthand: ``` + FROM Metric + SELECT uniques(metricName) + WHERE %[type] = 'gauge' + ``` + + Note the use of the `%` wildcard to target any matching `metricName`.