數據輸入
input{
tcp{
host => "127.0.0.1"
port => 9100
codec => "json"
}
}
數據過濾
filter{
mutate{
lowercase=>["springAppName"] 轉爲小寫 索引不能有大寫
}
if ![traceId] or ![spanId] or [traceId]==[spanId]{
mutate{
add_field => {"info"=>"service inner call not sent to es"}
}
}
}
數據輸出
output{
if [info] 判斷 info
{
elasticsearch{
action => "index"
hosts => "127.0.0.1:9200"
index => "%{springApName}" 動態索引
}
stdout{codec=>rubydebug} 控制檯輸出
}
}
-
說明
if ![traceId] or ![spanId] or [traceId]==[spanId]
- ![traceId] 表示 字段traceId 不存在
- or 表示條件 或
- ![spanId] 表示 字段 spanId 不存在
- [traceId]==[spanId] 表示字段traceId 和spanId 相等
-
mutate
mutate是 filter中的一個常用插件 配合if語句 可以對輸入的文本內容進行處理 可選的操作 在官網有詳細的說明
ps
- 而是在指定 索引(index)的時候 索引名 要全是小寫 不能有大寫字母
- %{springApName} 這個表示將springApName字段的值拿出來