From 28889b6fa7c6d7eae1acb43f3a1fd026d8e679f3 Mon Sep 17 00:00:00 2001 From: tclayton Date: Mon, 15 Apr 2024 11:04:08 -0400 Subject: [PATCH 1/4] chore(metrics): Expand getField examples to include long hand queries --- .../metric-data/query-metric-data-type.mdx | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) 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..864c1b86e93 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 @@ -205,25 +205,37 @@ You can use `getField()` to extract those fields. For example, if you want to us - 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 with 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 with the shorthand: ``` + FROM Metric SELECT uniques(metricName) WHERE %[type] = 'gauge' + ``` + + Note the use of the `%` wildcard to target any matching `metricName`. From 57365c7514cae2167f8d2748652fa94ee2acd2b9 Mon Sep 17 00:00:00 2001 From: Rob Siebens Date: Mon, 15 Apr 2024 08:14:57 -0700 Subject: [PATCH 2/4] fix(data-apis): Make minor formatting changes --- .../metric-data/query-metric-data-type.mdx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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 864c1b86e93..2002396c0e5 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 @@ -211,10 +211,13 @@ You can use `getField()` to extract those fields. For example, if you want to us 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 average(apm.service.transaction.duration) WHERE appName = 'MyApp' AND getField(apm.service.transaction.duration, total) / getField(apm.service.transaction.duration, count) > 2 + 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 with the shorthand: + 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 @@ -227,12 +230,16 @@ You can use `getField()` to extract those fields. For example, if you want to us This example query returns a list of gauge metrics: ``` - FROM Metric SELECT uniques(metricName) WHERE getField(%, type) = 'gauge' + FROM Metric + SELECT uniques(metricName) + WHERE getField(%, type) = 'gauge' ``` - or with the shorthand: + Or, you can use the shorthand: ``` - FROM Metric SELECT uniques(metricName) WHERE %[type] = 'gauge' + FROM Metric + SELECT uniques(metricName) + WHERE %[type] = 'gauge' ``` Note the use of the `%` wildcard to target any matching `metricName`. From 97de0f13d4c01b8e70da7814ff09577b81b0795d Mon Sep 17 00:00:00 2001 From: Rob Siebens Date: Mon, 15 Apr 2024 08:17:48 -0700 Subject: [PATCH 3/4] fix(data-apis): Clarify shorthand option --- .../understand-data/metric-data/query-metric-data-type.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 2002396c0e5..b978f3dd9fc 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,7 +201,7 @@ 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]`. Date: Mon, 15 Apr 2024 08:35:30 -0700 Subject: [PATCH 4/4] fix(data-apis): Add formatting I missed --- .../understand-data/metric-data/query-metric-data-type.mdx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 b978f3dd9fc..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 @@ -220,7 +220,10 @@ You can use `getField()` to extract those fields. For example, if you want to us 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 + FROM Metric + SELECT average(apm.service.transaction.duration) + WHERE appName = 'MyApp' + AND apm.service.transaction.duration[total] / apm.service.transaction.duration[count] > 2 ```