1
在某些logstash配置中,我希望有條件地設置配置塊中一個字段的值,而不必重複整個塊。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
}
}
}
什麼是避免重複這兩個區塊的內容,而只是改變了單一的領域是我的最佳方式m感興趣?我希望能夠設置一個變量並在塊內使用該變量,或者在該塊內使用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
}
}