Skip to content

Commit

Permalink
docs(entity): update verbiage
Browse files Browse the repository at this point in the history
  • Loading branch information
pranav-new-relic committed Jun 5, 2024
1 parent 74d6aad commit 9ebcc94
Showing 1 changed file with 32 additions and 29 deletions.
61 changes: 32 additions & 29 deletions website/docs/d/entity.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,42 @@ In addition to all arguments above, the following attributes are exported:
* `guid` - The unique GUID of the entity.
* `application_id` - The domain-specific application ID of the entity. Only returned for APM and Browser applications.
* `serving_apm_application_id` - The browser-specific ID of the backing APM entity. Only returned for Browser applications.
* `entity_tags` - The `entity_tags` helps retrieve tags associated with the entity fetched by the data source, the tags are returned as a JSON-encoded string and not a conventional list or a map, owing to a couple of design considerations; which is why one would need to use the Terraform function `jsondecode()`, along with the attribute entity_tags in order to convert the JSON-encoded string into a map with key-value pairs.

* `entity_tags` - A JSON-encoded string, comprising tags associated with the entity fetched.
* See the [**Additional Examples**](#using-the-entity_tags-attribute-to-fetch-tags-associated-with-the-entity) section below, for an illustration depicting the usage of `jsondecode` with the attribute `entity_tags`, to get the tags associated with the entity fetched.

## Additional Examples

-> If the entities are not found please try again without providing the `type` field.

### Entity Tags
### Query for an OTEL entity

```hcl
data "newrelic_entity" "app" {
name = "my-otel-app"
domain = "EXT"
type = "SERVICE"
tag {
key = "accountID"
value = "12345"
}
}
```

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

```hcl
data "newrelic_entity" "app" {
name = "my_lambda_trace"
type = "AWSLAMBDAFUNCTION"
}
```

### Using the `entity_tags` Attribute to Fetch Tags Associated with the Entity

As stated above in the [**Attributes Reference**](#attributes-reference) section, while the attribute `entity_tags` helps retrieve tags associated with the entity fetched by the data source, the tags are returned as a JSON-encoded string and not a conventional list or a map, owing to a couple of design considerations; which is why one would need to use the Terraform function `jsondecode()`, along with the attribute `entity_tags` in order to convert the JSON-encoded string into a map with key-value pairs.

* The following is an illustration of the aforementioned scenario. It may be observed that a key-value pair version of the JSON-encoded string exported by `entity_tags` is written to the variable `key_value_maps` , using the `jsondecode()` function.
The following is an illustration of the aforementioned scenario. It may be observed that a key-value pair version of the JSON-encoded string exported by `entity_tags` is written to the variable `key_value_maps` , using the `jsondecode()` function.

```hcl
data "newrelic_entity" "foo" {
Expand All @@ -190,9 +216,9 @@ locals {
output "key_value_map" {
value = local.key_value_map
}
```
The value of `local.key_value_map` would look like the following.
```
The value of `local.key_value_map` would look like the following.
```hcl
{
env = ["production"]
Expand All @@ -208,26 +234,3 @@ locals {
}
```

### Query for an OTEL entity

```hcl
data "newrelic_entity" "app" {
name = "my-otel-app"
domain = "EXT"
type = "SERVICE"
tag {
key = "accountID"
value = "12345"
}
}
```

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

```hcl
data "newrelic_entity" "app" {
name = "my_lambda_trace"
type = "AWSLAMBDAFUNCTION"
}
```

0 comments on commit 9ebcc94

Please sign in to comment.