Skip to content

Commit 3f0610d

Browse files
authored
feat: document decolorize processor (#1341)
Signed-off-by: Ruihang Xia <[email protected]>
1 parent 3f6d2ae commit 3f0610d

File tree

2 files changed

+37
-5
lines changed

2 files changed

+37
-5
lines changed

i18n/zh/docusaurus-plugin-content-docs/current/user-guide/logs/pipeline-config.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Processor 由一个 name 和多个配置组成,不同类型的 Processor 配
4444

4545
- `date`: 解析格式化的时间字符串字段,例如 `2024-07-12T16:18:53.048`。
4646
- `epoch`: 解析数字时间戳字段,例如 `1720772378893`。
47+
- `decolorize`: 移除日志数据中的 ANSI 颜色代码。
4748
- `dissect`: 对 log 数据字段进行拆分。
4849
- `gsub`: 对 log 数据字段进行替换。
4950
- `join`: 对 log 中的 array 类型字段进行合并。
@@ -110,6 +111,21 @@ processors:
110111
- `resolution`: 时间戳精度,支持 `s`, `sec` , `second` , `ms`, `millisecond`, `milli`, `us`, `microsecond`, `micro`, `ns`, `nanosecond`, `nano`。默认为 `ms`。
111112
- `ignore_missing`: 忽略字段不存在的情况。默认为 `false`。如果字段不存在,并且此配置为 false,则会抛出异常。
112113

114+
### `decolorize`
115+
116+
`decolorize` Processor 用于移除日志数据中的 ANSI 颜色代码。示例配置如下:
117+
118+
```yaml
119+
processors:
120+
- decolorize:
121+
fields:
122+
- message
123+
```
124+
125+
如上所示,`decolorize` Processor 的配置包含以下字段:
126+
127+
- `fields`: 需要移除颜色代码的字段名列表。
128+
113129
### `dissect`
114130

115131
`dissect` Processor 用于对 log 数据字段进行拆分,示例配置如下:

versioned_docs/version-0.10/user-guide/logs/pipeline-config.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ We currently provide the following built-in Processors:
4242

4343
- `date`: parses formatted time string fields, such as `2024-07-12T16:18:53.048`.
4444
- `epoch`: parses numeric timestamp fields, such as `1720772378893`.
45+
- `decolorize`: removes ANSI color codes from log data.
4546
- `dissect`: splits log data fields.
4647
- `gsub`: replaces log data fields.
4748
- `join`: merges array-type fields in logs.
@@ -108,6 +109,21 @@ In the above example, the configuration of the `epoch` processor includes the fo
108109
- `resolution`: Timestamp precision, supports `s`, `sec`, `second`, `ms`, `millisecond`, `milli`, `us`, `microsecond`, `micro`, `ns`, `nanosecond`, `nano`. Defaults to `ms`.
109110
- `ignore_missing`: Ignores the case when the field is missing. Defaults to `false`. If the field is missing and this configuration is set to `false`, an exception will be thrown.
110111

112+
### `decolorize`
113+
114+
The `decolorize` processor is used to remove ANSI color codes from log data. Here's an example configuration:
115+
116+
```yaml
117+
processors:
118+
- decolorize:
119+
fields:
120+
- message
121+
```
122+
123+
In the above example, the configuration of the `decolorize` processor includes the following fields:
124+
125+
- `fields`: A list of field names to be decolorized.
126+
111127
### `dissect`
112128

113129
The `dissect` processor is used to split log data fields. Here's an example configuration:
@@ -142,12 +158,12 @@ Similar to Logstash's dissect pattern, the dissect pattern consists of `%{key}`,
142158

143159
The dissect pattern supports the following modifiers:
144160

145-
| Modifier | Description | Example |
146-
| ---------- | ---------------------------------------------------- | -------------------- |
147-
| `+` | Concatenates two or more fields together | `%{+key} %{+key}` |
161+
| Modifier | Description | Example |
162+
| ------------ | ------------------------------------------------------ | --------------------- |
163+
| `+` | Concatenates two or more fields together | `%{+key} %{+key}` |
148164
| `+` and `/n` | Concatenates two or more fields in the specified order | `%{+key/2} %{+key/1}` |
149-
| `->` | Ignores any repeating characters on the right side | `%{key1->} %{key2->}` |
150-
| `?` | Ignores matching values | `%{?key}` |
165+
| `->` | Ignores any repeating characters on the right side | `%{key1->} %{key2->}` |
166+
| `?` | Ignores matching values | `%{?key}` |
151167

152168
#### `dissect` examples
153169

0 commit comments

Comments
 (0)