我在docker容器中运行logstash。那么我如何存储:sql_last_value,以便即使创建了一个新容器,查询也应该使用最后一次使用的值,而不是从一开始就使用?
下面是conf文件。
input {
jdbc {
jdbc_driver_library => "<driverpath>/mysql-connector-java-<versionNumber>.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://<MySQL host>:3306/es_db"
jdbc_user => "<myusername>"
jdbc_password => "<mypassword>"
jdbc_paging_enabled => true
tracking_column => "unix_ts_in_secs"
use_column_value => true
tracking_column_type => "numeric"
schedule => "*/5 * * * * *"
statement => "SELECT *, UNIX_TIMESTAMP(modification_time) AS unix_ts_in_secs FROM es_table WHERE (UNIX_TIMESTAMP(modification_time) > :sql_last_value AND modification_time < NOW()) ORDER BY modification_time ASC"
}
}
filter {
mutate {
copy => { "id" => "[@metadata][_id]"}
remove_field => ["id", "@version", "unix_ts_in_secs"]
}
}
output {
elasticsearch {
index => "demo_idx"
document_id => "%{[@metadata][_id]}"
ilm_enabled => false
cloud_id => "<cloud_id>"
cloud_auth => "<cloud_auth>"
ssl => true
}
}
1条答案
按热度按时间kninwzqo1#
您只需使用
last_run_metadata_path
设置将其存储在容器中的某个位置,然后将该文件夹Map到docker配置中的主机。在你的Docker配置中,你需要像这样配置一个卷: