> For the complete documentation index, see [llms.txt](https://ilogtail.gitbook.io/ilogtail-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ilogtail.gitbook.io/ilogtail-docs/pre-release/plugins/chu-li-cha-jian/kuo-zhan-chu-li-cha-jian/processor-add-fields.md).

# 添加字段

## 简介

`processor_add_fields processor`插件可以添加日志字段。

## 事件能力

列含义见 [概览 · 事件能力列说明](https://ilogtail.gitbook.io/ilogtail-docs/pre-release/plugins/chu-li-cha-jian/kuo-zhan-chu-li-cha-jian/pages/V3l051tHPlzCBkmzOfvu#事件能力列说明)。

| v1 接口 | v2 接口 | Log | Metric | Span |
| ----- | ----- | --- | ------ | ---- |
| ✓     | —     | v1  | 透传未知   | 透传未知 |

## 版本

[Stable](/ilogtail-docs/pre-release/plugins/stability-level.md)

## 版本说明

* 推荐版本：iLogtail v1.0.27 及以上

## 配置参数

| 参数            | 类型     | 是否必选 | 说明                                     |
| ------------- | ------ | ---- | -------------------------------------- |
| Type          | string | 是    | 插件类型。                                  |
| Fields        | Map    | 是    | 待添加字段和字段值。键值对格式，支持添加多个。                |
| IgnoreIfExist | bool   | 否    | 当Key相同时是否忽略。如果未添加该参数，则默认使用false，表示不忽略。 |

## 样例

采集`/home/test-log/`路径下的`test.log`文件，并添加字段service: A用于标识日志所在服务。

* 输入

```bash
echo 'this is a test log' >> /home/test-log/test.log
```

* 采集配置

```yaml
enable: true
inputs:
  - Type: input_file
    FilePaths: 
      - /home/test-log/*.log
processors:
  - Type: processor_add_fields
    Fields: 
      service: A
    IgnoreIfExist: false
flushers:
  - Type: flusher_stdout
    OnlyStdout: true
```

* 输出

```json
{
    "__tag__:__path__": "/home/test-log/test.log",
    "content": "this is a test log",
    "service": "A",
    "__time__": "1657354602"
}
```
