Skip to content

Commit

Permalink
[chore][processor/transform] add configuration example for copying at…
Browse files Browse the repository at this point in the history
…tributes matching regex (#35893)

Co-authored-by: Evan Bradley <[email protected]>
  • Loading branch information
odubajDT and evan-bradley authored Oct 22, 2024
1 parent 2eda7e9 commit 30c18b8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions processor/transformprocessor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,24 @@ transform:
- set(severity_number, SEVERITY_NUMBER_ERROR) where IsString(body) and IsMatch(body, "\\sERROR\\s")
```

## Copy attributes matching regular expression to a separate location

If you want to move resource attributes, which keys are matching the regular expression `pod_labels_.*` to a new attribute
location `kubernetes.labels`, use the following configuration:

```yaml
transform:
error_mode: ignore
trace_statements:
- context: resource
statements:
- set(cache["attrs"], attributes)
- keep_matching_keys(cache["attrs"], "pod_labels_.*")
- set(attributes["kubernetes.labels"], cache["attrs"])
```

The configuration can be used also with `delete_matching_keys()` to copy the attributes that do not match the regular expression.

## Troubleshooting

When using OTTL you can enable debug logging in the collector to print out useful information,
Expand Down

0 comments on commit 30c18b8

Please sign in to comment.