• /
  • Log in

NerdGraph tutorial: Managing data partition rules

You can use New Relic’s NerdGraph GraphQL explorer to query and manage your data partition rules.

This document includes:

Data partition rule schema

Here's the complete list of possible data partition rule fields:

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 enables, 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, please be sure to check the article organize 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 just 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 the already persisted data. This data is retained for a given period of time defined by the retention policy field.

mutation {
logConfigurationsDeleteDataPartitionRule(id: "1111", accountId: 123456) {
errors {
message
type
}
}
}

For more help

If you need more help, check out these support and learning resources:

Create issueEdit page
Copyright © 2021 New Relic Inc.