• Log inStart now

NerdGraph tutorial: Manage data partition rules

You can use NerdGraph at api.newrelic.com/graphiql to create, query, and manage your data partition rules for logs. NerdGraph is our GraphQL-format API explorer.

Data partition rule schema

Available data partition rule fields include:

Fields

Description

id

Unique data partition rule identifier.

targetDataPartition

The name of the data partition.

description

A description of what this data partition rule represents.

matchingCriteria

The matching criteria for this data partition rule. Once the rule is enabled, logs matching this criteria will be routed to the specified data partition.

retentionPolicy

The retention policy of the data partition data.

createdAt

The date and time the rule was created.

createdBy

The user who created the rule.

updatedAt

The date and time the rule was last changed.

updatedBy

The user who last updated the rule.

enabled

Whether or not this data partition rule is enabled.

deleted

Whether or not this data partition rule has been deleted. Deleting a data partition rule does not delete the already routed logs.

Example query of data partitions rules

This NerdGraph API request example gets all of the data partition rules for a given account. In this example, only a few fields are requested.

{
actor {
account(id: 123456) {
logConfigurations {
dataPartitionRules {
id
targetDataPartition
description
matchingCriteria {
attributeName
matchingOperator
matchingExpression
}
}
}
}
}
}

Create data partitions rules

This example creates a new data partition rule. Before creating the rule, be sure to review our documentation about organizing data with partitions.

mutation {
logConfigurationsCreateDataPartitionRule(
accountId: 1123456,
rule: {
targetDataPartition: "Log_aNewDataPartitionRule",
description: "Example data partition rule",
matchingCriteria: {
attributeName: "attribute",
matchingMethod: LIKE,
matchingExpression: "'%example%'"
},
retentionPolicy: STANDARD,
enabled: true
}) {
rule {
id
targetDataPartition
description
}
errors {
message
type
}
}
}

Update data partitions rules

This example updates the data partition rule with the given id "123". The fields that can be updated are description, matchingCriteria, and enabled. All of them are optional, so you only need to use the ones you want to update.

mutation {
logConfigurationsUpdateDataPartitionRule(
accountId: 1123456,
rule: {
id: "123",
description: "Example data partition rule",
matchingCriteria: {
attributeName: "attribute",
matchingMethod: LIKE,
matchingExpression: "'%example%'"
},
enabled: true
}) {
rule {
id
targetDataPartition
description
}
errors {
message
type
}
}
}

Delete data partitions rules

This example deletes a data partition rule. Deleting a data partition rule doesn't delete data that has already been partitioned. That data is retained for a given period of time defined by the retentionPolicy field.

mutation {
logConfigurationsDeleteDataPartitionRule(id: "1111", accountId: 123456) {
errors {
message
type
}
}
}
Copyright © 2022 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.