# 路由

路由是一项核心功能，它允许您通过过滤器**路由**您的数据，最后到达一个或多个目的地。路由器依赖[标签](/fluentbit/concepts/key-concepts.md#tag)和[匹配](/fluentbit/concepts/key-concepts.md#match)规则的概念。

![](/files/-M82rgqcXtvO2vsQ5s64)

路由中有两个重要概念:

* Tag
* Match

当数据由输入插件生成时，它带有**Tag**(大多数情况下，是手动配置标签)。标签是易于识别的标志，有助于识别数据源。

为了指定应将数据路由到**何处**，必须在输出配置中指定**匹配**规则。

考虑如下配置示例，该示例将 CPU 指标传递给 Elasticsearch 数据库，将内存指标传递给标准输出接口:

```
[INPUT]
    Name cpu
    Tag  my_cpu

[INPUT]
    Name mem
    Tag  my_mem

[OUTPUT]
    Name   es
    Match  my_cpu

[OUTPUT]
    Name   stdout
    Match  my_mem
```

> 注意: 以上是演示如何配置路由的一个简单示例。

路由会自动读取 Input Tag 和 Output Match 规则。如果某些数据的 Tag 与路由阶段的规则不匹配，则该数据将被删除。

## 使用通配符路由 <a href="#routing-with-wildcard" id="routing-with-wildcard"></a>

路由足够灵活，支持**Match**模式中的 *wildcard(通配符)*。下面的示例为两个数据源定义了一个公共目标:

```
[INPUT]
    Name cpu
    Tag  my_cpu

[INPUT]
    Name mem
    Tag  my_mem

[OUTPUT]
    Name   stdout
    Match  my_*
```

匹配规则设置为 **`my_*`**，它将匹配以 **`my_`** 开头的所有标签。


---

# Agent Instructions: 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/concepts/data-pipeline/router.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.
