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

NerdGraph tutorial: Alerts channels

In addition to managing your alert notification channels in the UI, you can use our NerdGraph API.

Important

This document refers to using Nerdgraph APIs for the new notification platform using destinations and notification messages. Notification messages are also referred to as channels, which are different from legacy notification channels.

Tip

For help getting started with NerdGraph, see Introduction to NerdGraph.

List and filter channels

The channels query allows you to paginate through all of your channels per account. It also allows some filtering functionality.

Create a channel

In order to create a channel, different inputs must be supplied for each channel type. Each channel is connected to a destination. For information on destinations, see the NerdGraph tutorial on destinations.

The best practice is to use the channelSchema endpoint to see which fields must be sent under properties like so:

{
actor {
account(id: YOUR_ACCOUNT_ID) {
aiNotifications {
channelSchema(
channelType: CHANNEL_TYPE
destinationId: YOUR_DESTINATION_ID
product: YOUR_PRODUCT
constraints: []
) {
schema {
fields {
mandatory
label
key
component
}
}
result
}
}
}
}
}

Update a channel

When you update a channel, note that you don't need to supply all of the attributes on the channel. For example, if you only want to update the name, that's the only attribute you need to update, as shown here:

mutation {
aiNotificationsUpdateChannel(
accountId: YOUR_ACCOUNT_ID
channelId: YOUR_CHANNEL_ID
channel: { name: "Updated channel Name" }
) {
channel {
id
name
}
}
}

Testing a channel

You can test channels via the NerdGraph API. This can be done before or after creating the channel.

mutation {
aiNotificationsTestChannel(
accountId: YOUR_ACCOUNT_ID
channel: {
type: PAGERDUTY_SERVICE_INTEGRATION
name: "Channel Name"
properties: [{ key: "summary", value: YOUR_PAGE_SUMMARY }]
}
) {
error {
details
}
details
result
}
}
mutation {
aiNotificationsTestChannelById(
accountId: YOUR_ACCOUNT_ID
channelId: YOUR_CHANNEL_ID
) {
error {
details
}
details
result
}
}

Delete a channel

You can delete channels via the NerdGraph API.

mutation {
aiNotificationsDeleteChannel(
accountId: YOUR_ACCOUNT_ID
channelId: YOUR_CHANNEL_ID
) {
ids
error {
details
}
}
}
Copyright © 2024 New Relic Inc.

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