appender

package
v1.8.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

README

字段追加

该插件可为指定字段(可以不存在)追加特定的值,且支持模板参数。

参数说明

插件类型(type)为 processor_appender

参数 类型 必选或可选 参数说明
Key string 必选 Key名称。
Value string 必选 Value值,该值支持模板参数替换,具体模板取值参考下表。
SortLabels bool 可选 bool值,在时序场景下,如果添加了Labels,如果不符合字母序要求,需要重新排序。
模板 说明 替换示例
{{__ip__}} 替换为Logtail的IP地址 10.112.31.40
{{__host__}} 替换为Logtail的主机名 logtail-ds-xdfaf
{{$xxxx}} $开头则会替换为环境变量的取值 例如存在环境变量 key=value,则{{$key}} 为 value
示例

__labels__ 追加一些本机特有的值:

  • 输入
"__labels__":"a#$#b"
  • 配置详情
{
  "processors":[
    {
      "type":"processor_appender",
      "detail": {
        "Key": "__labels__",
        "Value": "|host#$#{{__host__}}|ip#$#{{__ip__}}"
      }
    }
  ]
}
  • 配置后结果
"__labels__":"a#$#b|host#$#david|ip#$#30.40.60.150"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProcessorAppender

type ProcessorAppender struct {
	Key        string
	Value      string
	SortLabels bool
	Platform   platformmeta.Platform
	ReadOnce   bool
	// contains filtered or unexported fields
}

func (*ProcessorAppender) Description

func (*ProcessorAppender) Description() string

func (*ProcessorAppender) Init

func (p *ProcessorAppender) Init(context pipeline.Context) error

Init called for init some system resources, like socket, mutex...

func (*ProcessorAppender) ParseVariableValue added in v1.4.0

func (p *ProcessorAppender) ParseVariableValue(key string) string

ParseVariableValue parse specific key with logic:

  1. if key start with '$', the get from env
  2. if key == __ip__, return local ip address
  3. if key == __host__, return hostName others return key

func (*ProcessorAppender) ProcessLogs

func (p *ProcessorAppender) ProcessLogs(logArray []*protocol.Log) []*protocol.Log

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL