1. Packages
  2. Newrelic Provider
New Relic v5.43.0 published on Friday, Mar 21, 2025 by Pulumi

Newrelic Provider

newrelic logo
New Relic v5.43.0 published on Friday, Mar 21, 2025 by Pulumi

    Installation

    The Newrelic provider is available as a package in all Pulumi languages:

    Overview

    New Relic offers tools that help you fix problems quickly, maintain complex systems, improve your code, and accelerate your digital transformation.

    Use the navigation to the left to read about the available resources.

    Configuration Reference

    The following configuration inputs are supported.

    ArgumentRequired?Description
    accountIdRequiredYour New Relic account ID. The NEW_RELIC_ACCOUNT_ID environment variable can also be used.
    apiKeyRequiredYour New Relic Personal API key (usually prefixed with NRAK). The NEW_RELIC_API_KEY environment variable can also be used.
    regionOptionalThe region for the data center for which your New Relic account is configured. The NEW_RELIC_REGION environment variable can also be used. Valid values are US or EU. Default value is US.
    insecureSkipVerifyOptionalTrust self-signed SSL certificates. If omitted, the NEW_RELIC_API_SKIP_VERIFY environment variable is used.
    insightsInsertKeyOptionalYour Insights insert key used when inserting Insights events via the newrelic.insights.Event resource. Can also use NEW_RELIC_INSIGHTS_INSERT_KEY environment variable.
    cacertFileOptionalA path to a PEM-encoded certificate authority used to verify the remote agent’s certificate. The NEW_RELIC_API_CACERT environment variable can also be used.

    Authentication Requirements

    This provider is in the midst of migrating away from our older REST based APIs to a newer GraphQL based API that we lovingly call NerdGraph. During this transition, the provider will be using different endpoints depending on which resource is in use. Below is a table that reflects the current state of the resources compared to which endpoint is in use.

    Resources

    ResourceEndpointAuthentication
    newrelic.AccountManagementNerdGraphapiKey
    newrelic.AlertChannelRESTv2apiKey
    newrelic.AlertConditionRESTv2apiKey
    newrelic.AlertMutingRuleNerdGraphapiKey
    newrelic.AlertPolicyNerdGraphapiKey
    newrelic.AlertPolicyChannelRESTv2apiKey
    newrelic.ApiAccessKeyNerdGraphapiKey
    newrelic.plugins.ApplicationSettingsRESTv2apiKey
    newrelic.BrowserApplicationNerdGraphapiKey
    newrelic.cloud.AwsGovcloudIntegrationsNerdGraphapiKey
    newrelic.cloud.AwsGovcloudLinkAccountNerdGraphapiKey
    newrelic.cloud.AwsIntegrationsNerdGraphapiKey
    newrelic.cloud.AwsLinkAccountNerdGraphapiKey
    newrelic.cloud.AzureIntegrationsNerdGraphapiKey
    newrelic.cloud.AzureLinkAccountNerdGraphapiKey
    newrelic.cloud.GcpIntegrationsNerdGraphapiKey
    newrelic.cloud.GcpLinkAccountNerdGraphapiKey
    newrelic.DataPartitionRuleNerdGraphapiKey
    newrelic.EntityTagsNerdGraphapiKey
    newrelic.EventsToMetricsRuleNerdGraphapiKey
    newrelic.GroupNerdGraphapiKey
    newrelic.InfraAlertConditionInfrastructure REST APIapiKey
    newrelic.insights.EventInsights APIinsightsInsertKey
    newrelic.KeyTransactionNerdGraphapiKey
    newrelic.LogParsingRuleNerdGraphapiKey
    newrelic.NotificationChannelNerdGraphapiKey
    newrelic.NotificationDestinationNerdGraphapiKey
    newrelic.NrqlAlertConditionNerdGraphapiKey
    newrelic.NrqlDropRuleNerdGraphapiKey
    newrelic.ObfuscationExpressionNerdGraphapiKey
    newrelic.ObfuscationRuleNerdGraphapiKey
    newrelic.OneDashboardNerdGraphapiKey
    newrelic.OneDashboardJsonNerdGraphapiKey
    newrelic.OneDashboardRawNerdGraphapiKey
    newrelic.ServiceLevelNerdGraphapiKey
    newrelic.synthetics.AlertConditionRESTv2apiKey
    newrelic.synthetics.BrokenLinksMonitorNerdGraphapiKey
    newrelic.synthetics.CertCheckMonitorNerdGraphapiKey
    newrelic.synthetics.MonitorNerdGraphapiKey
    newrelic.synthetics.MultiLocationAlertConditionRESTv2apiKey
    newrelic.synthetics.PrivateLocationNerdGraphapiKey
    newrelic.synthetics.ScriptMonitorNerdGraphapiKey
    newrelic.synthetics.SecureCredentialNerdGraphapiKey
    newrelic.synthetics.StepMonitorNerdGraphapiKey
    newrelic.UserNerdGraphapiKey
    newrelic.WorkflowNerdGraphapiKey
    newrelic.plugins.WorkloadNerdGraphapiKey

    Functions

    FunctionEndpointAuthentication
    newrelic.getAccountNerdGraphapiKey
    newrelic.AlertChannelRESTv2apiKey
    newrelic.AlertPolicyNerdGraphapiKey
    newrelic.getApplicationRESTv2apiKey
    newrelic.getCloudAccountNerdGraphapiKey
    newrelic.getEntityNerdGraphapiKey
    newrelic.KeyTransactionNerdGraphapiKey
    newrelic.NotificationDestinationNerdGraphapiKey
    newrelic.ObfuscationExpressionNerdGraphapiKey
    newrelic.synthetics.PrivateLocationNerdGraphapiKey
    newrelic.synthetics.SecureCredentialNerdGraphapiKey
    newrelic.getTestGrokPatternNerdGraphapiKey

    Example Usage

    # Pulumi.yaml provider configuration file
    name: configuration-example
    runtime: nodejs
    config:
        newrelic:accountId:
            value: 12345
        newrelic:apiKey:
            value: 12345
        newrelic:region:
            value: US
    
    import * as pulumi from "@pulumi/pulumi";
    import * as newrelic from "@pulumi/newrelic";
    
    // Read an APM application resource
    const foo = newrelic.getEntity({
        name: "Your App Name",
        domain: "APM",
        type: "APPLICATION",
    });
    // Create an alert policy
    const alert = new newrelic.AlertPolicy("alert", {name: "Your Concise Alert Name"});
    // Add a condition
    const fooNrqlAlertCondition = new newrelic.NrqlAlertCondition("foo", {
        policyId: alert.id,
        type: "static",
        name: "foo",
        description: "Alert when transactions are taking too long",
        runbookUrl: "https://www.example.com",
        enabled: true,
        violationTimeLimitSeconds: 3600,
        nrql: {
            query: foo.then(foo => `SELECT average(duration) FROM Transaction where appName = '${foo.name}'`),
        },
        critical: {
            operator: "above",
            threshold: 5.5,
            thresholdDuration: 300,
            thresholdOccurrences: "ALL",
        },
    });
    // Add a notification channel
    const email = new newrelic.AlertChannel("email", {
        name: "email",
        type: "email",
        config: {
            recipients: "username@example.com",
            includeJsonAttachment: "1",
        },
    });
    // Link the channel to the policy
    const alertEmail = new newrelic.AlertPolicyChannel("alert_email", {
        policyId: alert.id,
        channelIds: [email.id],
    });
    
    # Pulumi.yaml provider configuration file
    name: configuration-example
    runtime: python
    config:
        newrelic:accountId:
            value: 12345
        newrelic:apiKey:
            value: 12345
        newrelic:region:
            value: US
    
    import pulumi
    import pulumi_newrelic as newrelic
    
    # Read an APM application resource
    foo = newrelic.get_entity(name="Your App Name",
        domain="APM",
        type="APPLICATION")
    # Create an alert policy
    alert = newrelic.AlertPolicy("alert", name="Your Concise Alert Name")
    # Add a condition
    foo_nrql_alert_condition = newrelic.NrqlAlertCondition("foo",
        policy_id=alert.id,
        type="static",
        name="foo",
        description="Alert when transactions are taking too long",
        runbook_url="https://www.example.com",
        enabled=True,
        violation_time_limit_seconds=3600,
        nrql={
            "query": f"SELECT average(duration) FROM Transaction where appName = '{foo.name}'",
        },
        critical={
            "operator": "above",
            "threshold": 5.5,
            "threshold_duration": 300,
            "threshold_occurrences": "ALL",
        })
    # Add a notification channel
    email = newrelic.AlertChannel("email",
        name="email",
        type="email",
        config={
            "recipients": "username@example.com",
            "include_json_attachment": "1",
        })
    # Link the channel to the policy
    alert_email = newrelic.AlertPolicyChannel("alert_email",
        policy_id=alert.id,
        channel_ids=[email.id])
    
    # Pulumi.yaml provider configuration file
    name: configuration-example
    runtime: dotnet
    config:
        newrelic:accountId:
            value: 12345
        newrelic:apiKey:
            value: 12345
        newrelic:region:
            value: US
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using NewRelic = Pulumi.NewRelic;
    
    return await Deployment.RunAsync(() =>
    {
        // Read an APM application resource
        var foo = NewRelic.GetEntity.Invoke(new()
        {
            Name = "Your App Name",
            Domain = "APM",
            Type = "APPLICATION",
        });
    
        // Create an alert policy
        var alert = new NewRelic.AlertPolicy("alert", new()
        {
            Name = "Your Concise Alert Name",
        });
    
        // Add a condition
        var fooNrqlAlertCondition = new NewRelic.NrqlAlertCondition("foo", new()
        {
            PolicyId = alert.Id,
            Type = "static",
            Name = "foo",
            Description = "Alert when transactions are taking too long",
            RunbookUrl = "https://www.example.com",
            Enabled = true,
            ViolationTimeLimitSeconds = 3600,
            Nrql = new NewRelic.Inputs.NrqlAlertConditionNrqlArgs
            {
                Query = $"SELECT average(duration) FROM Transaction where appName = '{foo.Apply(getEntityResult => getEntityResult.Name)}'",
            },
            Critical = new NewRelic.Inputs.NrqlAlertConditionCriticalArgs
            {
                Operator = "above",
                Threshold = 5.5,
                ThresholdDuration = 300,
                ThresholdOccurrences = "ALL",
            },
        });
    
        // Add a notification channel
        var email = new NewRelic.AlertChannel("email", new()
        {
            Name = "email",
            Type = "email",
            Config = new NewRelic.Inputs.AlertChannelConfigArgs
            {
                Recipients = "username@example.com",
                IncludeJsonAttachment = "1",
            },
        });
    
        // Link the channel to the policy
        var alertEmail = new NewRelic.AlertPolicyChannel("alert_email", new()
        {
            PolicyId = alert.Id,
            ChannelIds = new[]
            {
                email.Id,
            },
        });
    
    });
    
    # Pulumi.yaml provider configuration file
    name: configuration-example
    runtime: go
    config:
        newrelic:accountId:
            value: 12345
        newrelic:apiKey:
            value: 12345
        newrelic:region:
            value: US
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/pulumi/pulumi-newrelic/sdk/v5/go/newrelic"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// Read an APM application resource
    		foo, err := newrelic.GetEntity(ctx, &newrelic.GetEntityArgs{
    			Name:   "Your App Name",
    			Domain: pulumi.StringRef("APM"),
    			Type:   pulumi.StringRef("APPLICATION"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		// Create an alert policy
    		alert, err := newrelic.NewAlertPolicy(ctx, "alert", &newrelic.AlertPolicyArgs{
    			Name: pulumi.String("Your Concise Alert Name"),
    		})
    		if err != nil {
    			return err
    		}
    		// Add a condition
    		_, err = newrelic.NewNrqlAlertCondition(ctx, "foo", &newrelic.NrqlAlertConditionArgs{
    			PolicyId:                  alert.ID(),
    			Type:                      pulumi.String("static"),
    			Name:                      pulumi.String("foo"),
    			Description:               pulumi.String("Alert when transactions are taking too long"),
    			RunbookUrl:                pulumi.String("https://www.example.com"),
    			Enabled:                   pulumi.Bool(true),
    			ViolationTimeLimitSeconds: pulumi.Int(3600),
    			Nrql: &newrelic.NrqlAlertConditionNrqlArgs{
    				Query: pulumi.Sprintf("SELECT average(duration) FROM Transaction where appName = '%v'", foo.Name),
    			},
    			Critical: &newrelic.NrqlAlertConditionCriticalArgs{
    				Operator:             pulumi.String("above"),
    				Threshold:            pulumi.Float64(5.5),
    				ThresholdDuration:    pulumi.Int(300),
    				ThresholdOccurrences: pulumi.String("ALL"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		// Add a notification channel
    		email, err := newrelic.NewAlertChannel(ctx, "email", &newrelic.AlertChannelArgs{
    			Name: pulumi.String("email"),
    			Type: pulumi.String("email"),
    			Config: &newrelic.AlertChannelConfigArgs{
    				Recipients:            pulumi.String("username@example.com"),
    				IncludeJsonAttachment: pulumi.String("1"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		// Link the channel to the policy
    		_, err = newrelic.NewAlertPolicyChannel(ctx, "alert_email", &newrelic.AlertPolicyChannelArgs{
    			PolicyId: alert.ID(),
    			ChannelIds: pulumi.StringArray{
    				email.ID(),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    # Pulumi.yaml provider configuration file
    name: configuration-example
    runtime: yaml
    config:
        newrelic:accountId:
            value: 12345
        newrelic:apiKey:
            value: 12345
        newrelic:region:
            value: US
    
    resources:
      # Create an alert policy
      alert:
        type: newrelic:AlertPolicy
        properties:
          name: Your Concise Alert Name
      # Add a condition
      fooNrqlAlertCondition:
        type: newrelic:NrqlAlertCondition
        name: foo
        properties:
          policyId: ${alert.id}
          type: static
          name: foo
          description: Alert when transactions are taking too long
          runbookUrl: https://www.example.com
          enabled: true
          violationTimeLimitSeconds: 3600
          nrql:
            query: SELECT average(duration) FROM Transaction where appName = '${foo.name}'
          critical:
            operator: above
            threshold: 5.5
            thresholdDuration: 300
            thresholdOccurrences: ALL
      # Add a notification channel
      email:
        type: newrelic:AlertChannel
        properties:
          name: email
          type: email
          config:
            recipients: username@example.com
            includeJsonAttachment: '1'
      # Link the channel to the policy
      alertEmail:
        type: newrelic:AlertPolicyChannel
        name: alert_email
        properties:
          policyId: ${alert.id}
          channelIds:
            - ${email.id}
    variables:
      # Read an APM application resource
      foo:
        fn::invoke:
          Function: newrelic:getEntity
          Arguments:
            name: Your App Name
            domain: APM
            type: APPLICATION
    
    # Pulumi.yaml provider configuration file
    name: configuration-example
    runtime: java
    config:
        newrelic:accountId:
            value: 12345
        newrelic:apiKey:
            value: 12345
        newrelic:region:
            value: US
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.newrelic.NewrelicFunctions;
    import com.pulumi.newrelic.inputs.GetEntityArgs;
    import com.pulumi.newrelic.AlertPolicy;
    import com.pulumi.newrelic.AlertPolicyArgs;
    import com.pulumi.newrelic.NrqlAlertCondition;
    import com.pulumi.newrelic.NrqlAlertConditionArgs;
    import com.pulumi.newrelic.inputs.NrqlAlertConditionNrqlArgs;
    import com.pulumi.newrelic.inputs.NrqlAlertConditionCriticalArgs;
    import com.pulumi.newrelic.AlertChannel;
    import com.pulumi.newrelic.AlertChannelArgs;
    import com.pulumi.newrelic.inputs.AlertChannelConfigArgs;
    import com.pulumi.newrelic.AlertPolicyChannel;
    import com.pulumi.newrelic.AlertPolicyChannelArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            // Read an APM application resource
            final var foo = NewrelicFunctions.getEntity(GetEntityArgs.builder()
                .name("Your App Name")
                .domain("APM")
                .type("APPLICATION")
                .build());
    
            // Create an alert policy
            var alert = new AlertPolicy("alert", AlertPolicyArgs.builder()
                .name("Your Concise Alert Name")
                .build());
    
            // Add a condition
            var fooNrqlAlertCondition = new NrqlAlertCondition("fooNrqlAlertCondition", NrqlAlertConditionArgs.builder()
                .policyId(alert.id())
                .type("static")
                .name("foo")
                .description("Alert when transactions are taking too long")
                .runbookUrl("https://www.example.com")
                .enabled(true)
                .violationTimeLimitSeconds(3600)
                .nrql(NrqlAlertConditionNrqlArgs.builder()
                    .query(String.format("SELECT average(duration) FROM Transaction where appName = '%s'", foo.applyValue(getEntityResult -> getEntityResult.name())))
                    .build())
                .critical(NrqlAlertConditionCriticalArgs.builder()
                    .operator("above")
                    .threshold(5.5)
                    .thresholdDuration(300)
                    .thresholdOccurrences("ALL")
                    .build())
                .build());
    
            // Add a notification channel
            var email = new AlertChannel("email", AlertChannelArgs.builder()
                .name("email")
                .type("email")
                .config(AlertChannelConfigArgs.builder()
                    .recipients("username@example.com")
                    .includeJsonAttachment("1")
                    .build())
                .build());
    
            // Link the channel to the policy
            var alertEmail = new AlertPolicyChannel("alertEmail", AlertPolicyChannelArgs.builder()
                .policyId(alert.id())
                .channelIds(email.id())
                .build());
    
        }
    }
    
    newrelic logo
    New Relic v5.43.0 published on Friday, Mar 21, 2025 by Pulumi