【发布时间】:2015-11-09 10:59:16
【问题描述】:
在某些logstash配置中,我想有条件地设置配置块中一个字段的值,而不必重复整个块。
例如,我有两个设置非常相似的http 输出:
output {
if "foo" in [tags] {
http {
url => "http://example.com/x"
http_method => "post"
follow_redirects => true
keepalive => false
connect_timeout => 20
cookies => true
}
} else {
http {
url => "http://example.com/y"
http_method => "post"
follow_redirects => true
keepalive => false
connect_timeout => 20
cookies => true
}
}
}
避免重复这两个块的内容以及只更改我感兴趣的单个字段的最佳方法是什么?我希望我可以设置一个变量并在块内使用它,或者在块内使用if,但找不到任何一个示例。
我正在寻找类似以下的东西(这是无效的配置):
output {
http {
if "foo" in [tags] {
url => "http://example.com/x"
} else {
url => "http://example.com/y"
}
http_method => "post"
follow_redirects => true
keepalive => false
connect_timeout => 20
cookies => true
}
}
【问题讨论】:
标签: logstash logstash-configuration