• EnglishEspañol日本語한국어Português
  • Log inStart now

NerdGraph tutorial: Create and manage alert workflows

For New Relic alerts, you can create and manage workflows using our NerdGraph API.

List and filter workflows

The workflows query allows you to paginate through all of your workflows per account. It also allows some filtering functionality on the account workflows. Here are some example use cases:

Create a workflow

In order to create a workflow you should first create destinations and channels.

Important

A channel ID is unique and so can't be used in multiple workflows or used multiple times in the same workflow.

Update a workflow

When you update a workflow, note the only mandatory attributes you need to supply are the accountId under aiWorkflowsUpdateWorkflow and the id of the workflow under updateWorkflowData. The rest are optional. For example, you only need to supply the name if you only intend to update the name.

To get the workflow ID, go to the workflow table and click the icon at the end of the row. Then, choose Copy workflow id to clipboard.

Here's an example of updating a workflow's name and two channels:

mutation {
aiWorkflowsUpdateWorkflow(
accountId: YOUR_ACCOUNT_ID
updateWorkflowData: {
name: "UPDATED_WORKFLOW_NAME"
id: WORKFLOW_ID
destinationConfigurations: [
{
channelId: "12345abc-6de7-8f90-g123-4h56i78j9klm"
notificationTriggers: [ACTIVATED]
}
{
channelId: "zy0987xw-v65u-432t-10s9-r876qpo543n2"
notificationTriggers: [ACTIVATED]
}
]
}
) {
workflow {
id
name
destinationConfigurations {
channelId
name
type
notificationTriggers
}
enrichmentsEnabled
destinationsEnabled
issuesFilter {
accountId
id
name
predicates {
attribute
operator
values
}
type
}
lastRun
workflowEnabled
mutingRulesHandling
}
errors {
description
type
}
}
}

Delete a workflow

Here's an example of deleting a workflow:

mutation {
aiWorkflowsDeleteWorkflow(id: WORKFLOW_ID, accountId: YOUR_ACCOUNT_ID) {
id
errors {
description
type
}
}
}

Test a workflow

The test searches for previous issues that match your inputs and creates a fake notification based on that. If no previous issue matching your inputs has been found it will return an error.

For example:

mutation {
aiWorkflowsTestWorkflow(
accountId: YOUR_ACCOUNT_ID
testWorkflowData: {
destinationConfigurations: { channelId: YOUR_CHANNEL_ID, type: SLACK }
issuesFilter: { predicates: [], type: YOUR_FILTER }
}
) {
status
notificationResponses {
status
evidence
channelId
}
errors {
description
type
}
}
}
Copyright © 2024 New Relic Inc.

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