> For the complete documentation index, see [llms.txt](https://hulining.gitbook.io/fluentbit/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hulining.gitbook.io/fluentbit/administration/configuring-fluent-bit/commands.md).

# 命令

配置文件必须足够灵活以适应任何部署需求，它们必须保持干净且易读的格式。

Fluent Bit *Commands* 扩展了具有特定内置功能的配置文件。从Fluent Bit 0.12 系列开始可用的命令列表为:

| 命令                                                                                   | 模版            | 描述       |
| ------------------------------------------------------------------------------------ | ------------- | -------- |
| [@INCLUDE](/fluentbit/administration/configuring-fluent-bit/commands.md#cmd_include) | @INCLUDE FILE | 包含一个配置文件 |
| [@SET](/fluentbit/administration/configuring-fluent-bit/commands.md#cmd_set)         | @SET KEY=VAL  | 配置配置变量   |

## @INCLUDE 命令 <a href="#cmd_include" id="cmd_include"></a>

配置日志记录管道可能会有大量配置文件。为了保持易于理解的配置，建议将配置分成多个文件。

`@INCLUDE` 命令允许配置读取器包含一个外部配置文件，例如:

```
[SERVICE]
    Flush 1

@INCLUDE inputs.conf
@INCLUDE outputs.conf
```

上面的示例定义了主服务配置文件，还包括两个文件以延续配置:

### inputs.conf

```
[INPUT]
    Name cpu
    Tag  mycpu

[INPUT]
    Name tail
    Path /var/log/*.log
    Tag  varlog.*
```

### outputs.conf

```
[OUTPUT]
    Name   stdout
    Match  mycpu

[OUTPUT]
    Name            es
    Match           varlog.*
    Host            127.0.0.1
    Port            9200
    Logstash_Format On
```

请注意，不管包含的顺序如何，Fluent Bit **始终**遵循以下顺序:

* Service
* Inputs
* Filters
* Outputs

## @SET 命令 <a href="#cmd_set" id="cmd_set"></a>

Fluent Bit 支持[配置变量](/fluentbit/administration/configuring-fluent-bit/variables.md),向 Fluent Bit 设置变量的一种方法是通过设置 Shell 环境变量，另一种是通过 *`@SET`* 命令

`@SET` 命令只能在每行的根目录级别使用，这意味着它不能在配置段内使用，例如：

```
@SET my_input=cpu
@SET my_output=stdout

[SERVICE]
    Flush 1

[INPUT]
    Name ${my_input}

[OUTPUT]
    Name ${my_output}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hulining.gitbook.io/fluentbit/administration/configuring-fluent-bit/commands.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
