use*_*099 6 file logstash output
可以请有人向我解释,为什么logstash一直忽略"codec => plain => format"设置,我试图设置?
我正在使用的Cfg文件:
input {
gelf {
host => "[some ip]"
port => 12201
}
}
output {
elasticsearch {
host => "[some ip]"
bind_port => "9301"
}
file {
codec => plain {
format => "%{[time]} | %{[severity]} : /%{[thread]}/ %{[loggername]} (%{[sourcemethodname]}) - %{[message]}"
}
path => "/Users/[some user]/logs/%{host}/%{facility}-%{+YYYY-MM-dd}.log"
}
}
Run Code Online (Sandbox Code Playgroud)
我以为我使用了错误的格式,为字段尝试了不同的组合,如"%{time}",甚至尝试使用常量文本,如:
codec => plain {format => "Simple line"}
Run Code Online (Sandbox Code Playgroud)
但似乎没有任何效果.它输出到elasticsearch罚款,创建文件夹/文件,但输出为JSON.
如果有人知道它发生了什么,请帮忙.谢谢.
参数message_format已弃用,将在Logstash的未来版本中删除.而不是message_format尝试这样的东西:
file {
codec => line {
format => "%{[time]} | %{[severity]} : /%{[thread]}/ %{[loggername]} (%{[sourcemethodname]}) - %{[message]}"
}
path => "/Users/[some user]/logs/%{host}/%{facility}-%{+YYYY-MM-dd}.log"
}
Run Code Online (Sandbox Code Playgroud)
PS:您使用编解码器的示例plain,请尝试使用line.
file有一个message_format你想要使用的参数:
file {
message_format => "%{[time]} | %{[severity]} : /%{[thread]}/ %{[loggername]} (%{[sourcemethodname]}) - %{[message]}"
path => "/Users/[some user]/logs/%{host}/%{facility}-%{+YYYY-MM-dd}.log"
}
Run Code Online (Sandbox Code Playgroud)