菜单
开源

输出

注意

Promtail 已弃用,并在长期支持 (LTS) 下持续到 2026 年 2 月 28 日。Promtail 将于 2026 年 3 月 2 日到达生命周期结束 (EOL)。你可以在此处找到迁移资源。

output 阶段是一个动作阶段,它从提取的映射 (extracted map) 中获取数据,并更改将发送到 Loki 的日志行。

Schema

yaml
output:
  # Name from extracted data to use for the log entry.
  source: <string>

示例

对于给定的管道

yaml
- json:
    expressions:
      user: user
      message: message
- labels:
    user:
- output:
    source: message

以及给定的日志行

{"user": "alexis", "message": "hello, world!"}

那么第一个阶段会将以下键值对提取到提取的映射 (extracted map) 中

  • user: alexis
  • message: hello, world!

然后第二个阶段会将 user=alexis 添加到输出日志行的标签集中,最终的 output 阶段会将日志行从原始 JSON 更改为 hello, world!