由于与我的问题无关的原因,我需要将端口设置为事件字段。我还不能。这是显示问题的示例代码。
filter {
mutate {
add_field => { "the_port" => 12345 }
convert => { "the_port" => "integer" } # not needed, just in case
}
}
output {
syslog {
facility => "local0"
severity => "warning"
host = [the_host]
port = [the_port] # this throws the error
}
}
Logstash 在这里抛出一个错误(运行 /bin/logstash -f syslog.conf --configtest)说:
Invalid setting for syslog output plugin:
# This setting must be a number
# Expected number, got "the_port" (type the_port)
port => ["the_port"]
查看 logstash 源代码后,logstash 似乎正在对端口值进行一些检查,然后再从变量中完全扩展它。这可以通过将变量的名称更改为数字来确认,然后它通过了配置检查,但不幸的是,名称-编号随后设置为端口,并且变量没有展开。
有没有人比我更了解这里发生的事情?有没有其他人能够从事件字段成功设置端口?任何帮助表示赞赏。谢谢。
附言。logstash 版本 1.5.1