static_labels
注意
Promtail 已被弃用,并将处于长期支持 (LTS) 状态直至 2026 年 2 月 28 日。Promtail 将于 2026 年 3 月 2 日终止生命周期 (EOL)。您可以在此处找到迁移资源。
static_labels 阶段是一个动作阶段,它向随日志条目发送到 Loki 的标签集添加静态标签。
Schema
static_labels:
[ <string>: [<string>] ... ]
示例
对于给定的管道
- json:
expressions:
stream: stream
- labels:
stream:
- static_labels:
custom_key: custom_val
给定以下日志行
{"log":"log message\n","stream":"stderr","time":"2019-04-30T02:12:41.8443515Z"}
第一个阶段会将 stream 提取到提取映射中,其值为 stderr。labels 阶段会将该键值对转换为标签。static_labels 阶段会将提供的静态标签添加到标签集中。
发送到 Loki 的最终条目将包含 stream="stderr"
和 custom_key="custom_val"
作为标签。