logstash块中的条件或变量

logstash块中的条件或变量,logstash,logstash-configuration,Logstash,Logstash Configuration,在一些日志存储配置中,我希望在配置块中有条件地设置一个字段的值,而不必重复整个块 例如,我有两个设置非常相似的http输出: output { if "foo" in [tags] { http { url => "http://example.com/x" http_method => "post" follow_redirects => true keep

在一些日志存储配置中,我希望在配置块中有条件地设置一个字段的值,而不必重复整个块

例如,我有两个设置非常相似的
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
,但找不到这两种方法的示例

我正在寻找类似以下类型的东西(这是无效的配置):


在filter{}部分设置一个变量(可能是mutate->add_字段),然后在输出节中引用该变量,例如:

url => "%{myField}"
如果不想在elasticsearch中存储变量,请在两个位置使用元数据,例如:

[@metadata][myField]
[@metadata][myField]