Skip to main content

Resourcedetection Processor

Status Available in: contrib, k8s Maintainers: @Aneurysm9, @dashpole, @paulojmdias Source: opentelemetry-collector-contrib

Supported Telemetry

Logs Metrics Traces

Overview

The Resource Detection processor can be used to detect resource information from the host, in a format that conforms to the OpenTelemetry resource semantic conventions, and append or override the resource value in telemetry data with this information.
Note If a configured resource detector fails, the error will propagate and stop the collector from starting.

Retry configuration

By default, every detector retries failed Detect calls with exponential backoff. The retry block uses the standard configretry.BackOffConfig and applies to every detection attempt (including periodic refreshes when refresh_interval > 0). When retry.max_elapsed_time is 0, the whole detection session is bounded by timeout. When it is greater than zero, timeout only bounds each individual attempt, and max_elapsed_time bounds the total. The processor rejects configurations with retry.enabled: true, timeout: 0, and retry.max_elapsed_time: 0 — at least one of the two must be set so a hung detector cannot block startup indefinitely. Example: wait up to two minutes for a slow metadata server to come up.

Supported detectors

Environment Variable

Reads resource information from the OTEL_RESOURCE_ATTRIBUTES environment variable. This is expected to be in the format <key1>=<value1>,<key2>=<value2>,..., the details of which are currently pending confirmation in the OpenTelemetry specification. Example:
[!NOTE] The deprecated coponent type resourcedetection (without the underscore) can still be used as an alias and will log a deprecation warning.

System metadata

Note: use the Docker detector (see below) if running the Collector as a Docker container. Queries the host machine to retrieve the system related resource attributes. The list of the populated resource attributes can be found at System Detector Resource Attributes. By default host.name is being set to FQDN if possible, and a hostname provided by OS used as fallback. This logic can be changed with hostname_sources configuration which is set to ["dns", "os"] by default. Use the following config to avoid getting FQDN and apply hostname provided by OS only:
  • all valid options for hostname_sources:
    • “dns”
    • “os”
    • “cname”
    • “lookup”

Hostname Sources

dns
The “dns” hostname source uses multiple sources to get the fully qualified domain name. First, 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
The “os” hostname source provides the hostname provided by the local machine’s kernel.
cname
The “cname” hostname source 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
The “lookup” hostname source does a reverse DNS lookup of the current host’s IP address.

Docker metadata

Queries the Docker daemon to retrieve resource attributes from the host machine. The list of the populated resource attributes can be found at Docker Detector Resource Attributes. 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. If container.name or container.image.name is enabled, the detector inspects the current container by using the container hostname as the Docker container name or ID. This can fail when the container hostname is changed, for example when running with network_mode: host. Example:
Note: When fail_on_missing_metadata is true, this detector returns an error if the Docker daemon cannot be contacted. When false (default), failures are logged and an empty resource is returned.

Docker Socket Permissions

Since version 0.40.0, official OpenTelemetry Collector images run as a non-root user. To access the Docker socket, you need to configure appropriate permissions:
  • Linux: Grant access to the docker group (e.g., --group-add <docker-gid> or set runAsGroup in Kubernetes)
  • Windows: Ensure appropriate named pipe permissions
For detailed permission configuration options and security considerations, see the Docker Stats receiver documentation. For more information, see issue #11791.

Heroku metadata

When Heroku dyno metadata is active, Heroku applications publish information through environment variables. We map these environment variables to resource attributes as follows: For more information, see the Heroku cloud provider documentation under the OpenTelemetry specification semantic conventions. The list of the populated resource attributes can be found at Heroku Detector Resource Attributes.
Note: When fail_on_missing_metadata is true, this detector returns an error if both HEROKU_DYNO_ID and HEROKU_APP_ID environment variables are not set, instead of silently returning an empty resource.

GCP Metadata

Uses the Google Cloud Client Libraries for Go to read resource information from the metadata server and environment variables to detect which GCP platform the application is running on, and detect the appropriate attributes for that platform. Regardless of the GCP platform the application is running on, use the gcp detector: It also can optionally gather labels for the GCE instance that the collector is running on. Note that in order to fetch GCE labels, the service account assigned to the GCE instance must have the roles/compute.viewer role. Example:
The list of the populated resource attributes can be found at GCP Detector Resource Attributes.

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

