1. Packages
  2. New Relic
  3. API Docs
  4. getKeyTransaction
New Relic v5.33.0 published on Thursday, Sep 26, 2024 by Pulumi

newrelic.getKeyTransaction

Explore with Pulumi AI

newrelic logo
New Relic v5.33.0 published on Thursday, Sep 26, 2024 by Pulumi

    Use this data source to get information about a specific key transaction in New Relic that already exists.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as newrelic from "@pulumi/newrelic";
    
    const txn = newrelic.getKeyTransaction({
        name: "txn",
    });
    const foo = new newrelic.AlertPolicy("foo", {name: "foo"});
    const fooAlertCondition = new newrelic.AlertCondition("foo", {
        policyId: foo.id,
        name: "foo",
        type: "apm_kt_metric",
        entities: [txn.then(txn => txn.id)],
        metric: "error_percentage",
        runbookUrl: "https://www.example.com",
        terms: [{
            duration: 5,
            operator: "below",
            priority: "critical",
            threshold: 0.75,
            timeFunction: "all",
        }],
    });
    
    import pulumi
    import pulumi_newrelic as newrelic
    
    txn = newrelic.get_key_transaction(name="txn")
    foo = newrelic.AlertPolicy("foo", name="foo")
    foo_alert_condition = newrelic.AlertCondition("foo",
        policy_id=foo.id,
        name="foo",
        type="apm_kt_metric",
        entities=[txn.id],
        metric="error_percentage",
        runbook_url="https://www.example.com",
        terms=[{
            "duration": 5,
            "operator": "below",
            "priority": "critical",
            "threshold": 0.75,
            "time_function": "all",
        }])
    
    package main
    
    import (
    	"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 {
    		txn, err := newrelic.LookupKeyTransaction(ctx, &newrelic.LookupKeyTransactionArgs{
    			Name: "txn",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		foo, err := newrelic.NewAlertPolicy(ctx, "foo", &newrelic.AlertPolicyArgs{
    			Name: pulumi.String("foo"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = newrelic.NewAlertCondition(ctx, "foo", &newrelic.AlertConditionArgs{
    			PolicyId: foo.ID(),
    			Name:     pulumi.String("foo"),
    			Type:     pulumi.String("apm_kt_metric"),
    			Entities: pulumi.StringArray{
    				pulumi.String(txn.Id),
    			},
    			Metric:     pulumi.String("error_percentage"),
    			RunbookUrl: pulumi.String("https://www.example.com"),
    			Terms: newrelic.AlertConditionTermArray{
    				&newrelic.AlertConditionTermArgs{
    					Duration:     pulumi.Int(5),
    					Operator:     pulumi.String("below"),
    					Priority:     pulumi.String("critical"),
    					Threshold:    pulumi.Float64(0.75),
    					TimeFunction: pulumi.String("all"),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using NewRelic = Pulumi.NewRelic;
    
    return await Deployment.RunAsync(() => 
    {
        var txn = NewRelic.GetKeyTransaction.Invoke(new()
        {
            Name = "txn",
        });
    
        var foo = new NewRelic.AlertPolicy("foo", new()
        {
            Name = "foo",
        });
    
        var fooAlertCondition = new NewRelic.AlertCondition("foo", new()
        {
            PolicyId = foo.Id,
            Name = "foo",
            Type = "apm_kt_metric",
            Entities = new[]
            {
                txn.Apply(getKeyTransactionResult => getKeyTransactionResult.Id),
            },
            Metric = "error_percentage",
            RunbookUrl = "https://www.example.com",
            Terms = new[]
            {
                new NewRelic.Inputs.AlertConditionTermArgs
                {
                    Duration = 5,
                    Operator = "below",
                    Priority = "critical",
                    Threshold = 0.75,
                    TimeFunction = "all",
                },
            },
        });
    
    });
    
    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.GetKeyTransactionArgs;
    import com.pulumi.newrelic.AlertPolicy;
    import com.pulumi.newrelic.AlertPolicyArgs;
    import com.pulumi.newrelic.AlertCondition;
    import com.pulumi.newrelic.AlertConditionArgs;
    import com.pulumi.newrelic.inputs.AlertConditionTermArgs;
    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) {
            final var txn = NewrelicFunctions.getKeyTransaction(GetKeyTransactionArgs.builder()
                .name("txn")
                .build());
    
            var foo = new AlertPolicy("foo", AlertPolicyArgs.builder()
                .name("foo")
                .build());
    
            var fooAlertCondition = new AlertCondition("fooAlertCondition", AlertConditionArgs.builder()
                .policyId(foo.id())
                .name("foo")
                .type("apm_kt_metric")
                .entities(txn.applyValue(getKeyTransactionResult -> getKeyTransactionResult.id()))
                .metric("error_percentage")
                .runbookUrl("https://www.example.com")
                .terms(AlertConditionTermArgs.builder()
                    .duration(5)
                    .operator("below")
                    .priority("critical")
                    .threshold("0.75")
                    .timeFunction("all")
                    .build())
                .build());
    
        }
    }
    
    resources:
      foo:
        type: newrelic:AlertPolicy
        properties:
          name: foo
      fooAlertCondition:
        type: newrelic:AlertCondition
        name: foo
        properties:
          policyId: ${foo.id}
          name: foo
          type: apm_kt_metric
          entities:
            - ${txn.id}
          metric: error_percentage
          runbookUrl: https://www.example.com
          terms:
            - duration: 5
              operator: below
              priority: critical
              threshold: '0.75'
              timeFunction: all
    variables:
      txn:
        fn::invoke:
          Function: newrelic:getKeyTransaction
          Arguments:
            name: txn
    

    Using getKeyTransaction

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getKeyTransaction(args: GetKeyTransactionArgs, opts?: InvokeOptions): Promise<GetKeyTransactionResult>
    function getKeyTransactionOutput(args: GetKeyTransactionOutputArgs, opts?: InvokeOptions): Output<GetKeyTransactionResult>
    def get_key_transaction(name: Optional[str] = None,
                            opts: Optional[InvokeOptions] = None) -> GetKeyTransactionResult
    def get_key_transaction_output(name: Optional[pulumi.Input[str]] = None,
                            opts: Optional[InvokeOptions] = None) -> Output[GetKeyTransactionResult]
    func LookupKeyTransaction(ctx *Context, args *LookupKeyTransactionArgs, opts ...InvokeOption) (*LookupKeyTransactionResult, error)
    func LookupKeyTransactionOutput(ctx *Context, args *LookupKeyTransactionOutputArgs, opts ...InvokeOption) LookupKeyTransactionResultOutput

    > Note: This function is named LookupKeyTransaction in the Go SDK.

    public static class GetKeyTransaction 
    {
        public static Task<GetKeyTransactionResult> InvokeAsync(GetKeyTransactionArgs args, InvokeOptions? opts = null)
        public static Output<GetKeyTransactionResult> Invoke(GetKeyTransactionInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetKeyTransactionResult> getKeyTransaction(GetKeyTransactionArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: newrelic:index/getKeyTransaction:getKeyTransaction
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Name string
    The name of the key transaction in New Relic.
    Name string
    The name of the key transaction in New Relic.
    name String
    The name of the key transaction in New Relic.
    name string
    The name of the key transaction in New Relic.
    name str
    The name of the key transaction in New Relic.
    name String
    The name of the key transaction in New Relic.

    getKeyTransaction Result

    The following output properties are available:

    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    id string
    The provider-assigned unique ID for this managed resource.
    name string
    id str
    The provider-assigned unique ID for this managed resource.
    name str
    id String
    The provider-assigned unique ID for this managed resource.
    name String

    Package Details

    Repository
    New Relic pulumi/pulumi-newrelic
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the newrelic Terraform Provider.
    newrelic logo
    New Relic v5.33.0 published on Thursday, Sep 26, 2024 by Pulumi