if在输出部分中使用条件,例如,基于消息类型或对选择索引有意义的任何消息字段。
input { udp { ... type => "foo" } file { ... type => "bar" }}output { if [type] == "foo" { elasticsearch { ... index => "foo-index" } } else { elasticsearch { ... index => "bar-index" } }}或者,如果消息类型可以直接进入索引名称,则可以有一个输出声明:
elasticsearch { ... index => "%{type}-index"}


