> ## Documentation Index
> Fetch the complete documentation index at: https://otel.fyi/llms.txt
> Use this file to discover all available pages before exploring further.

# Resource

> OpenTelemetry processor for Resource

# Resource Processor

![Status](https://img.shields.io/badge/status-beta-yellow)

**Available in:** `core`, `contrib`, `k8s`

**Maintainers:** [@dmitryax](https://github.com/dmitryax)

**Source:** [opentelemetry-collector-contrib](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/resourceprocessor)

## Supported Telemetry

![Logs](https://img.shields.io/badge/logs-beta-blue) ![Metrics](https://img.shields.io/badge/metrics-beta-green) ![Traces](https://img.shields.io/badge/traces-beta-orange)

## Overview

The resource processor can be used to apply changes on resource attributes.
Please refer to [config.go](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/resourceprocessor/config.go) for the config spec.

`attributes` represents actions that can be applied on resource attributes.
See [Attributes Processor](../attributesprocessor/README.md) for more details on supported attributes actions.

## Supported Actions

* `INSERT`: Inserts the key/value to attributes when the key does not exist
* `UPDATE`: Updates an existing key with a value
* `UPSERT`: Performs insert or update depending on whether the key exists
* `DELETE`: Deletes the attribute
* `HASH`: Computes the SHA-256 hash of an existing value
* `EXTRACT`: Extracts values using a regular expression

## Default Values

The `default_value` field can be used to specify a fallback value when the primary value source (e.g., attribute, or context value) is not available. This is useful for:

* Providing sensible defaults when attributes don't exist
* Ensuring the pipeline doesn't fail due to missing configuration

Examples:

```yaml theme={null}
processors:
  resource:
    attributes:
    # Basic example: set a fixed value
    - key: cloud.availability_zone
      value: "zone-1"
      action: upsert
    
    # Copy from another attribute
    - key: k8s.cluster.name
      from_attribute: k8s-cluster
      action: insert
    
    # Delete an attribute
    - key: redundant-attribute
      action: delete
    
    # Use default_value when source attribute doesn't exist
    - key: region
      from_attribute: cloud.region
      default_value: "us-east-1"
      action: insert
    
    # Use default_value when context value is not available
    - key: tenant_id
      from_context: "metadata.tenant"
      default_value: "default-tenant"
      action: upsert
```

Refer to [config.yaml](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/resourceprocessor/testdata/config.yaml) for detailed
examples on using the processor.

## Configuration

### Example Configuration

```yaml theme={null}
# The following specifies a resource configuration doing the changes on resource attributes:
# 1. Set "cloud.availability_zone" attributes with "zone-1" value ignoring existing values.
# 2. Copy "k8s-cluster" attribute value to "k8s.cluster.name" attribute, nothing happens if "k8s-cluster" not found.
# 3. Remove "redundant-attribute" attribute.
# There are many more attribute modification actions supported,
# check processor/attributesprocessor/testdata/config.yaml for reference.
resource:
  attributes:
  - key: cloud.availability_zone
    value: zone-1
    action: upsert
  - key: k8s.cluster.name
    from_attribute: k8s-cluster
    action: insert
  - key: redundant-attribute
    action: delete

# The following demonstrates using default_value to handle missing environment variables or attributes
resource/with_defaults:
  attributes:
  # Use default when source attribute doesn't exist
  - key: service.namespace
    from_attribute: namespace
    default_value: "default"
    action: insert
  # Use default when context value is not available
  - key: cloud.region
    from_context: "metadata.region"
    default_value: "us-east-1"
    action: upsert

# The following specifies an invalid resource configuration, it has to have at least one action set in attributes field.
resource/empty:
```

***

*Last generated: 2026-07-06*
