NerdGraph tutorial: Managing the Metric Normalization Rules
preview
We're still working on this feature, but we'd love for you to try it out!
This feature is currently provided as part of a preview program pursuant to our pre-release policies.
You can use NerdGraph mutations to manage metric normalization rules in New Relic. By leveraging these mutations, you can create, edit, enable, and disable these rules directly from your New Relic account. This provides a streamlined and programmatic approach to resolve Metric Grouping Issues (MGIs).
User type and assigned roles can affect your NerdGraph permissions. For more details, see Factors affecting access.
Sugerencia
You can also create metric normalization rule by using the New Relic platform. For more information, refer to Metric normalization rules.
Retrieve the metric normalization rules
Use the metricNormalizationRules query to retrieve all metric normalization rules associated with your account. This query provides a comprehensive overview of the existing rules, including their status and configuration.
Input parameters
Attribute name
Data type
Description
accountId
String
(Required) The account ID associated with the rule.
enable
Boolean
(Required) If set to true, only enabled rules are returned.
Sample query
{
actor{
user{
name
}
account(id:xxxxxx){
metricNormalization{
metricNormalizationRules(enabled:true){
action
applicationGuid
applicationName
createdAt
enabled
evalOrder
id
matchExpression
notes
replacement
terminateChain
}
}
}
}
}
Mutations
Manage your metric normalization rules with the following NerdGraph mutations:
Use the metricNormalizationCreateRule mutation to create a new metric normalization rule in New Relic.
Input parameters
Attribute name
Data type
Description
accountId
String
(Required) The account ID associated with the rule.
action
String
(Required) Select one of the following action:
REPLACE: Replace the metrics that match the matchExpression with the value defined in the replacement field.
IGNORE: Block any metrics from reporting to New Relic that match matchExpression.
DENY_NEW_METRICS: Prevent the creation of new metric names that match the matchExpression, while allowing existing metric names to continue reporting.
applicationGuid
String
(Optional) The unique GUID for the application in New Relic. If left blank, this becomes an account-wide rule.
enabled
Boolean
(Required) To enable the rule, set to true.
evalOrder
Integer
(Required) Specify the order in which the rule is applied relative to other rules. The lower the number, the higher the evaluated priority. Recommend value is 2000.
matchExpression
String
(Required) Accepts a regular expression pattern that matches the metrics to be normalized. This field must start with a ^ and end with a $. It defines a pattern to identify which metrics should be affected by the normalization rule. For example:
^WebTransaction/Uri/RESTfulExample/users/username/[a-zA-Z0-9]+$
The pattern ^[a-zA-Z0-9]+$ matches any string composed of lowercase characters (a-z), uppercase characters (A-Z), and numbers (0-9).
notes
String
Additional notes or comments about the normalization rule.
replacement
String
This field is only required when the REPLACE option is selected from the action drop-down list. It replaces any metric name that matches matchExpression. For example: WebTransaction/Uri/RESTfulExample/users/username/{username}$
terminateChain
Boolean
(Required) If set to true, no further rules will apply on the matched metrics.
Use the metricNormalizationEditRule mutation to update the value of the existing rule using the ruleId parameters. It provides flexibility to adjust the rule as per the new insights or changing requirements. You can fetch ruleId information using Retrieve the metric normalization rules query.
Input parameters
Attribute name
Data type
Description
accountId
String
(Required) The account ID associated with the rule.
action
String
(Required) Select one of the following action:
REPLACE: Replace the metrics that match the matchExpression with the value defined in the replacement field.
IGNORE: Block any metrics from reporting to New Relic that match matchExpression.
DENY_NEW_METRICS: Prevent the creation of new metric names that match the matchExpression, while allowing existing metric names to continue reporting.
applicationGuid
String
(Optional) The unique GUID for the application in New Relic. If left blank, this becomes an account-wide rule.
enabled
Boolean
(Required) To enable the rule, set to true.
evalOrder
Integer
(Required) Specify the order in which the rule is applied relative to other rules. The lower the number, the higher the evaluated priority. Recommend value is 2000.
id
String
(Required) The ruleId of the metric rule for which you want to update the value.
matchExpression
String
(Required) Accepts a regular expression pattern that matches the metrics to be normalized. This field must start with a ^ and end with a $. It defines a pattern to identify which metrics should be affected by the normalization rule. For example:
^WebTransaction/Uri/RESTfulExample/users/username/[a-zA-Z0-9]+$
The pattern ^[a-zA-Z0-9]+$ matches any string composed of lowercase characters (a-z), uppercase characters (A-Z), and numbers (0-9).
notes
String
Additional notes or comments about the normalization rule.
replacement
String
This field is only required when the REPLACE option is selected from the action drop-down list. It replaces any metric name that matches matchExpression. For example: WebTransaction/Uri/RESTfulExample/users/username/{username}$
terminateChain
Boolean
(Required) If set to true, no further rules will apply on the matched metrics.
Use the metricNormalizationEnableRule mutation to enable a previously disabled rule using the accountId and ruleId parameters. You can fetch these parameters using Retrieve the metric normalization rules query.
Input Parameters
Attribute name
Data type
Description
accountId
String
(Required) The account ID associated with the rule.
Use metricNormalizationDisableRule mutation to disables a previously enabled rule using the accountId and ruleId parameters. You can fetch these parameters using Retrieve the metric normalization rules query.
Input Parameters
Attribute name
Data type
Description
accountId
String
(Required) The account ID associated with the rule.