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
| Parameter | Type | Default | Required | Description |
|---|---|---|---|---|
attributes | object[] | — | Yes | At least one attribute action. Actions are applied in order. |
Action fields
| Field | Type | Required | Description |
|---|---|---|---|
key | string | Yes | Resource attribute key the action targets (or creates). |
action | string | Yes | One of insert, update, upsert, delete, hash, extract. |
value | string | When applicable | Static value to set (for insert/update/upsert). |
from_attribute | string | Optional | Copy the value from another existing resource attribute. Mutually exclusive with value and from_context. |
from_context | string | Optional | Copy the value from a request context key (advanced — receiver-specific). |
pattern | string | When action=extract | Regex 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
| Action | Behavior |
|---|---|
insert | Set key to value only if key does not already exist. |
update | Set key to value only if key already exists. No-op otherwise. |
upsert | Always set key to value, creating or replacing. |
delete | Remove key from the resource. |
hash | Replace the value at key with its SHA-1 hash (for sensitive identifiers). |
extract | Apply 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
deletefollowed by aninsertof the same key is a deterministic upsert; the reverse is a no-op forinsert. extractconsumes the source. After anextract, the originalkeyis removed. Add aninsertto retain it if needed.from_contextis receiver-specific. Most receivers don't expose request context keys. When in doubt, usefrom_attribute.