Skip to content

Commit

Permalink
Add unstructured log example
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerHelmuth committed Sep 22, 2023
1 parent ccfd8b1 commit cef007e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions processor/transformprocessor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,27 @@ transform:
- set(attributes["nested.attr3"], cache["nested"]["attr3"])
```

### Get Severity of an Unstructured Log Body

Given the following unstructured log body

```txt
[2023-09-22 07:38:22,570] INFO [Something]: some interesting log
```

You can find the severity using IsMatch:

```yaml
transform:
error_mode: ignore
log_statements:
- context: log
statements:
- set(severity_number, SEVERITY_NUMBER_INFO) where IsString(body) and IsMatch(body, "\sINFO\s")
- set(severity_number, SEVERITY_NUMBER_WARN) where IsString(body) and IsMatch(body, "\sWARN\s")
- set(severity_number, SEVERITY_NUMBER_ERROR) where IsString(body) and IsMatch(body, "\sERROR\s")
```

## Contributing

See [CONTRIBUTING.md](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/transformprocessor/CONTRIBUTING.md).
Expand Down

0 comments on commit cef007e

Please sign in to comment.