根据logstash documentation,我可以这样做:
$ export VAR=some_value
input {
jdbc {
jdbc_connection_string => ...
jdbc_user => ...
jdbc_validate_connection => ..
jdbc_password => ...
jdbc_driver_library => ..
jdbc_driver_class => ...
jdbc_paging_enabled => ...
jdbc_page_size => ..
statement => "SELECT * FROM table where column='{$VAR}'"
}
...
嗯,这没用。所以我试过了:
input {
jdbc {
jdbc_connection_string => ...
jdbc_user => ...
jdbc_validate_connection => ..
jdbc_password => ...
jdbc_driver_library => ..
jdbc_driver_class => ...
jdbc_paging_enabled => ...
jdbc_page_size => ..
parameters => {"var" => "${VAR}" }
statement => "SELECT * FROM table where column= :var"
}
但是,什么也没发生。要清楚,当我使用
时 statement => "SELECT * FROM table where column= 'some_value' "
一切正常。那么,我如何让logstash识别环境变量呢?