Skip to main content

Resource

Overview

The Resource processor modifies attributes on the resource of every record passing through it (not the record body or its attributes). Use it to:

  • Stamp deployment-wide metadata (deployment.environment, cloud.region) onto every signal a collector emits.
  • Rename or drop noisy resource attributes inherited from a receiver.
  • Hash a sensitive resource attribute before export.
  • Extract structured fields from one attribute into multiple new attributes via regex.

For changes to record attributes (per-log fields, per-span tags) use the Transform processor or the dedicated add/copy/delete/rename field processors instead — those operate on the record, not the resource.

Supported types: Logs · Metrics · Traces

Configuration

ParameterTypeDefaultRequiredDescription
attributesobject[]YesAt least one attribute action. Actions are applied in order.

Action fields

FieldTypeRequiredDescription
keystringYesResource attribute key the action targets (or creates).
actionstringYesOne of insert, update, upsert, delete, hash, extract.
valuestringWhen applicableStatic value to set (for insert/update/upsert).
from_attributestringOptionalCopy the value from another existing resource attribute. Mutually exclusive with value and from_context.
from_contextstringOptionalCopy the value from a request context key (advanced — receiver-specific).
patternstringWhen action=extractRegex with named capture groups. Each group becomes a new resource attribute keyed by the group's name; the source attribute (key) is consumed.

Action semantics

ActionBehavior
insertSet key to value only if key does not already exist.
updateSet key to value only if key already exists. No-op otherwise.
upsertAlways set key to value, creating or replacing.
deleteRemove key from the resource.
hashReplace the value at key with its SHA-1 hash (for sensitive identifiers).
extractApply pattern (regex with named groups) to the value at key; promote each named group to a new resource attribute. The original key is removed.

Example Configuration

{
"attributes": [
// Stamp a deployment-wide tag (creates only if missing — receivers can override)
{ "action": "insert", "key": "deployment.environment", "value": "production" },

// Always overwrite cloud.region with the value the supervisor injects
{ "action": "upsert", "key": "cloud.region", "value": "us-central1" },

// Mirror service.namespace into a vendor-specific key without removing the original
{ "action": "insert", "key": "vendor.namespace", "from_attribute": "service.namespace" },

// Drop a noisy attribute from the kubelet stats receiver
{ "action": "delete", "key": "container.id.short" },

// SHA-1 the customer ID before export
{ "action": "hash", "key": "customer.id" },

// Split host.name "node-01.zone-a.cluster-01" into three attributes
{
"action": "extract",
"key": "host.name",
"pattern": "^(?P<host>[^.]+)\\.(?P<zone>[^.]+)\\.(?P<cluster>[^.]+)$",
},
],
}

Notes

  • Resource vs record. Resource attributes describe the thing producing the signal (the host, the service, the K8s pod). They're shared across every record that comes from the same source. If you find yourself wanting to set a per-record value, you want the Transform processor, not this one.
  • Order of operations. Actions execute top-to-bottom. A delete followed by an insert of the same key is a deterministic upsert; the reverse is a no-op for insert.
  • extract consumes the source. After an extract, the original key is removed. Add an insert to retain it if needed.
  • from_context is receiver-specific. Most receivers don't expose request context keys. When in doubt, use from_attribute.