GKE Metadata

  • cloud.provider (“gcp”)
  • cloud.platform (“gcp_kubernetes_engine”)
  • cloud.account.id (project id)
  • cloud.region (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; availability with workload identity depends on GKE version)

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.instance (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.instance (instance id)
  • faas.name (service name)
  • gcp.cloud_run.job.execution (“my-service-ajg89”)
  • gcp.cloud_run.job.task_index (“0”)

Cloud Run Worker Pools Metadata

  • cloud.provider (“gcp”)
  • cloud.platform (“gcp_cloud_run”)
  • cloud.account.id (project id)
  • cloud.region (e.g. “us-central1”)
  • faas.instance (instance id)
  • faas.name (worker pool name)
  • faas.version (worker pool revision)

Google Cloud Functions Metadata

  • cloud.provider (“gcp”)
  • cloud.platform (“gcp_cloud_functions”)
  • cloud.account.id (project id)
  • cloud.region (e.g. “us-central1”)
  • faas.instance (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.instance (instance id)
  • faas.name (service name)
  • faas.version (service version)

AWS EC2

Uses AWS SDK for Go to read resource information from the EC2 instance metadata API to retrieve related resource attributes: The list of the populated resource attributes can be found at EC2 Detector Resource Attributes. It also can optionally gather tags for the EC2 instance that the collector is running on. By default, tags are fetched via the EC2 DescribeTags API, which requires the IAM role assigned to the EC2 instance to include the ec2:DescribeTags permission. Alternatively, tags can be fetched via the Instance Metadata Service (IMDS), which does not require any IAM permissions but requires instance metadata tags to be enabled on the instance. Tag retrieval behavior is controlled by the tags_from_imds configuration field:
  • false (default): tags are fetched via the EC2 DescribeTags API — requires ec2:DescribeTags IAM permission.
  • true: tags are fetched via IMDS — no IAM permissions needed, but requires InstanceMetadataTags=enabled on the instance.
EC2 custom configuration example:
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. 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 OTEL user to access 169.254.169.254/32 In some cases, you might need to change the behavior of the AWS metadata client from the standard retryer By default, the client retries 3 times with a max backoff delay of 20s. We offer a limited set of options to override those defaults specifically, such that you can set the client to retry 10 times, for up to 5 minutes, for example:
Deprecated: The per-detector fail_on_missing_metadata field is deprecated. Use the top-level fail_on_missing_metadata in the processor config instead. See Using the fail_on_missing_metadata parameter.

Amazon ECS

Queries the Task Metadata Endpoint (TMDE) to record information about the current ECS Task. Only TMDE V4 and V3 are supported. The list of the populated resource attributes can be found at ECS Detector Resource Attributes. Example:
Note: When fail_on_missing_metadata is true, this detector returns an error if the ECS Task Metadata Endpoint is not detected (not running on ECS) or if container sidecar metadata retrieval fails, instead of silently returning an empty or partial resource.

Amazon Elastic Beanstalk

Reads the AWS X-Ray configuration file available on all Beanstalk instances with X-Ray Enabled. The list of the populated resource attributes can be found at Elastic Beanstalk Detector Resource Attributes. Example:
Note: When fail_on_missing_metadata is true, this detector returns an error if the Elastic Beanstalk configuration file is not found, instead of silently returning an empty resource.

Migrating to the current deployment semantic conventions

By default this detector reports deployment.environment, which is deprecated in the semantic conventions, and reports the deployment ID as service.instance.id. Two feature gates move it to deployment.environment.name and deployment.id: Enabling only EmitV1DeploymentConventions reports both sets of attributes, which lets you migrate dashboards and alerts before dropping the deprecated ones:
Once nothing depends on the deprecated attributes, enable both gates:

Amazon EKS

This detector reads resource information from the EC2 instance metadata service to retrieve related resource attributes. If IMDS is not available, (example: EKS-AutoMode and POD not on the hostnetwork), it falls back to a combination of Kubernetes API and EC2 API to retrieve related resource attributes. EC2 API requires the EC2:DescribeInstances permission to be granted to the IAM role. If IMDS is not accessible, ex: EKS-AutoMode, you can use POD Identity. The list of the populated resource attributes can be found at EKS Detector Resource Attributes. Example:
Note: When fail_on_missing_metadata is true, this detector returns an error if EKS cannot be detected (environment check fails) or if metadata retrieval fails, instead of silently returning an empty resource.

Cluster Name

Cluster name detection is disabled by default, and can be enabled with the following configuration:
Note: The kubernetes cluster name is only available when running on EC2 instances, and requires permission to run the EC2:DescribeInstances action. If you see an error with the message context deadline exceeded, please increase the timeout setting in your config.

Node Name Env Variable

When using the EC2 API and the Kubernetes API to retrieve resource attributes, the node name is needed. The node name is extracted from the env variable you define on the pod. The node name env variable that contains the node name value can be set using the node_from_env_var option:
In this example, the env variable K8S_NODE_NAME will hold the actual node name and can be set in the pod spec using the downward API.

AWS Lambda

Uses the AWS Lambda runtime environment variables to retrieve related resource attributes. The list of the populated resource attributes can be found at Lambda Detector Resource Attributes. Example:
Note: When fail_on_missing_metadata is true, this detector returns an error if the AWS_LAMBDA_FUNCTION_NAME environment variable is not set (not running on Lambda), instead of silently returning an empty resource.

Azure

Queries the Azure Instance Metadata Service to retrieve related attributes. The list of the populated resource attributes can be found at Azure Detector Resource Attributes. Example:
It also can optionally gather tags from the Azure instance that the Collector is running on. Azure custom configuration example:
Matched tags are added as:
  • azure.tags.<tag name>

Azure AKS

The list of the populated resource attributes can be found at AKS Detector Resource Attributes.

Cluster Name

Cluster name detection is disabled by default, and can be enabled with the following configuration:
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. e.g: 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, as Azure will not allow users to create multiple clusters with the same infrastructure resource group name.

Azure Container Apps

Uses the Azure Container Apps injected environment variables to retrieve related resource attributes. Note: Azure Container Apps jobs are not supported. The list of the populated resource attributes can be found at Azure Container Apps Detector Resource Attributes. Example:
Note: When fail_on_missing_metadata is true, this detector returns an error if the CONTAINER_APP_NAME environment variable is not set (not running on Azure Container Apps), instead of silently returning an empty resource.

Consul

Queries a consul agent and reads its configuration endpoint to retrieve related resource attributes: The list of the populated resource attributes can be found at Consul Detector Resource Attributes. In addition to:
  • exploded consul metadata - reads all key:value pairs in consul metadata into label:labelvalue pairs.
Consul node metadata keys are emitted verbatim, without a namespace of their own. Enabling the processor.resourcedetection.consul.prefixMetaAttributes feature gate namespaces each key as consul.meta.<key>, consistent with the other detectors that expose user-defined key/value data (ec2.tag., azure.tag., gcp.gce.instance.labels., openstack.nova.meta.):
The gate is alpha (disabled by default) and is expected to become the default in a future release.

Kubeadm Metadata

Queries the K8S API server to retrieve kubeadm resource attributes: The list of the populated resource attributes can be found at kubeadm Detector Resource Attributes.
Note: When fail_on_missing_metadata is true, this detector returns an error if Kubernetes API calls fail. When false (default), failures are logged and an empty resource is returned.

Oracle Cloud Infrastructure (OCI) metadata

The OCI detector implements a fast probe to the instance metadata service (IMDS) endpoint to quickly verify if the collector is running on OCI. If this probe fails, the detector returns an empty resource and no error. If the probe succeeds, it then fetches instance metadata; if this fetch fails, the detector logs and returns an error so that partial detection is not silently ignored. This behavior makes it possible to differentiate between the case where the collector is not running on OCI, vs it is running on OCI but the IMDS request failed. Queries the Oracle Cloud Infrastructure (OCI) metadata service to retrieve resource attributes related to the OCI instance environment. The list of the populated resource attributes can be found at OracleCloud Detector Resource Attributes. Example:
Populated resource attributes:
  • cloud.provider
  • cloud.platform
  • cloud.region
  • cloud.resource_id
  • cloud.availability_zone
  • host.id
  • host.name
  • host.type
  • k8s.cluster.name
See internal/oraclecloud/documentation.md for detailed attribute definitions.
The following permissions are required:

K8S API Metadata

Queries the K8S API server to retrieve node and cluster resource attributes. The k8snode detector name is deprecated — use k8s_api instead. The list of the populated resource attributes can be found at k8s_api Detector Resource Attributes.
Note: When fail_on_missing_metadata is true, this detector returns an error if Kubernetes API calls fail. When false (default), failures are logged and an empty resource is returned.
The following permissions are required:
Note: node_from_env_var and the nodes RBAC permission are required even when only k8s.cluster.uid is enabled; the detector will fail to start if the env variable is unset or empty. The namespaces permission is required for k8s.cluster.uid; if missing, detection continues without it.

Example using the default node_from_env_var option:

and add this to your workload:

Example using a custom variable node_from_env_var option:

and add this to your workload:

OpenShift

Queries the OpenShift and Kubernetes API to retrieve related resource attributes. The list of the populated resource attributes can be found at OpenShift Detector Resource Attributes. The following permissions are required:
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 explicit 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. Example:
See: TLS Configuration Settings for the full set of available options.

Dynatrace

Loads resource information from the dt_host_metadata.properties file which is located in the /var/lib/dynatrace/enrichment (on *nix systems) or %ProgramData%\dynatrace\enrichment (on Windows) directories. If present in the file, the following attributes will be added:
  • dt.entity.host
  • host.name
  • dt.smartscape.host
The Dynatrace detector does not require any additional configuration, other than being added to the list of detectors. Example:
It is strongly recommended to use the override: false configuration option, to prevent the detector from overwriting existing resource attributes. If the Dynatrace host entity identifier attribute dt.entity.host, host.name, or dt.smartscape.host are already present on incoming data as it is sent from other sources to the collector, then these describe the monitored entity in the best way. Overriding these with the collector’s own identifier would instead make the telemetry appear as if it was coming from the collector or the collector’s host instead, which might be inaccurate.

Hetzner

Uses the Hetzner metadata API to read resource information from the instance metadata service and populate related resource attributes. The list of the populated resource attributes can be found at Hetzner Detector Resource Attributes. Hetzner custom configuration example:

Akamai

Uses the Akamai metadata API to read resource information from the instance metadata service and populate related resource attributes. The list of the populated resource attributes can be found at Akamai Detector Resource Attributes. Akamai custom configuration example:

Scaleway

Uses the Scaleway metadata API to read resource information from the instance metadata service and populate related resource attributes. The list of the populated resource attributes can be found at Scaleway Detector Resource Attributes. Scaleway custom configuration example:

Upcloud

Uses the Upcloud metadata API to read resource information from the instance metadata service and populate related resource attributes. The list of the populated resource attributes can be found at Upcloud Detector Resource Attributes. Upcloud custom configuration example:
Deprecated: The per-detector fail_on_missing_metadata field is deprecated. Use the top-level fail_on_missing_metadata in the processor config instead. See Using the fail_on_missing_metadata parameter.

Vultr

Uses the Vultr metadata API to read resource information from the instance metadata service and populate related resource attributes. The list of the populated resource attributes can be found at Vultr Detector Resource Attributes. Vultr custom configuration example:
Deprecated: The per-detector fail_on_missing_metadata field is deprecated. Use the top-level fail_on_missing_metadata in the processor config instead. See Using the fail_on_missing_metadata parameter.

Digital Ocean

Uses the Digital Ocean metadata API to read resource information from the instance metadata service and populate related resource attributes. The list of the populated resource attributes can be found at Digital Ocean Detector Resource Attributes. Akamai custom configuration example:

Openstack Nova

Uses the OpenStack Nova metadata API to read resource information from the instance metadata service and populate related resource attributes. The list of the populated resource attributes can be found at Nova Detector Resource Attributes. It can also optionally capture metadata keys from the "meta" section of meta_data.json as resource attributes, using regular expressions to match the keys you want. Nova custom configuration example:
Deprecated: The per-detector fail_on_missing_metadata field is deprecated. Use the top-level fail_on_missing_metadata in the processor config instead. See Using the fail_on_missing_metadata parameter.

Alibaba Cloud ECS

Uses the Alibaba Cloud metadata API to read resource information from the instance metadata service and populate related resource attributes. The list of the populated resource attributes can be found at Alibaba Cloud ECS Detector Resource Attributes. Alibaba Cloud ECS custom configuration example:
Deprecated: The per-detector fail_on_missing_metadata field is deprecated. Use the top-level fail_on_missing_metadata in the processor config instead. See Using the fail_on_missing_metadata parameter.

Tencent Cloud CVM

Uses the Tencent Cloud metadata API to read resource information from the instance metadata service and populate related resource attributes. The list of the populated resource attributes can be found at Tencent Cloud CVM Detector Resource Attributes. Tencent Cloud CVM custom configuration example:
Deprecated: The per-detector fail_on_missing_metadata field is deprecated. Use the top-level fail_on_missing_metadata in the processor config instead. See Using the fail_on_missing_metadata parameter.

IBM Cloud VPC

Queries the IBM Cloud VPC Instance Metadata Service to retrieve resource attributes from the instance. The list of the populated resource attributes can be found at IBM Cloud VPC Detector Resource Attributes. By default, the detector queries the IBM Cloud VPC Instance Metadata Service at http://api.metadata.cloud.ibm.com. Set protocol: https to use HTTPS instead.
Note The protocol option must match the instance’s metadata service access mode. If the Secure access state is toggled while the collector is running, update the protocol configuration value accordingly and restart the collector.
Example:
IBM Cloud VPC custom configuration example:

IBM Cloud Classic

Queries the IBM Cloud Classic (SoftLayer) Resource Metadata Service to retrieve resource attributes from the instance. The list of the populated resource attributes can be found at IBM Cloud Classic Detector Resource Attributes. Example:

Configuration

You have the ability to specify which detector should collect each attribute with resource_attributes option. An example of such a configuration is:

Using the refresh_interval parameter

The refresh_interval option allows resource attributes to be periodically refreshed without restarting the Collector. Important considerations:
  • Latency: Newly detected resource attributes will be applied after the next refresh cycle completes (up to refresh_interval duration).
  • Metric cardinality: Changes to resource attributes create new metric time series, which can significantly increase storage costs and query complexity.
  • Performance impact: Each refresh re-runs all configured detectors. Values below 5 minutes can increase CPU and memory usage. There is no enforced minimum, but intervals below 1 minute are strongly discouraged.
Recommendation: In most environments, a single resource detection at startup is sufficient. Periodic refresh should be used only when resource attributes are expected to change during the Collector’s lifetime (e.g., Kubernetes pod labels, cloud instance tags).

Using the fail_on_missing_metadata parameter

The fail_on_missing_metadata option controls whether detectors treat an unreachable metadata service as a hard failure. When set to true, affected detectors return an error instead of silently returning an empty resource, enabling the collector’s retry mechanism to wait until the metadata service becomes available. This is particularly useful for workloads where the metadata service may be temporarily unavailable during node startup.
Note: The per-detector fail_on_missing_metadata fields in the ec2, alibaba_ecs, tencent_cvm, upcloud, vultr, and nova detector configs are deprecated. Use this top-level flag instead.

Performance

Benchmark Tests

This component includes comprehensive benchmark tests for all stable signals. The benchmarks measure the performance of the processor under different configurations:
  • Traces: BenchmarkConsumeTracesDefault and BenchmarkConsumeTracesAll
  • Metrics: BenchmarkConsumeMetricsDefault and BenchmarkConsumeMetricsAll
  • Logs: BenchmarkConsumeLogsDefault and BenchmarkConsumeLogsAll
To run the benchmarks locally:
For the latest benchmark results, see the GitHub Actions workflow runs.

Internal Telemetry

The processor emits internal telemetry to observe resource detection. For the complete list of metrics and their attributes, see the Internal Telemetry documentation.

Ordering

Note that 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 below ordering is recommended.

AWS

  • lambda
  • elastic_beanstalk
  • eks
  • ecs
  • ec2
The full list of settings exposed for this extension are documented in config.go with detailed sample configurations in testdata/config.yaml.

Attributes

Configuration

config.yaml (testdata)

config.yaml (testdata)


Last generated: 2026-08-24