AlertPolicy
Use this resource to create and manage New Relic alert policies.
Example Usage
Basic Usage
Coming soon!
Coming soon!
Coming soon!
import * as pulumi from "@pulumi/pulumi";
import * as newrelic from "@pulumi/newrelic";
const foo = new newrelic.AlertPolicy("foo", {
incidentPreference: "PER_POLICY", // PER_POLICY is default
});Provision multiple notification channels and add those channels to a policy
using Pulumi;
using NewRelic = Pulumi.NewRelic;
class MyStack : Stack
{
public MyStack()
{
// Provision a Slack notification channel.
var slackChannel = new NewRelic.AlertChannel("slackChannel", new NewRelic.AlertChannelArgs
{
Type = "slack",
Config = new NewRelic.Inputs.AlertChannelConfigArgs
{
Url = "https://hooks.slack.com/services/<*****>/<*****>",
Channel = "example-alerts-channel",
},
});
// Provision an email notification channel.
var emailChannel = new NewRelic.AlertChannel("emailChannel", new NewRelic.AlertChannelArgs
{
Type = "email",
Config = new NewRelic.Inputs.AlertChannelConfigArgs
{
Recipients = "example@testing.com",
IncludeJsonAttachment = "1",
},
});
// Provision the alert policy.
var policyWithChannels = new NewRelic.AlertPolicy("policyWithChannels", new NewRelic.AlertPolicyArgs
{
IncidentPreference = "PER_CONDITION",
ChannelIds =
{
slackChannel.Id,
emailChannel.Id,
},
});
}
}
Coming soon!
import pulumi
import pulumi_newrelic as newrelic
# Provision a Slack notification channel.
slack_channel = newrelic.AlertChannel("slackChannel",
type="slack",
config={
"url": "https://hooks.slack.com/services/<*****>/<*****>",
"channel": "example-alerts-channel",
})
# Provision an email notification channel.
email_channel = newrelic.AlertChannel("emailChannel",
type="email",
config={
"recipients": "example@testing.com",
"includeJsonAttachment": "1",
})
# Provision the alert policy.
policy_with_channels = newrelic.AlertPolicy("policyWithChannels",
incident_preference="PER_CONDITION",
channel_ids=[
slack_channel.id,
email_channel.id,
])import * as pulumi from "@pulumi/pulumi";
import * as newrelic from "@pulumi/newrelic";
// Provision a Slack notification channel.
const slackChannel = new newrelic.AlertChannel("slackChannel", {
type: "slack",
config: {
url: "https://hooks.slack.com/services/<*****>/<*****>",
channel: "example-alerts-channel",
},
});
// Provision an email notification channel.
const emailChannel = new newrelic.AlertChannel("emailChannel", {
type: "email",
config: {
recipients: "example@testing.com",
includeJsonAttachment: "1",
},
});
// Provision the alert policy.
const policyWithChannels = new newrelic.AlertPolicy("policyWithChannels", {
incidentPreference: "PER_CONDITION",
channelIds: [
slackChannel.id,
emailChannel.id,
],
});Reference existing notification channels and add those channel to a policy
using Pulumi;
using NewRelic = Pulumi.NewRelic;
class MyStack : Stack
{
public MyStack()
{
var slackChannel = Output.Create(NewRelic.GetAlertChannel.InvokeAsync(new NewRelic.GetAlertChannelArgs
{
Name = "slack-channel-notification",
}));
var emailChannel = Output.Create(NewRelic.GetAlertChannel.InvokeAsync(new NewRelic.GetAlertChannelArgs
{
Name = "test@example.com",
}));
// Provision the alert policy.
var policyWithChannels = new NewRelic.AlertPolicy("policyWithChannels", new NewRelic.AlertPolicyArgs
{
IncidentPreference = "PER_CONDITION",
ChannelIds =
{
slackChannel.Apply(slackChannel => slackChannel.Id),
emailChannel.Apply(emailChannel => emailChannel.Id),
},
});
}
}
Coming soon!
import pulumi
import pulumi_newrelic as newrelic
slack_channel = newrelic.get_alert_channel(name="slack-channel-notification")
email_channel = newrelic.get_alert_channel(name="test@example.com")
# Provision the alert policy.
policy_with_channels = newrelic.AlertPolicy("policyWithChannels",
incident_preference="PER_CONDITION",
channel_ids=[
slack_channel.id,
email_channel.id,
])import * as pulumi from "@pulumi/pulumi";
import * as newrelic from "@pulumi/newrelic";
const slackChannel = newrelic.getAlertChannel({
name: "slack-channel-notification",
});
const emailChannel = newrelic.getAlertChannel({
name: "test@example.com",
});
// Provision the alert policy.
const policyWithChannels = new newrelic.AlertPolicy("policyWithChannels", {
incidentPreference: "PER_CONDITION",
channelIds: [
slackChannel.then(slackChannel => slackChannel.id),
emailChannel.then(emailChannel => emailChannel.id),
],
});Create a AlertPolicy Resource
new AlertPolicy(name: string, args?: AlertPolicyArgs, opts?: CustomResourceOptions);def AlertPolicy(resource_name, opts=None, account_id=None, channel_ids=None, incident_preference=None, name=None, __props__=None);func NewAlertPolicy(ctx *Context, name string, args *AlertPolicyArgs, opts ...ResourceOption) (*AlertPolicy, error)public AlertPolicy(string name, AlertPolicyArgs? args = null, CustomResourceOptions? opts = null)- name string
- The unique name of the resource.
- args AlertPolicyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- opts ResourceOptions
- A bag of options that control this resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args AlertPolicyArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args AlertPolicyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
AlertPolicy Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The AlertPolicy resource accepts the following input properties:
- Account
Id int The New Relic account ID to operate on.
- Channel
Ids List<int> An array of channel IDs (integers) to assign to the policy. Adding or removing channel IDs from this array will result in a new alert policy resource being created and the old one being destroyed.
- Incident
Preference string The rollup strategy for the policy. Options include:
PER_POLICY,PER_CONDITION, orPER_CONDITION_AND_TARGET. The default isPER_POLICY.- Name string
The name of the policy.
- Account
Id int The New Relic account ID to operate on.
- Channel
Ids []int An array of channel IDs (integers) to assign to the policy. Adding or removing channel IDs from this array will result in a new alert policy resource being created and the old one being destroyed.
- Incident
Preference string The rollup strategy for the policy. Options include:
PER_POLICY,PER_CONDITION, orPER_CONDITION_AND_TARGET. The default isPER_POLICY.- Name string
The name of the policy.
- account
Id number The New Relic account ID to operate on.
- channel
Ids number[] An array of channel IDs (integers) to assign to the policy. Adding or removing channel IDs from this array will result in a new alert policy resource being created and the old one being destroyed.
- incident
Preference string The rollup strategy for the policy. Options include:
PER_POLICY,PER_CONDITION, orPER_CONDITION_AND_TARGET. The default isPER_POLICY.- name string
The name of the policy.
- account_
id float The New Relic account ID to operate on.
- channel_
ids List[Integer] An array of channel IDs (integers) to assign to the policy. Adding or removing channel IDs from this array will result in a new alert policy resource being created and the old one being destroyed.
- incident_
preference str The rollup strategy for the policy. Options include:
PER_POLICY,PER_CONDITION, orPER_CONDITION_AND_TARGET. The default isPER_POLICY.- name str
The name of the policy.
Outputs
All input properties are implicitly available as output properties. Additionally, the AlertPolicy resource produces the following output properties:
Look up an Existing AlertPolicy Resource
Get an existing AlertPolicy resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: AlertPolicyState, opts?: CustomResourceOptions): AlertPolicystatic get(resource_name, id, opts=None, account_id=None, channel_ids=None, incident_preference=None, name=None, __props__=None);func GetAlertPolicy(ctx *Context, name string, id IDInput, state *AlertPolicyState, opts ...ResourceOption) (*AlertPolicy, error)public static AlertPolicy Get(string name, Input<string> id, AlertPolicyState? state, CustomResourceOptions? opts = null)- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
The following state arguments are supported:
- Account
Id int The New Relic account ID to operate on.
- Channel
Ids List<int> An array of channel IDs (integers) to assign to the policy. Adding or removing channel IDs from this array will result in a new alert policy resource being created and the old one being destroyed.
- Incident
Preference string The rollup strategy for the policy. Options include:
PER_POLICY,PER_CONDITION, orPER_CONDITION_AND_TARGET. The default isPER_POLICY.- Name string
The name of the policy.
- Account
Id int The New Relic account ID to operate on.
- Channel
Ids []int An array of channel IDs (integers) to assign to the policy. Adding or removing channel IDs from this array will result in a new alert policy resource being created and the old one being destroyed.
- Incident
Preference string The rollup strategy for the policy. Options include:
PER_POLICY,PER_CONDITION, orPER_CONDITION_AND_TARGET. The default isPER_POLICY.- Name string
The name of the policy.
- account
Id number The New Relic account ID to operate on.
- channel
Ids number[] An array of channel IDs (integers) to assign to the policy. Adding or removing channel IDs from this array will result in a new alert policy resource being created and the old one being destroyed.
- incident
Preference string The rollup strategy for the policy. Options include:
PER_POLICY,PER_CONDITION, orPER_CONDITION_AND_TARGET. The default isPER_POLICY.- name string
The name of the policy.
- account_
id float The New Relic account ID to operate on.
- channel_
ids List[Integer] An array of channel IDs (integers) to assign to the policy. Adding or removing channel IDs from this array will result in a new alert policy resource being created and the old one being destroyed.
- incident_
preference str The rollup strategy for the policy. Options include:
PER_POLICY,PER_CONDITION, orPER_CONDITION_AND_TARGET. The default isPER_POLICY.- name str
The name of the policy.
Package Details
- Repository
- https://github.com/pulumi/pulumi-newrelic
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
newrelicTerraform Provider.