1. Packages
  2. New Relic
  3. API Docs
  4. getEntity
New Relic v5.22.0 published on Wednesday, Mar 27, 2024 by Pulumi

newrelic.getEntity

Explore with Pulumi AI

newrelic logo
New Relic v5.22.0 published on Wednesday, Mar 27, 2024 by Pulumi

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

    Example: Filter By Account ID

    The default behaviour of this data source is to retrieve entities matching the specified parameters (such as name, domain, type) from NerdGraph with the credentials specified in the configuration of the provider (account ID and API Key), filter them by the account ID specified in the configuration of the provider, and return the first match.

    This would mean, if no entity with the specified search parameters is found associated with the account ID in the configuration of the provider, i.e. NEW_RELIC_ACCOUNT_ID, an error is thrown, stating that no matching entity has been found.

    import * as pulumi from "@pulumi/pulumi";
    import * as newrelic from "@pulumi/newrelic";
    
    const app = newrelic.getEntity({
        domain: "APM",
        name: "my-app",
        type: "APPLICATION",
    });
    
    import pulumi
    import pulumi_newrelic as newrelic
    
    app = newrelic.get_entity(domain="APM",
        name="my-app",
        type="APPLICATION")
    
    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 {
    		_, err := newrelic.GetEntity(ctx, &newrelic.GetEntityArgs{
    			Domain: pulumi.StringRef("APM"),
    			Name:   "my-app",
    			Type:   pulumi.StringRef("APPLICATION"),
    		}, nil)
    		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 app = NewRelic.GetEntity.Invoke(new()
        {
            Domain = "APM",
            Name = "my-app",
            Type = "APPLICATION",
        });
    
    });
    
    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 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 app = NewrelicFunctions.getEntity(GetEntityArgs.builder()
                .domain("APM")
                .name("my-app")
                .type("APPLICATION")
                .build());
    
        }
    }
    
    variables:
      app:
        fn::invoke:
          Function: newrelic:getEntity
          Arguments:
            domain: APM
            name: my-app
            type: APPLICATION
    

    However, in order to cater to scenarios in which it could be necessary to retrieve an entity belonging to a subaccount using the account ID and API Key of the parent account (for instance, when entities with identical names are present in both the parent account and subaccounts, since matching entities from subaccounts too are returned by NerdGraph), the account_id attribute of this data source may be availed. This ensures that the account ID in the configuration of the provider, used to filter entities returned by the API is now overridden by the account_id specified in the configuration; i.e., in the below example, the data source would now return an entity matching the specified name, belonging to the account with the ID account_id.

    import * as pulumi from "@pulumi/pulumi";
    import * as newrelic from "@pulumi/newrelic";
    
    const app = newrelic.getEntity({
        accountId: 654321,
        domain: "APM",
        name: "my-app",
        type: "APPLICATION",
    });
    
    import pulumi
    import pulumi_newrelic as newrelic
    
    app = newrelic.get_entity(account_id=654321,
        domain="APM",
        name="my-app",
        type="APPLICATION")
    
    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 {
    		_, err := newrelic.GetEntity(ctx, &newrelic.GetEntityArgs{
    			AccountId: pulumi.IntRef(654321),
    			Domain:    pulumi.StringRef("APM"),
    			Name:      "my-app",
    			Type:      pulumi.StringRef("APPLICATION"),
    		}, nil)
    		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 app = NewRelic.GetEntity.Invoke(new()
        {
            AccountId = 654321,
            Domain = "APM",
            Name = "my-app",
            Type = "APPLICATION",
        });
    
    });
    
    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 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 app = NewrelicFunctions.getEntity(GetEntityArgs.builder()
                .accountId(654321)
                .domain("APM")
                .name("my-app")
                .type("APPLICATION")
                .build());
    
        }
    }
    
    variables:
      app:
        fn::invoke:
          Function: newrelic:getEntity
          Arguments:
            accountId: 654321
            domain: APM
            name: my-app
            type: APPLICATION
    

    The following example explains a use case along the lines of the aforementioned; using the account_id argument in the data source to allow the filtering criteria to be the account_id specified (of the subaccount), and not the account ID in the provider configuration.

    In simpler terms, when entities are queried from the parent account, entities with matching names are returned from subaccounts too, hence, specifying the account_id of the subaccount in the configuration allows the entity returned to belong to the subaccount with account_id.

    Query for an OTEL entity

    import * as pulumi from "@pulumi/pulumi";
    import * as newrelic from "@pulumi/newrelic";
    
    const app = newrelic.getEntity({
        domain: "EXT",
        name: "my-otel-app",
        tags: [{
            key: "accountID",
            value: "12345",
        }],
        type: "SERVICE",
    });
    
    import pulumi
    import pulumi_newrelic as newrelic
    
    app = newrelic.get_entity(domain="EXT",
        name="my-otel-app",
        tags=[newrelic.GetEntityTagArgs(
            key="accountID",
            value="12345",
        )],
        type="SERVICE")
    
    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 {
    		_, err := newrelic.GetEntity(ctx, &newrelic.GetEntityArgs{
    			Domain: pulumi.StringRef("EXT"),
    			Name:   "my-otel-app",
    			Tags: []newrelic.GetEntityTag{
    				{
    					Key:   "accountID",
    					Value: "12345",
    				},
    			},
    			Type: pulumi.StringRef("SERVICE"),
    		}, nil)
    		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 app = NewRelic.GetEntity.Invoke(new()
        {
            Domain = "EXT",
            Name = "my-otel-app",
            Tags = new[]
            {
                new NewRelic.Inputs.GetEntityTagInputArgs
                {
                    Key = "accountID",
                    Value = "12345",
                },
            },
            Type = "SERVICE",
        });
    
    });
    
    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 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 app = NewrelicFunctions.getEntity(GetEntityArgs.builder()
                .domain("EXT")
                .name("my-otel-app")
                .tags(GetEntityTagArgs.builder()
                    .key("accountID")
                    .value("12345")
                    .build())
                .type("SERVICE")
                .build());
    
        }
    }
    
    variables:
      app:
        fn::invoke:
          Function: newrelic:getEntity
          Arguments:
            domain: EXT
            name: my-otel-app
            tags:
              - key: accountID
                value: '12345'
            type: SERVICE
    

    Query for an entity by type (AWS Lambda entity in this example)

    import * as pulumi from "@pulumi/pulumi";
    import * as newrelic from "@pulumi/newrelic";
    
    const app = newrelic.getEntity({
        name: "my_lambda_trace",
        type: "AWSLAMBDAFUNCTION",
    });
    
    import pulumi
    import pulumi_newrelic as newrelic
    
    app = newrelic.get_entity(name="my_lambda_trace",
        type="AWSLAMBDAFUNCTION")
    
    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 {
    		_, err := newrelic.GetEntity(ctx, &newrelic.GetEntityArgs{
    			Name: "my_lambda_trace",
    			Type: pulumi.StringRef("AWSLAMBDAFUNCTION"),
    		}, nil)
    		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 app = NewRelic.GetEntity.Invoke(new()
        {
            Name = "my_lambda_trace",
            Type = "AWSLAMBDAFUNCTION",
        });
    
    });
    
    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 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 app = NewrelicFunctions.getEntity(GetEntityArgs.builder()
                .name("my_lambda_trace")
                .type("AWSLAMBDAFUNCTION")
                .build());
    
        }
    }
    
    variables:
      app:
        fn::invoke:
          Function: newrelic:getEntity
          Arguments:
            name: my_lambda_trace
            type: AWSLAMBDAFUNCTION
    

    Using getEntity

    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 getEntity(args: GetEntityArgs, opts?: InvokeOptions): Promise<GetEntityResult>
    function getEntityOutput(args: GetEntityOutputArgs, opts?: InvokeOptions): Output<GetEntityResult>
    def get_entity(account_id: Optional[int] = None,
                   domain: Optional[str] = None,
                   ignore_case: Optional[bool] = None,
                   name: Optional[str] = None,
                   tags: Optional[Sequence[GetEntityTag]] = None,
                   type: Optional[str] = None,
                   opts: Optional[InvokeOptions] = None) -> GetEntityResult
    def get_entity_output(account_id: Optional[pulumi.Input[int]] = None,
                   domain: Optional[pulumi.Input[str]] = None,
                   ignore_case: Optional[pulumi.Input[bool]] = None,
                   name: Optional[pulumi.Input[str]] = None,
                   tags: Optional[pulumi.Input[Sequence[pulumi.Input[GetEntityTagArgs]]]] = None,
                   type: Optional[pulumi.Input[str]] = None,
                   opts: Optional[InvokeOptions] = None) -> Output[GetEntityResult]
    func GetEntity(ctx *Context, args *GetEntityArgs, opts ...InvokeOption) (*GetEntityResult, error)
    func GetEntityOutput(ctx *Context, args *GetEntityOutputArgs, opts ...InvokeOption) GetEntityResultOutput

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

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

    The following arguments are supported:

    Name string
    The name of the entity in New Relic One. The first entity matching this name for the given search parameters will be returned.
    AccountId int
    The New Relic account ID the entity to be returned would be associated with, i.e. if specified, the data source would filter matching entities received by account_id and return the first match. If not, matching entities are filtered by the account ID specified in the configuration of the provider. See the Example: Filter By Account ID section above for more details.
    Domain string
    The entity's domain. Valid values are APM, BROWSER, INFRA, MOBILE, SYNTH, and EXT. If not specified, all domains are searched.
    IgnoreCase bool
    Ignore case of the name when searching for the entity. Defaults to false.
    Tags List<Pulumi.NewRelic.Inputs.GetEntityTag>
    A tag applied to the entity. See Nested tag blocks below for details.
    Type string
    The entity's type. Valid values are APPLICATION, DASHBOARD, HOST, MONITOR, WORKLOAD, AWSLAMBDAFUNCTION, SERVICE_LEVEL, and KEY_TRANSACTION. Note: Other entity types may also be queryable as the list of entity types may fluctuate over time.
    Name string
    The name of the entity in New Relic One. The first entity matching this name for the given search parameters will be returned.
    AccountId int
    The New Relic account ID the entity to be returned would be associated with, i.e. if specified, the data source would filter matching entities received by account_id and return the first match. If not, matching entities are filtered by the account ID specified in the configuration of the provider. See the Example: Filter By Account ID section above for more details.
    Domain string
    The entity's domain. Valid values are APM, BROWSER, INFRA, MOBILE, SYNTH, and EXT. If not specified, all domains are searched.
    IgnoreCase bool
    Ignore case of the name when searching for the entity. Defaults to false.
    Tags []GetEntityTag
    A tag applied to the entity. See Nested tag blocks below for details.
    Type string
    The entity's type. Valid values are APPLICATION, DASHBOARD, HOST, MONITOR, WORKLOAD, AWSLAMBDAFUNCTION, SERVICE_LEVEL, and KEY_TRANSACTION. Note: Other entity types may also be queryable as the list of entity types may fluctuate over time.
    name String
    The name of the entity in New Relic One. The first entity matching this name for the given search parameters will be returned.
    accountId Integer
    The New Relic account ID the entity to be returned would be associated with, i.e. if specified, the data source would filter matching entities received by account_id and return the first match. If not, matching entities are filtered by the account ID specified in the configuration of the provider. See the Example: Filter By Account ID section above for more details.
    domain String
    The entity's domain. Valid values are APM, BROWSER, INFRA, MOBILE, SYNTH, and EXT. If not specified, all domains are searched.
    ignoreCase Boolean
    Ignore case of the name when searching for the entity. Defaults to false.
    tags List<GetEntityTag>
    A tag applied to the entity. See Nested tag blocks below for details.
    type String
    The entity's type. Valid values are APPLICATION, DASHBOARD, HOST, MONITOR, WORKLOAD, AWSLAMBDAFUNCTION, SERVICE_LEVEL, and KEY_TRANSACTION. Note: Other entity types may also be queryable as the list of entity types may fluctuate over time.
    name string
    The name of the entity in New Relic One. The first entity matching this name for the given search parameters will be returned.
    accountId number
    The New Relic account ID the entity to be returned would be associated with, i.e. if specified, the data source would filter matching entities received by account_id and return the first match. If not, matching entities are filtered by the account ID specified in the configuration of the provider. See the Example: Filter By Account ID section above for more details.
    domain string
    The entity's domain. Valid values are APM, BROWSER, INFRA, MOBILE, SYNTH, and EXT. If not specified, all domains are searched.
    ignoreCase boolean
    Ignore case of the name when searching for the entity. Defaults to false.
    tags GetEntityTag[]
    A tag applied to the entity. See Nested tag blocks below for details.
    type string
    The entity's type. Valid values are APPLICATION, DASHBOARD, HOST, MONITOR, WORKLOAD, AWSLAMBDAFUNCTION, SERVICE_LEVEL, and KEY_TRANSACTION. Note: Other entity types may also be queryable as the list of entity types may fluctuate over time.
    name str
    The name of the entity in New Relic One. The first entity matching this name for the given search parameters will be returned.
    account_id int
    The New Relic account ID the entity to be returned would be associated with, i.e. if specified, the data source would filter matching entities received by account_id and return the first match. If not, matching entities are filtered by the account ID specified in the configuration of the provider. See the Example: Filter By Account ID section above for more details.
    domain str
    The entity's domain. Valid values are APM, BROWSER, INFRA, MOBILE, SYNTH, and EXT. If not specified, all domains are searched.
    ignore_case bool
    Ignore case of the name when searching for the entity. Defaults to false.
    tags Sequence[GetEntityTag]
    A tag applied to the entity. See Nested tag blocks below for details.
    type str
    The entity's type. Valid values are APPLICATION, DASHBOARD, HOST, MONITOR, WORKLOAD, AWSLAMBDAFUNCTION, SERVICE_LEVEL, and KEY_TRANSACTION. Note: Other entity types may also be queryable as the list of entity types may fluctuate over time.
    name String
    The name of the entity in New Relic One. The first entity matching this name for the given search parameters will be returned.
    accountId Number
    The New Relic account ID the entity to be returned would be associated with, i.e. if specified, the data source would filter matching entities received by account_id and return the first match. If not, matching entities are filtered by the account ID specified in the configuration of the provider. See the Example: Filter By Account ID section above for more details.
    domain String
    The entity's domain. Valid values are APM, BROWSER, INFRA, MOBILE, SYNTH, and EXT. If not specified, all domains are searched.
    ignoreCase Boolean
    Ignore case of the name when searching for the entity. Defaults to false.
    tags List<Property Map>
    A tag applied to the entity. See Nested tag blocks below for details.
    type String
    The entity's type. Valid values are APPLICATION, DASHBOARD, HOST, MONITOR, WORKLOAD, AWSLAMBDAFUNCTION, SERVICE_LEVEL, and KEY_TRANSACTION. Note: Other entity types may also be queryable as the list of entity types may fluctuate over time.

    getEntity Result

    The following output properties are available:

    AccountId int
    ApplicationId int
    The domain-specific application ID of the entity. Only returned for APM and Browser applications.
    Domain string
    Guid string
    The unique GUID of the entity.
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    ServingApmApplicationId int
    The browser-specific ID of the backing APM entity. Only returned for Browser applications.
    Type string
    IgnoreCase bool
    Tags List<Pulumi.NewRelic.Outputs.GetEntityTag>
    AccountId int
    ApplicationId int
    The domain-specific application ID of the entity. Only returned for APM and Browser applications.
    Domain string
    Guid string
    The unique GUID of the entity.
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    ServingApmApplicationId int
    The browser-specific ID of the backing APM entity. Only returned for Browser applications.
    Type string
    IgnoreCase bool
    Tags []GetEntityTag
    accountId Integer
    applicationId Integer
    The domain-specific application ID of the entity. Only returned for APM and Browser applications.
    domain String
    guid String
    The unique GUID of the entity.
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    servingApmApplicationId Integer
    The browser-specific ID of the backing APM entity. Only returned for Browser applications.
    type String
    ignoreCase Boolean
    tags List<GetEntityTag>
    accountId number
    applicationId number
    The domain-specific application ID of the entity. Only returned for APM and Browser applications.
    domain string
    guid string
    The unique GUID of the entity.
    id string
    The provider-assigned unique ID for this managed resource.
    name string
    servingApmApplicationId number
    The browser-specific ID of the backing APM entity. Only returned for Browser applications.
    type string
    ignoreCase boolean
    tags GetEntityTag[]
    account_id int
    application_id int
    The domain-specific application ID of the entity. Only returned for APM and Browser applications.
    domain str
    guid str
    The unique GUID of the entity.
    id str
    The provider-assigned unique ID for this managed resource.
    name str
    serving_apm_application_id int
    The browser-specific ID of the backing APM entity. Only returned for Browser applications.
    type str
    ignore_case bool
    tags Sequence[GetEntityTag]
    accountId Number
    applicationId Number
    The domain-specific application ID of the entity. Only returned for APM and Browser applications.
    domain String
    guid String
    The unique GUID of the entity.
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    servingApmApplicationId Number
    The browser-specific ID of the backing APM entity. Only returned for Browser applications.
    type String
    ignoreCase Boolean
    tags List<Property Map>

    Supporting Types

    GetEntityTag

    Key string
    The tag key.
    Value string
    The tag value.
    Key string
    The tag key.
    Value string
    The tag value.
    key String
    The tag key.
    value String
    The tag value.
    key string
    The tag key.
    value string
    The tag value.
    key str
    The tag key.
    value str
    The tag value.
    key String
    The tag key.
    value String
    The tag value.

    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.22.0 published on Wednesday, Mar 27, 2024 by Pulumi