You can useNerdGraph mutations to managemetric 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 resolveMetric Grouping Issues (MGIs).
User type and assigned roles can affect your NerdGraph permissions. For more details, seeFactors affecting access.
Tip
You can also create metric normalization rule by using the New Relic platform. For more information, refer toMetric normalization rules.
Retrieve the metric normalization rules
Use themetricNormalizationRules 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 totrue, 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 followingNerdGraph mutations:
Use themetricNormalizationCreateRule 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 thematchExpression with the value defined in thereplacement field.
IGNORE: Block any metrics from reporting to New Relic that matchmatchExpression.
DENY_NEW_METRICS: Prevent the creation of new metric names that match thematchExpression, 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 totrue.
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 is2000.
matchExpression
String
(Required) Accepts aregular 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 theREPLACE option is selected from theaction drop-down list. It replaces any metric name that matchesmatchExpression. For example:WebTransaction/Uri/RESTfulExample/users/username/{username}$
terminateChain
Boolean
(Required) If set totrue, no further rules will apply on the matched metrics.
Use themetricNormalizationEditRule mutation to update the value of the existing rule using theruleId parameters. It provides flexibility to adjust the rule as per the new insights or changing requirements. You can fetchruleId information usingRetrieve 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 thematchExpression with the value defined in thereplacement field.
IGNORE: Block any metrics from reporting to New Relic that matchmatchExpression.
DENY_NEW_METRICS: Prevent the creation of new metric names that match thematchExpression, 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 totrue.
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 is2000.
id
String
(Required) TheruleId of the metric rule for which you want to update the value.
matchExpression
String
(Required) Accepts aregular 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 theREPLACE option is selected from theaction drop-down list. It replaces any metric name that matchesmatchExpression. For example:WebTransaction/Uri/RESTfulExample/users/username/{username}$
terminateChain
Boolean
(Required) If set totrue, no further rules will apply on the matched metrics.
Use themetricNormalizationEnableRule mutation to enable a previously disabled rule using theaccountId andruleId parameters. You can fetch these parameters usingRetrieve the metric normalization rules query.
Input Parameters
Attribute name
Data type
Description
accountId
String
(Required) The account ID associated with the rule.
UsemetricNormalizationDisableRule mutation to disables a previously enabled rule using theaccountId andruleId parameters. You can fetch these parameters usingRetrieve the metric normalization rules query.
Input Parameters
Attribute name
Data type
Description
accountId
String
(Required) The account ID associated with the rule.