Class AlertPolicy
Use this resource to create and manage New Relic alert policies.
Additional Examples
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,
},
});
}
}
<br>
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),
},
});
}
}
Inherited Members
Namespace: Pulumi.NewRelic
Assembly: Pulumi.NewRelic.dll
Syntax
public class AlertPolicy : CustomResource
Constructors
View SourceAlertPolicy(String, AlertPolicyArgs, CustomResourceOptions)
Create a AlertPolicy resource with the given unique name, arguments, and options.
Declaration
public AlertPolicy(string name, AlertPolicyArgs args = null, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resource |
| AlertPolicyArgs | args | The arguments used to populate this resource's properties |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Properties
View SourceChannelIds
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. Also note that channel IDs cannot be imported via terraform import.
Declaration
public Output<ImmutableArray<int>> ChannelIds { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<System.Int32>> |
CreatedAt
DEPRECATED: The time the policy was created.
Declaration
public Output<string> CreatedAt { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
IncidentPreference
The rollup strategy for the policy. Options include: PER_POLICY, PER_CONDITION, or PER_CONDITION_AND_TARGET. The default is PER_POLICY.
Declaration
public Output<string> IncidentPreference { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Name
The name of the policy.
Declaration
public Output<string> Name { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
UpdatedAt
DEPRECATED: The time the policy was last updated.
Declaration
public Output<string> UpdatedAt { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Methods
View SourceGet(String, Input<String>, AlertPolicyState, CustomResourceOptions)
Get an existing AlertPolicy resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
Declaration
public static AlertPolicy Get(string name, Input<string> id, AlertPolicyState state = null, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resulting resource. |
| Input<System.String> | id | The unique provider ID of the resource to lookup. |
| AlertPolicyState | state | Any extra arguments used during the lookup. |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Returns
| Type | Description |
|---|---|
| AlertPolicy |