---
title: "otelcol.processor.resourcedetection | Grafana Agent documentation"
description: "Learn about otelcol.processor.resourcedetection"
---

# otelcol.processor.resourcedetection

> **BETA**: This is a [beta](/docs/agent/v0.43/stability/#beta) component. Beta components are subject to breaking changes, and may be replaced with equivalent functionality that cover the same use case.

`otelcol.processor.resourcedetection` detects resource information from the host in a format that conforms to the [OpenTelemetry resource semantic conventions](https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/resource/semantic_conventions/), and appends or overrides the resource values in the telemetry data with this information.

> Note
> 
> `otelcol.processor.resourcedetection` is a wrapper over the upstream OpenTelemetry Collector Contrib `resourcedetection` processor. If necessary, bug reports or feature requests are redirected to the upstream repository.

You can specify multiple `otelcol.processor.resourcedetection` components by giving them different labels.

## Usage

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
otelcol.processor.resourcedetection "LABEL" {
  output {
    logs    = [...]
    metrics = [...]
    traces  = [...]
  }
}
```

## Arguments

`otelcol.processor.resourcedetection` supports the following arguments:

Expand table

| Name        | Type           | Description                                                                        | Default   | Required |
|-------------|----------------|------------------------------------------------------------------------------------|-----------|----------|
| `detectors` | `list(string)` | An ordered list of named detectors used to detect resource information.            | `["env"]` | no       |
| `override`  | `bool`         | Configures whether existing resource attributes should be overridden or preserved. | `true`    | no       |
| `timeout`   | `duration`     | Timeout by which all specified detectors must complete.                            | `"5s"`    | no       |

`detectors` could contain the following values:

- `env`
- `ec2`
- `ecs`
- `eks`
- `elasticbeanstalk`
- `lambda`
- `azure`
- `aks`
- `consul`
- `docker`
- `gcp`
- `heroku`
- `system`
- `openshift`
- `kubernetes_node`

`env` is the only detector that is not configured through a River block. The `env` detector reads resource information from the `OTEL_RESOURCE_ATTRIBUTES` environment variable. This variable must be in the format `<key1>=<value1>,<key2>=<value2>,...`, the details of which are currently pending confirmation in the OpenTelemetry specification.

If a detector other than `env` is needed, you can customize it with the relevant River block. For example, you can customize the `ec2` detector with the [ec2](#ec2) block. If you omit the [ec2](#ec2) block, the defaults specified in the [ec2](#ec2) block documentation are used.

If multiple detectors are inserting the same attribute name, the first detector to insert wins. For example, if you had `detectors = ["eks", "ec2"]` then `cloud.platform` will be `aws_eks` instead of `ec2`.

The following order is recommended for AWS:

1. [lambda](#lambda)
2. [elasticbeanstalk](#elasticbeanstalk)
3. [eks](#eks)
4. [ecs](#ecs)
5. [ec2](#ec2)

## Blocks

The following blocks are supported inside the definition of `otelcol.processor.resourcedetection`:

Expand table

| Hierarchy        | Block                                 | Description                                       | Required |
|------------------|---------------------------------------|---------------------------------------------------|----------|
| output           | [output](#output)                     | Configures where to send received telemetry data. | yes      |
| ec2              | [ec2](#ec2)                           |                                                   | no       |
| ecs              | [ecs](#ecs)                           |                                                   | no       |
| eks              | [eks](#eks)                           |                                                   | no       |
| elasticbeanstalk | [elasticbeanstalk](#elasticbeanstalk) |                                                   | no       |
| lambda           | [lambda](#lambda)                     |                                                   | no       |
| azure            | [azure](#azure)                       |                                                   | no       |
| aks              | [aks](#aks)                           |                                                   | no       |
| consul           | [consul](#consul)                     |                                                   | no       |
| docker           | [docker](#docker)                     |                                                   | no       |
| gcp              | [gcp](#gcp)                           |                                                   | no       |
| heroku           | [heroku](#heroku)                     |                                                   | no       |
| system           | [system](#system)                     |                                                   | no       |
| openshift        | [openshift](#openshift)               |                                                   | no       |
| kubernetes\_node | [kubernetes\_node](#kubernetes_node)  |                                                   | no       |

### output

The `output` block configures a set of components to forward resulting telemetry data to.

The following arguments are supported:

Expand table

| Name      | Type                     | Description                           | Default | Required |
|-----------|--------------------------|---------------------------------------|---------|----------|
| `logs`    | `list(otelcol.Consumer)` | List of consumers to send logs to.    | `[]`    | no       |
| `metrics` | `list(otelcol.Consumer)` | List of consumers to send metrics to. | `[]`    | no       |
| `traces`  | `list(otelcol.Consumer)` | List of consumers to send traces to.  | `[]`    | no       |

You must specify the `output` block, but all its arguments are optional. By default, telemetry data is dropped. Configure the `metrics`, `logs`, and `traces` arguments accordingly to send telemetry data to other components.

### ec2

The `ec2` block reads resource information from the [EC2 instance metadata API](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html) using the [AWS SDK for Go](https://docs.aws.amazon.com/sdk-for-go/api/aws/ec2metadata/).

The `ec2` block supports the following attributes:

Expand table

| Attribute | Type           | Description                                                                 | Default | Required |
|-----------|----------------|-----------------------------------------------------------------------------|---------|----------|
| `tags`    | `list(string)` | A list of regular expressions to match against tag keys of an EC2 instance. | `[]`    | no       |

If you are using a proxy server on your EC2 instance, it’s important that you exempt requests for instance metadata as described in the [AWS cli user guide](https://github.com/awsdocs/aws-cli-user-guide/blob/a2393582590b64bd2a1d9978af15b350e1f9eb8e/doc_source/cli-configure-proxy.md#using-a-proxy-on-amazon-ec2-instances). Failing to do so can result in proxied or missing instance data.

If the instance is part of AWS ParallelCluster and the detector is failing to connect to the metadata server, check the iptable and make sure the chain `PARALLELCLUSTER_IMDS` contains a rule that allows the Grafana Agent user to access `169.254.169.254/32`.

`tags` can be used to gather tags for the EC2 instance which Grafana Agent is running on. To fetch EC2 tags, the IAM role assigned to the EC2 instance must have a policy that includes the `ec2:DescribeTags` permission.

The `ec2` block supports the following blocks:

Expand table

| Block                                             | Description                                  | Required |
|---------------------------------------------------|----------------------------------------------|----------|
| [resource\_attributes](#ec2--resource_attributes) | Configures which resource attributes to add. | no       |

##### ec2 &gt; resource\_attributes

The `resource_attributes` block supports the following blocks:

Expand table

| Block                                                  | Description                                                                                           | Required |
|--------------------------------------------------------|-------------------------------------------------------------------------------------------------------|----------|
| [cloud.account.id](#resource-attribute-config)         | Toggles the `cloud.account.id` resource attribute.  <br />Sets `enabled` to `true` by default.        | no       |
| [cloud.availability\_zone](#resource-attribute-config) | Toggles the `cloud.availability_zone` resource attribute.  <br />Sets `enabled` to `true` by default. | no       |
| [cloud.platform](#resource-attribute-config)           | Toggles the `cloud.platform` resource attribute.  <br />Sets `enabled` to `true` by default.          | no       |
| [cloud.provider](#resource-attribute-config)           | Toggles the `cloud.provider` resource attribute.  <br />Sets `enabled` to `true` by default.          | no       |
| [cloud.region](#resource-attribute-config)             | Toggles the `cloud.region` resource attribute.  <br />Sets `enabled` to `true` by default.            | no       |
| [host.id](#resource-attribute-config)                  | Toggles the `host.id` resource attribute.  <br />Sets `enabled` to `true` by default.                 | no       |
| [host.image.id](#resource-attribute-config)            | Toggles the `host.image.id` resource attribute.  <br />Sets `enabled` to `true` by default.           | no       |
| [host.name](#resource-attribute-config)                | Toggles the `host.name` resource attribute.  <br />Sets `enabled` to `true` by default.               | no       |
| [host.type](#resource-attribute-config)                | Toggles the `host.type` resource attribute.  <br />Sets `enabled` to `true` by default.               | no       |

### ecs

The `ecs` block queries the Task Metadata Endpoint (TMDE) to record information about the current ECS Task. Only TMDE V4 and V3 are supported.

The `ecs` block supports the following blocks:

Expand table

| Block                                             | Description                                  | Required |
|---------------------------------------------------|----------------------------------------------|----------|
| [resource\_attributes](#ecs--resource_attributes) | Configures which resource attributes to add. | no       |

#### ecs &gt; resource\_attributes

The `resource_attributes` block supports the following blocks:

Expand table

| Block                                                  | Description                                                                                           | Required |
|--------------------------------------------------------|-------------------------------------------------------------------------------------------------------|----------|
| [aws.ecs.cluster.arn](#resource-attribute-config)      | Toggles the `aws.ecs.cluster.arn` resource attribute.  <br />Sets `enabled` to `true` by default.     | no       |
| [aws.ecs.launchtype](#resource-attribute-config)       | Toggles the `aws.ecs.launchtype` resource attribute.  <br />Sets `enabled` to `true` by default.      | no       |
| [aws.ecs.task.arn](#resource-attribute-config)         | Toggles the `aws.ecs.task.arn` resource attribute.  <br />Sets `enabled` to `true` by default.        | no       |
| [aws.ecs.task.family](#resource-attribute-config)      | Toggles the `aws.ecs.task.family` resource attribute.  <br />Sets `enabled` to `true` by default.     | no       |
| [aws.ecs.task.id](#resource-attribute-config)          | Toggles the `aws.ecs.task.id` resource attribute.  <br />Sets `enabled` to `true` by default.         | no       |
| [aws.ecs.task.revision](#resource-attribute-config)    | Toggles the `aws.ecs.task.revision` resource attribute.  <br />Sets `enabled` to `true` by default.   | no       |
| [aws.log.group.arns](#resource-attribute-config)       | Toggles the `aws.log.group.arns` resource attribute.  <br />Sets `enabled` to `true` by default.      | no       |
| [aws.log.group.names](#resource-attribute-config)      | Toggles the `aws.log.group.names` resource attribute.  <br />Sets `enabled` to `true` by default.     | no       |
| [aws.log.stream.arns](#resource-attribute-config)      | Toggles the `aws.log.stream.arns` resource attribute.  <br />Sets `enabled` to `true` by default.     | no       |
| [aws.log.stream.names](#resource-attribute-config)     | Toggles the `aws.log.stream.names` resource attribute.  <br />Sets `enabled` to `true` by default.    | no       |
| [cloud.account.id](#resource-attribute-config)         | Toggles the `cloud.account.id` resource attribute.  <br />Sets `enabled` to `true` by default.        | no       |
| [cloud.availability\_zone](#resource-attribute-config) | Toggles the `cloud.availability_zone` resource attribute.  <br />Sets `enabled` to `true` by default. | no       |
| [cloud.platform](#resource-attribute-config)           | Toggles the `cloud.platform` resource attribute.  <br />Sets `enabled` to `true` by default.          | no       |
| [cloud.provider](#resource-attribute-config)           | Toggles the `cloud.provider` resource attribute.  <br />Sets `enabled` to `true` by default.          | no       |
| [cloud.region](#resource-attribute-config)             | Toggles the `cloud.region` resource attribute.  <br />Sets `enabled` to `true` by default.            | no       |

### eks

The `eks` block adds resource attributes for Amazon EKS.

The `eks` block supports the following blocks:

Expand table

| Block                                             | Description                                  | Required |
|---------------------------------------------------|----------------------------------------------|----------|
| [resource\_attributes](#eks--resource_attributes) | Configures which resource attributes to add. | no       |

#### eks &gt; resource\_attributes

The `resource_attributes` block supports the following blocks:

Expand table

| Block                                          | Description                                                                                     | Required |
|------------------------------------------------|-------------------------------------------------------------------------------------------------|----------|
| [cloud.platform](#resource-attribute-config)   | Toggles the `cloud.platform` resource attribute.  <br />Sets `enabled` to `true` by default.    | no       |
| [cloud.provider](#resource-attribute-config)   | Toggles the `cloud.provider` resource attribute.  <br />Sets `enabled` to `true` by default.    | no       |
| [k8s.cluster.name](#resource-attribute-config) | Toggles the `k8s.cluster.name` resource attribute.  <br />Sets `enabled` to `false` by default. | no       |

Example values:

- `cloud.provider`: `"aws"`
- `cloud.platform`: `"aws_eks"`

### elasticbeanstalk

The `elasticbeanstalk` block reads the AWS X-Ray configuration file available on all Beanstalk instances with [X-Ray Enabled](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-configuration-debugging.html).

The `elasticbeanstalk` block supports the following blocks:

Expand table

| Block                                                          | Description                                  | Required |
|----------------------------------------------------------------|----------------------------------------------|----------|
| [resource\_attributes](#elasticbeanstalk--resource_attributes) | Configures which resource attributes to add. | no       |

#### elasticbeanstalk &gt; resource\_attributes

The `resource_attributes` block supports the following blocks:

Expand table

| Block                                          | Description                                                                                    | Required |
|------------------------------------------------|------------------------------------------------------------------------------------------------|----------|
| [cloud.platform](#resource-attribute-config)   | Toggles the `cloud.platform` resource attribute.  <br />Sets `enabled` to `true` by default.   | no       |
| [cloud.provider](#resource-attribute-config)   | Toggles the `cloud.provider` resource attribute.  <br />Sets `enabled` to `true` by default.   | no       |
| [deployment.envir](#resource-attribute-config) | Toggles the `deployment.envir` resource attribute.  <br />Sets `enabled` to `true` by default. | no       |
| [service.instance](#resource-attribute-config) | Toggles the `service.instance` resource attribute.  <br />Sets `enabled` to `true` by default. | no       |
| [service.version](#resource-attribute-config)  | Toggles the `service.version` resource attribute.  <br />Sets `enabled` to `true` by default.  | no       |

Example values:

- `cloud.provider`: `"aws"`
- `cloud.platform`: `"aws_elastic_beanstalk"`

### lambda

The `lambda` block uses the AWS Lambda [runtime environment variables](https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-runtime) to retrieve various resource attributes.

The `lambda` block supports the following blocks:

Expand table

| Block                                                | Description                                  | Required |
|------------------------------------------------------|----------------------------------------------|----------|
| [resource\_attributes](#lambda--resource_attributes) | Configures which resource attributes to add. | no       |

#### lambda &gt; resource\_attributes

The `resource_attributes` block supports the following blocks:

Expand table

| Block                                              | Description                                                                                        | Required |
|----------------------------------------------------|----------------------------------------------------------------------------------------------------|----------|
| [aws.log.group.names](#resource-attribute-config)  | Toggles the `aws.log.group.names` resource attribute.  <br />Sets `enabled` to `true` by default.  | no       |
| [aws.log.stream.names](#resource-attribute-config) | Toggles the `aws.log.stream.names` resource attribute.  <br />Sets `enabled` to `true` by default. | no       |
| [cloud.platform](#resource-attribute-config)       | Toggles the `cloud.platform` resource attribute.  <br />Sets `enabled` to `true` by default.       | no       |
| [cloud.provider](#resource-attribute-config)       | Toggles the `cloud.provider` resource attribute.  <br />Sets `enabled` to `true` by default.       | no       |
| [cloud.region](#resource-attribute-config)         | Toggles the `cloud.region` resource attribute.  <br />Sets `enabled` to `true` by default.         | no       |
| [faas.instance](#resource-attribute-config)        | Toggles the `faas.instance` resource attribute.  <br />Sets `enabled` to `true` by default.        | no       |
| [faas.max\_memory](#resource-attribute-config)     | Toggles the `faas.max_memory` resource attribute.  <br />Sets `enabled` to `true` by default.      | no       |
| [faas.name](#resource-attribute-config)            | Toggles the `faas.name` resource attribute.  <br />Sets `enabled` to `true` by default.            | no       |
| [faas.version](#resource-attribute-config)         | Toggles the `faas.version` resource attribute.  <br />Sets `enabled` to `true` by default.         | no       |

[Cloud semantic conventions](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/cloud.md):

- `cloud.provider`: `"aws"`
- `cloud.platform`: `"aws_lambda"`
- `cloud.region`: `$AWS_REGION`

[Function as a Service semantic conventions](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/faas.md) and [AWS Lambda semantic conventions](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/instrumentation/aws-lambda.md#resource-detector):

- `faas.name`: `$AWS_LAMBDA_FUNCTION_NAME`
- `faas.version`: `$AWS_LAMBDA_FUNCTION_VERSION`
- `faas.instance`: `$AWS_LAMBDA_LOG_STREAM_NAME`
- `faas.max_memory`: `$AWS_LAMBDA_FUNCTION_MEMORY_SIZE`

[AWS Logs semantic conventions](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/cloud_provider/aws/logs.md):

- `aws.log.group.names`: `$AWS_LAMBDA_LOG_GROUP_NAME`
- `aws.log.stream.names`: `$AWS_LAMBDA_LOG_STREAM_NAME`

### azure

The `azure` block queries the [Azure Instance Metadata Service](https://aka.ms/azureimds) to retrieve various resource attributes.

The `azure` block supports the following blocks:

Expand table

| Block                                               | Description                                  | Required |
|-----------------------------------------------------|----------------------------------------------|----------|
| [resource\_attributes](#azure--resource_attributes) | Configures which resource attributes to add. | no       |

#### azure &gt; resource\_attributes

The `resource_attributes` block supports the following blocks:

Expand table

| Block                                                  | Description                                                                                            | Required |
|--------------------------------------------------------|--------------------------------------------------------------------------------------------------------|----------|
| [azure.resourcegroup.name](#resource-attribute-config) | Toggles the `azure.resourcegroup.name` resource attribute.  <br />Sets `enabled` to `true` by default. | no       |
| [azure.vm.name](#resource-attribute-config)            | Toggles the `azure.vm.name` resource attribute.  <br />Sets `enabled` to `true` by default.            | no       |
| [azure.vm.scaleset.name](#resource-attribute-config)   | Toggles the `azure.vm.scaleset.name` resource attribute.  <br />Sets `enabled` to `true` by default.   | no       |
| [azure.vm.size](#resource-attribute-config)            | Toggles the `azure.vm.size` resource attribute.  <br />Sets `enabled` to `true` by default.            | no       |
| [cloud.account.id](#resource-attribute-config)         | Toggles the `cloud.account.id` resource attribute.  <br />Sets `enabled` to `true` by default.         | no       |
| [cloud.platform](#resource-attribute-config)           | Toggles the `cloud.platform` resource attribute.  <br />Sets `enabled` to `true` by default.           | no       |
| [cloud.provider](#resource-attribute-config)           | Toggles the `cloud.provider` resource attribute.  <br />Sets `enabled` to `true` by default.           | no       |
| [cloud.region](#resource-attribute-config)             | Toggles the `cloud.region` resource attribute.  <br />Sets `enabled` to `true` by default.             | no       |
| [host.id](#resource-attribute-config)                  | Toggles the `host.id` resource attribute.  <br />Sets `enabled` to `true` by default.                  | no       |
| [host.name](#resource-attribute-config)                | Toggles the `host.name` resource attribute.  <br />Sets `enabled` to `true` by default.                | no       |

Example values:

- `cloud.provider`: `"azure"`
- `cloud.platform`: `"azure_vm"`

### aks

The `aks` block adds resource attributes related to Azure AKS.

The `aks` block supports the following blocks:

Expand table

| Block                                             | Description                                  | Required |
|---------------------------------------------------|----------------------------------------------|----------|
| [resource\_attributes](#aks--resource_attributes) | Configures which resource attributes to add. | no       |

#### aks &gt; resource\_attributes

The `resource_attributes` block supports the following blocks:

Expand table

| Block                                          | Description                                                                                     | Required |
|------------------------------------------------|-------------------------------------------------------------------------------------------------|----------|
| [cloud.platform](#resource-attribute-config)   | Toggles the `cloud.platform` resource attribute.  <br />Sets `enabled` to `true` by default.    | no       |
| [cloud.provider](#resource-attribute-config)   | Toggles the `cloud.provider` resource attribute.  <br />Sets `enabled` to `true` by default.    | no       |
| [k8s.cluster.name](#resource-attribute-config) | Toggles the `k8s.cluster.name` resource attribute.  <br />Sets `enabled` to `false` by default. | no       |

Example values:

- `cloud.provider`: `"azure"`
- `cloud.platform`: `"azure_vm"`

Azure AKS cluster name is derived from the Azure Instance Metadata Service’s (IMDS) infrastructure resource group field. This field contains the resource group and name of the cluster, separated by underscores. For example: `MC_<resource group>_<cluster name>_<location>`.

Example:

- Resource group: `my-resource-group`
- Cluster name: `my-cluster`
- Location: `eastus`
- Generated name: `MC_my-resource-group_my-cluster_eastus`

The cluster name is detected if it does not contain underscores and if a custom infrastructure resource group name was not used.

If accurate parsing cannot be performed, the infrastructure resource group value is returned. This value can be used to uniquely identify the cluster, because Azure will not allow users to create multiple clusters with the same infrastructure resource group name.

### consul

The `consul` block queries a Consul agent and reads its configuration endpoint to retrieve values for resource attributes.

The `consul` block supports the following attributes:

Expand table

| Attribute    | Type           | Description                                                                                                            | Default | Required |
|--------------|----------------|------------------------------------------------------------------------------------------------------------------------|---------|----------|
| `address`    | `string`       | The address of the Consul server                                                                                       | `""`    | no       |
| `datacenter` | `string`       | Datacenter to use. If not provided, the default agent datacenter is used.                                              | `""`    | no       |
| `token`      | `secret`       | A per-request ACL token which overrides the Consul agent’s default (empty) token.                                      | `""`    | no       |
| `namespace`  | `string`       | The name of the namespace to send along for the request.                                                               | `""`    | no       |
| `meta`       | `list(string)` | Allowlist of [Consul Metadata](https://www.consul.io/docs/agent/options#node_meta) keys to use as resource attributes. | `[]`    | no       |

`token` is only required if [Consul’s ACL System](https://www.consul.io/docs/security/acl/acl-system) is enabled.

The `consul` block supports the following blocks:

Expand table

| Block                                                | Description                                  | Required |
|------------------------------------------------------|----------------------------------------------|----------|
| [resource\_attributes](#consul--resource_attributes) | Configures which resource attributes to add. | no       |

#### consul &gt; resource\_attributes

The `resource_attributes` block supports the following blocks:

Expand table

| Block                                      | Description                                                                                | Required |
|--------------------------------------------|--------------------------------------------------------------------------------------------|----------|
| [cloud.region](#resource-attribute-config) | Toggles the `cloud.region` resource attribute.  <br />Sets `enabled` to `true` by default. | no       |
| [host.id](#resource-attribute-config)      | Toggles the `host.id` resource attribute.  <br />Sets `enabled` to `true` by default.      | no       |
| [host.name](#resource-attribute-config)    | Toggles the `host.name` resource attribute.  <br />Sets `enabled` to `true` by default.    | no       |

### docker

The `docker` block queries the Docker daemon to retrieve various resource attributes from the host machine.

You need to mount the Docker socket (`/var/run/docker.sock` on Linux) to contact the Docker daemon. Docker detection does not work on MacOS.

The `docker` block supports the following blocks:

Expand table

| Block                                                | Description                                  | Required |
|------------------------------------------------------|----------------------------------------------|----------|
| [resource\_attributes](#docker--resource_attributes) | Configures which resource attributes to add. | no       |

#### docker &gt; resource\_attributes

The `resource_attributes` block supports the following blocks:

Expand table

| Block                                   | Description                                                                             | Required |
|-----------------------------------------|-----------------------------------------------------------------------------------------|----------|
| [host.name](#resource-attribute-config) | Toggles the `host.name` resource attribute.  <br />Sets `enabled` to `true` by default. | no       |
| [os.type](#resource-attribute-config)   | Toggles the `os.type` resource attribute.  <br />Sets `enabled` to `true` by default.   | no       |

### gcp

The `gcp` block detects resource attributes using the [Google Cloud Client Libraries for Go](https://github.com/googleapis/google-cloud-go), which reads resource information from the [GCP metadata server](https://cloud.google.com/compute/docs/storing-retrieving-metadata). The detector also uses environment variables to identify which GCP platform the application is running on, and assigns appropriate resource attributes for that platform.

Use the `gcp` detector regardless of the GCP platform Grafana Agent is running on.

The `gcp` block supports the following blocks:

Expand table

| Block                                             | Description                                  | Required |
|---------------------------------------------------|----------------------------------------------|----------|
| [resource\_attributes](#gcp--resource_attributes) | Configures which resource attributes to add. | no       |

#### gcp &gt; resource\_attributes

The `resource_attributes` block supports the following blocks:

Expand table

| Block                                                        | Description                                                                                                | Required |
|--------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|----------|
| [cloud.account.id](#resource-attribute-config)               | Toggles the `cloud.account.id` resource attribute.  <br />Sets `enabled` to `true` by default.             | no       |
| [cloud.availability\_zone](#resource-attribute-config)       | Toggles the `cloud.availability_zone` resource attribute.  <br />Sets `enabled` to `true` by default.      | no       |
| [cloud.platform](#resource-attribute-config)                 | Toggles the `cloud.platform` resource attribute.  <br />Sets `enabled` to `true` by default.               | no       |
| [cloud.provider](#resource-attribute-config)                 | Toggles the `cloud.provider` resource attribute.  <br />Sets `enabled` to `true` by default.               | no       |
| [cloud.region](#resource-attribute-config)                   | Toggles the `cloud.region` resource attribute.  <br />Sets `enabled` to `true` by default.                 | no       |
| [faas.id](#resource-attribute-config)                        | Toggles the `faas.id` resource attribute.  <br />Sets `enabled` to `true` by default.                      | no       |
| [faas.instance](#resource-attribute-config)                  | Toggles the `faas.instance` resource attribute.  <br />Sets `enabled` to `true` by default.                | no       |
| [faas.name](#resource-attribute-config)                      | Toggles the `faas.name` resource attribute.  <br />Sets `enabled` to `true` by default.                    | no       |
| [faas.version](#resource-attribute-config)                   | Toggles the `faas.version` resource attribute.  <br />Sets `enabled` to `true` by default.                 | no       |
| [gcp.cloud\_run.job.execution](#resource-attribute-config)   | Toggles the `gcp.cloud_run.job.execution` resource attribute.  <br />Sets `enabled` to `true` by default.  | no       |
| [gcp.cloud\_run.job.task\_index](#resource-attribute-config) | Toggles the `gcp.cloud_run.job.task_index` resource attribute.  <br />Sets `enabled` to `true` by default. | no       |
| [gcp.gce.instance.hostname](#resource-attribute-config)      | Toggles the `gcp.gce.instance.hostname` resource attribute.  <br />Sets `enabled` to `false` by default.   | no       |
| [gcp.gce.instance.name](#resource-attribute-config)          | Toggles the `gcp.gce.instance.name` resource attribute.  <br />Sets `enabled` to `false` by default.       | no       |
| [host.id](#resource-attribute-config)                        | Toggles the `host.id` resource attribute.  <br />Sets `enabled` to `true` by default.                      | no       |
| [host.name](#resource-attribute-config)                      | Toggles the `host.name` resource attribute.  <br />Sets `enabled` to `true` by default.                    | no       |
| [host.type](#resource-attribute-config)                      | Toggles the `host.type` resource attribute.  <br />Sets `enabled` to `true` by default.                    | no       |
| [k8s.cluster.name](#resource-attribute-config)               | Toggles the `k8s.cluster.name` resource attribute.  <br />Sets `enabled` to `true` by default.             | no       |

#### Google Compute Engine (GCE) metadata

- `cloud.provider`: `"gcp"`
- `cloud.platform`: `"gcp_compute_engine"`
- `cloud.account.id`: project id
- `cloud.region`: e.g. `"us-central1"`
- `cloud.availability_zone`: e.g. `"us-central1-c"`
- `host.id`: instance id
- `host.name`: instance name
- `host.type`: machine type
- (optional) `gcp.gce.instance.hostname`
- (optional) `gcp.gce.instance.name`

#### Google Kubernetes Engine (GKE) metadata

- `cloud.provider`: `"gcp"`
- `cloud.platform`: `"gcp_kubernetes_engine"`
- `cloud.account.id`: project id
- `cloud.region`: only for regional GKE clusters; e.g. `"us-central1"`
- `cloud.availability_zone`: only for zonal GKE clusters; e.g. `"us-central1-c"`
- `k8s.cluster.name`
- `host.id`: instance id
- `host.name`: instance name; only when workload identity is disabled

One known issue happens when GKE workload identity is enabled. The GCE metadata endpoints won’t be available, and the GKE resource detector won’t be able to determine `host.name`. If this happens, you can set `host.name` from one of the following resources:

- Get the `node.name` through the [downward API](https://kubernetes.io/docs/concepts/workloads/pods/downward-api/) with the `env` detector.
- Get the Kubernetes node name from the Kubernetes API (with `k8s.io/client-go`).

#### Google Cloud Run Services metadata

- `cloud.provider`: `"gcp"`
- `cloud.platform`: `"gcp_cloud_run"`
- `cloud.account.id`: project id
- `cloud.region`: e.g. `"us-central1"`
- `faas.id`: instance id
- `faas.name`: service name
- `faas.version`: service revision

#### Cloud Run Jobs metadata

- `cloud.provider`: `"gcp"`
- `cloud.platform`: `"gcp_cloud_run"`
- `cloud.account.id`: project id
- `cloud.region`: e.g. `"us-central1"`
- `faas.id`: instance id
- `faas.name`: service name
- `gcp.cloud_run.job.execution`: e.g. `"my-service-ajg89"`
- `gcp.cloud_run.job.task_index`: e.g. `"0"`

#### Google Cloud Functions metadata

- `cloud.provider`: `"gcp"`
- `cloud.platform`: `"gcp_cloud_functions"`
- `cloud.account.id`: project id
- `cloud.region`: e.g. `"us-central1"`
- `faas.id`: instance id
- `faas.name`: function name
- `faas.version`: function version

#### Google App Engine metadata

- `cloud.provider`: `"gcp"`
- `cloud.platform`: `"gcp_app_engine"`
- `cloud.account.id`: project id
- `cloud.region`: e.g. `"us-central1"`
- `cloud.availability_zone`: e.g. `"us-central1-c"`
- `faas.id`: instance id
- `faas.name`: service name
- `faas.version`: service version

### heroku

The `heroku` block adds resource attributes derived from [Heroku dyno metadata](https://devcenter.heroku.com/articles/dyno-metadata).

The `heroku` block supports the following blocks:

Expand table

| Block                                                | Description                                  | Required |
|------------------------------------------------------|----------------------------------------------|----------|
| [resource\_attributes](#heroku--resource_attributes) | Configures which resource attributes to add. | no       |

#### heroku &gt; resource\_attributes

The `resource_attributes` block supports the following blocks:

Expand table

| Block                                                            | Description                                                                                                     | Required |
|------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------|----------|
| [cloud.provider](#resource-attribute-config)                     | Toggles the `cloud.provider` resource attribute.  <br />Sets `enabled` to `true` by default.                    | no       |
| [heroku.app.id](#resource-attribute-config)                      | Toggles the `heroku.app.id` resource attribute.  <br />Sets `enabled` to `true` by default.                     | no       |
| [heroku.dyno.id](#resource-attribute-config)                     | Toggles the `heroku.dyno.id` resource attribute.  <br />Sets `enabled` to `true` by default.                    | no       |
| [heroku.release.commit](#resource-attribute-config)              | Toggles the `heroku.release.commit` resource attribute.  <br />Sets `enabled` to `true` by default.             | no       |
| [heroku.release.creation\_timestamp](#resource-attribute-config) | Toggles the `heroku.release.creation_timestamp` resource attribute.  <br />Sets `enabled` to `true` by default. | no       |
| [service.instance.id](#resource-attribute-config)                | Toggles the `service.instance.id` resource attribute.  <br />Sets `enabled` to `true` by default.               | no       |
| [service.name](#resource-attribute-config)                       | Toggles the `service.name` resource attribute.  <br />Sets `enabled` to `true` by default.                      | no       |
| [service.version](#resource-attribute-config)                    | Toggles the `service.version` resource attribute.  <br />Sets `enabled` to `true` by default.                   | no       |

When [Heroku dyno metadata](https://devcenter.heroku.com/articles/dyno-metadata) is active, Heroku applications publish information through environment variables. We map these environment variables to resource attributes as follows:

Expand table

| Dyno metadata environment variable | Resource attribute                  |
|------------------------------------|-------------------------------------|
| `HEROKU_APP_ID`                    | `heroku.app.id`                     |
| `HEROKU_APP_NAME`                  | `service.name`                      |
| `HEROKU_DYNO_ID`                   | `service.instance.id`               |
| `HEROKU_RELEASE_CREATED_AT`        | `heroku.release.creation_timestamp` |
| `HEROKU_RELEASE_VERSION`           | `service.version`                   |
| `HEROKU_SLUG_COMMIT`               | `heroku.release.commit`             |

For more information, see the [Heroku cloud provider documentation](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/cloud_provider/heroku.md) under the [OpenTelemetry specification semantic conventions](https://github.com/open-telemetry/opentelemetry-specification).

### system

The `system` block queries the host machine to retrieve various resource attributes.

> Note
> 
> Use the [Docker](#docker) detector if running Grafana Agent as a Docker container.

The `system` block supports the following attributes:

Expand table

| Attribute          | Type           | Description                                                         | Default         | Required |
|--------------------|----------------|---------------------------------------------------------------------|-----------------|----------|
| `hostname_sources` | `list(string)` | A priority list of sources from which the hostname will be fetched. | `["dns", "os"]` | no       |

The valid options for `hostname_sources` are:

- `"dns"`: Uses multiple sources to get the fully qualified domain name. Firstly, it looks up the host name in the local machine’s `hosts` file. If that fails, it looks up the CNAME. Lastly, if that fails, it does a reverse DNS query. Note: this hostname source may produce unreliable results on Windows. To produce a FQDN, Windows hosts might have better results using the “lookup” hostname source, which is mentioned below.
- `"os"`: Provides the hostname provided by the local machine’s kernel.
- `"cname"`: Provides the canonical name, as provided by `net.LookupCNAME` in the Go standard library. Note: this hostname source may produce unreliable results on Windows.
- `"lookup"`: Does a reverse DNS lookup of the current host’s IP address.

In case of an error in fetching a hostname from a source, the next source from the list of `hostname_sources` will be considered.

The `system` block supports the following blocks:

Expand table

| Block                                                | Description                                  | Required |
|------------------------------------------------------|----------------------------------------------|----------|
| [resource\_attributes](#system--resource_attributes) | Configures which resource attributes to add. | no       |

#### system &gt; resource\_attributes

The `resource_attributes` block supports the following blocks:

Expand table

| Block                                                | Description                                                                                           | Required |
|------------------------------------------------------|-------------------------------------------------------------------------------------------------------|----------|
| [host.arch](#resource-attribute-config)              | Toggles the `host.arch` resource attribute.  <br />Sets `enabled` to `false` by default.              | no       |
| [host.cpu.cache.l2.size](#resource-attribute-config) | Toggles the `host.cpu.cache.l2.size` resource attribute.  <br />Sets `enabled` to `false` by default. | no       |
| [host.cpu.family](#resource-attribute-config)        | Toggles the `host.cpu.family` resource attribute.  <br />Sets `enabled` to `false` by default.        | no       |
| [host.cpu.model.id](#resource-attribute-config)      | Toggles the `host.cpu.model.id` resource attribute.  <br />Sets `enabled` to `false` by default.      | no       |
| [host.cpu.model.name](#resource-attribute-config)    | Toggles the `host.cpu.model.name` resource attribute.  <br />Sets `enabled` to `false` by default.    | no       |
| [host.cpu.stepping](#resource-attribute-config)      | Toggles the `host.cpu.stepping` resource attribute.  <br />Sets `enabled` to `false` by default.      | no       |
| [host.cpu.vendor.id](#resource-attribute-config)     | Toggles the `host.cpu.vendor.id` resource attribute.  <br />Sets `enabled` to `false` by default.     | no       |
| [host.id](#resource-attribute-config)                | Toggles the `host.id` resource attribute.  <br />Sets `enabled` to `false` by default.                | no       |
| [host.ip](#resource-attribute-config)                | Toggles the `host.ip` resource attribute.  <br />Sets `enabled` to `false` by default.                | no       |
| [host.mac](#resource-attribute-config)               | Toggles the `host.mac` resource attribute.  <br />Sets `enabled` to `false` by default.               | no       |
| [host.name](#resource-attribute-config)              | Toggles the `host.name` resource attribute.  <br />Sets `enabled` to `true` by default.               | no       |
| [os.description](#resource-attribute-config)         | Toggles the `os.description` resource attribute.  <br />Sets `enabled` to `false` by default.         | no       |
| [os.type](#resource-attribute-config)                | Toggles the `os.type` resource attribute.  <br />Sets `enabled` to `true` by default.                 | no       |

### openshift

The `openshift` block queries the OpenShift and Kubernetes APIs to retrieve various resource attributes.

The `openshift` block supports the following attributes:

Expand table

| Attribute | Type     | Description                                              | Default     | Required |
|-----------|----------|----------------------------------------------------------|-------------|----------|
| `address` | `string` | Address of the OpenShift API server.                     | *See below* | no       |
| `token`   | `string` | Token used to identify against the OpenShift API server. | ""          | no       |

The “get”, “watch”, and “list” permissions are required:

YAML ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```yaml
kind: ClusterRole
metadata:
  name: grafana-agent
rules:
- apiGroups: ["config.openshift.io"]
  resources: ["infrastructures", "infrastructures/status"]
  verbs: ["get", "watch", "list"]
```

By default, the API address is determined from the environment variables `KUBERNETES_SERVICE_HOST`, `KUBERNETES_SERVICE_PORT` and the service token is read from `/var/run/secrets/kubernetes.io/serviceaccount/token`. If TLS is not explicitly disabled and no `ca_file` is configured, `/var/run/secrets/kubernetes.io/serviceaccount/ca.crt` is used. The determination of the API address, `ca_file`, and the service token is skipped if they are set in the configuration.

The `openshift` block supports the following blocks:

Expand table

| Block                                                   | Description                                             | Required |
|---------------------------------------------------------|---------------------------------------------------------|----------|
| [resource\_attributes](#openshift--resource_attributes) | Configures which resource attributes to add.            | no       |
| [tls](#openshift--tls)                                  | TLS settings for the connection with the OpenShift API. | yes      |

#### openshift &gt; tls

The `tls` block configures TLS settings used for the connection to the gRPC server.

The following arguments are supported:

Expand table

| Name                           | Type           | Description                                                                                  | Default     | Required |
|--------------------------------|----------------|----------------------------------------------------------------------------------------------|-------------|----------|
| `ca_file`                      | `string`       | Path to the CA file.                                                                         |             | no       |
| `ca_pem`                       | `string`       | CA PEM-encoded text to validate the server with.                                             |             | no       |
| `cert_file`                    | `string`       | Path to the TLS certificate.                                                                 |             | no       |
| `cert_pem`                     | `string`       | Certificate PEM-encoded text for client authentication.                                      |             | no       |
| `insecure_skip_verify`         | `boolean`      | Ignores insecure server TLS certificates.                                                    |             | no       |
| `include_system_ca_certs_pool` | `boolean`      | Whether to load the system certificate authorities pool alongside the certificate authority. | `false`     | no       |
| `insecure`                     | `boolean`      | Disables TLS when connecting to the configured server.                                       |             | no       |
| `key_file`                     | `string`       | Path to the TLS certificate key.                                                             |             | no       |
| `key_pem`                      | `secret`       | Key PEM-encoded text for client authentication.                                              |             | no       |
| `max_version`                  | `string`       | Maximum acceptable TLS version for connections.                                              | `"TLS 1.3"` | no       |
| `min_version`                  | `string`       | Minimum acceptable TLS version for connections.                                              | `"TLS 1.2"` | no       |
| `cipher_suites`                | `list(string)` | A list of TLS cipher suites that the TLS transport can use.                                  | `[]`        | no       |
| `reload_interval`              | `duration`     | The duration after which the certificate is reloaded.                                        | `"0s"`      | no       |
| `server_name`                  | `string`       | Verifies the hostname of server certificates when set.                                       |             | no       |

If the server doesn’t support TLS, you must set the `insecure` argument to `true`.

To disable `tls` for connections to the server, set the `insecure` argument to `true`.

If `reload_interval` is set to `"0s"`, the certificate never reloaded.

The following pairs of arguments are mutually exclusive and can’t both be set simultaneously:

- `ca_pem` and `ca_file`
- `cert_pem` and `cert_file`
- `key_pem` and `key_file`

If `cipher_suites` is left blank, a safe default list is used. See the [Go TLS documentation](https://go.dev/src/crypto/tls/cipher_suites.go) for a list of supported cipher suites.

#### openshift &gt; resource\_attributes

The `resource_attributes` block supports the following blocks:

Expand table

| Block                                          | Description                                                                                    | Required |
|------------------------------------------------|------------------------------------------------------------------------------------------------|----------|
| [cloud.platform](#resource-attribute-config)   | Toggles the `cloud.platform` resource attribute.  <br />Sets `enabled` to `true` by default.   | no       |
| [cloud.provider](#resource-attribute-config)   | Toggles the `cloud.provider` resource attribute.  <br />Sets `enabled` to `true` by default.   | no       |
| [cloud.region](#resource-attribute-config)     | Toggles the `cloud.region` resource attribute.  <br />Sets `enabled` to `true` by default.     | no       |
| [k8s.cluster.name](#resource-attribute-config) | Toggles the `k8s.cluster.name` resource attribute.  <br />Sets `enabled` to `true` by default. | no       |

### kubernetes\_node

The `kubernetes_node` block queries the Kubernetes API server to retrieve various node resource attributes.

The `kubernetes_node` block supports the following attributes:

Expand table

| Attribute           | Type     | Description                                                               | Default           | Required |
|---------------------|----------|---------------------------------------------------------------------------|-------------------|----------|
| `auth_type`         | `string` | Configures how to authenticate to the K8s API server.                     | `"none"`          | no       |
| `context`           | `string` | Override the current context when `auth_type` is set to `"kubeConfig"`.   | `""`              | no       |
| `node_from_env_var` | `string` | The name of an environment variable from which to retrieve the node name. | `"K8S_NODE_NAME"` | no       |

The “get” and “list” permissions are required:

YAML ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```yaml
kind: ClusterRole
metadata:
  name: grafana-agent
rules:
  - apiGroups: [""]
    resources: ["nodes"]
    verbs: ["get", "list"]
```

`auth_type` can be set to one of the following:

- `none`: no authentication.
- `serviceAccount`: use the standard service account token provided to the Grafana Agent pod.
- `kubeConfig`: use credentials from `~/.kube/config`.

The `kubernetes_node` block supports the following blocks:

Expand table

| Block                                                         | Description                                  | Required |
|---------------------------------------------------------------|----------------------------------------------|----------|
| [resource\_attributes](#kubernetes_node--resource_attributes) | Configures which resource attributes to add. | no       |

#### kubernetes\_node &gt; resource\_attributes

The `resource_attributes` block supports the following blocks:

Expand table

| Block                                       | Description                                                                                 | Required |
|---------------------------------------------|---------------------------------------------------------------------------------------------|----------|
| [k8s.node.name](#resource-attribute-config) | Toggles the `k8s.node.name` resource attribute.  <br />Sets `enabled` to `true` by default. | no       |
| [k8s.node.uid](#resource-attribute-config)  | Toggles the `k8s.node.uid` resource attribute.  <br />Sets `enabled` to `true` by default.  | no       |

## Common configuration

### Resource attribute config

This block describes how to configure resource attributes such as `k8s.node.name` and `azure.vm.name`. Every block is configured using the same set of attributes. Only the default values for those attributes might differ across resource attributes. For example, some resource attributes have `enabled` set to `true` by default, whereas others don’t.

The following attributes are supported:

Expand table

| Attribute | Type   | Description                                                                         | Default     | Required |
|-----------|--------|-------------------------------------------------------------------------------------|-------------|----------|
| `enabled` | `bool` | Toggles whether to add the resource attribute to the span, log, or metric resource. | *See below* | no       |

To see the default value for `enabled`, refer to the tables in the sections above which list the resource attributes blocks. The “Description” column will state either…

> Sets `enabled` to `true` by default.

… or:

> Sets `enabled` to `false` by default.

## Exported fields

The following fields are exported and can be referenced by other components:

Expand table

| Name    | Type               | Description                                                      |
|---------|--------------------|------------------------------------------------------------------|
| `input` | `otelcol.Consumer` | A value that other components can use to send telemetry data to. |

`input` accepts `otelcol.Consumer` OTLP-formatted data for any telemetry signal of these types:

- logs
- metrics
- traces

## Component health

`otelcol.processor.resourcedetection` is only reported as unhealthy if given an invalid configuration.

## Debug information

`otelcol.processor.resourcedetection` doesn’t expose any component-specific debug information.

## Examples

### env detector

If you set up a `OTEL_RESOURCE_ATTRIBUTES` environment variable with value of `TestKey=TestValue`, then all logs, metrics, and traces have a resource attribute with a key `TestKey` and value of `TestValue`.

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
otelcol.processor.resourcedetection "default" {
  detectors = ["env"]

  output {
    logs    = [otelcol.exporter.otlp.default.input]
    metrics = [otelcol.exporter.otlp.default.input]
    traces  = [otelcol.exporter.otlp.default.input]
  }
}
```

### env and ec2

There is no need to put in an `ec2 {}` River block. The `ec2` defaults are applied automatically, as specified in [ec2](#ec2).

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
otelcol.processor.resourcedetection "default" {
  detectors = ["env", "ec2"]

  output {
    logs    = [otelcol.exporter.otlp.default.input]
    metrics = [otelcol.exporter.otlp.default.input]
    traces  = [otelcol.exporter.otlp.default.input]
  }
}
```

### ec2 with default resource attributes

There is no need to put in a `ec2 {}` River block. The `ec2` defaults are applied automatically, as specified in [ec2](#ec2).

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
otelcol.processor.resourcedetection "default" {
  detectors = ["ec2"]

  output {
    logs    = [otelcol.exporter.otlp.default.input]
    metrics = [otelcol.exporter.otlp.default.input]
    traces  = [otelcol.exporter.otlp.default.input]
  }
}
```

### ec2 with explicit resource attributes

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
otelcol.processor.resourcedetection "default" {
  detectors = ["ec2"]
  ec2 {
    tags = ["^tag1$", "^tag2$", "^label.*$"]
    resource_attributes {
      cloud.account.id  { enabled = true }
      cloud.availability_zone  { enabled = true }
      cloud.platform  { enabled = true }
      cloud.provider  { enabled = true }
      cloud.region  { enabled = true }
      host.id  { enabled = true }
      host.image.id  { enabled = false }
      host.name  { enabled = false }
      host.type  { enabled = false }
    }
  }

  output {
    logs    = [otelcol.exporter.otlp.default.input]
    metrics = [otelcol.exporter.otlp.default.input]
    traces  = [otelcol.exporter.otlp.default.input]
  }
}
```

### kubernetes\_node

This example uses the default `node_from_env_var` option of `K8S_NODE_NAME`.

There is no need to put in a `kubernetes_node {}` River block. The `kubernetes_node` defaults are applied automatically, as specified in [kubernetes\_node](#kubernetes_node).

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
otelcol.processor.resourcedetection "default" {
  detectors = ["kubernetes_node"]

  output {
    logs    = [otelcol.exporter.otlp.default.input]
    metrics = [otelcol.exporter.otlp.default.input]
    traces  = [otelcol.exporter.otlp.default.input]
  }
}
```

You need to add this to your workload:

YAML ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```yaml
        env:
          - name: K8S_NODE_NAME
            valueFrom:
              fieldRef:
                fieldPath: spec.nodeName
```

### kubernetes\_node with a custom environment variable

This example uses a custom `node_from_env_var` set to `my_custom_var`.

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
otelcol.processor.resourcedetection "default" {
  detectors = ["kubernetes_node"]
  kubernetes_node {
    node_from_env_var = "my_custom_var"
  }

  output {
    logs    = [otelcol.exporter.otlp.default.input]
    metrics = [otelcol.exporter.otlp.default.input]
    traces  = [otelcol.exporter.otlp.default.input]
  }
}
```

You need to add this to your workload:

YAML ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```yaml
        env:
          - name: my_custom_var
            valueFrom:
              fieldRef:
                fieldPath: spec.nodeName
```

## Compatible components

`otelcol.processor.resourcedetection` can accept arguments from the following components:

- Components that export [OpenTelemetry `otelcol.Consumer`](../../compatibility/#opentelemetry-otelcolconsumer-exporters)

`otelcol.processor.resourcedetection` has exports that can be consumed by the following components:

- Components that consume [OpenTelemetry `otelcol.Consumer`](../../compatibility/#opentelemetry-otelcolconsumer-consumers)

> Note
> 
> Connecting some components may not be sensible or components may require further configuration to make the connection work correctly. Refer to the linked documentation for more details.
