情况:
dailyImport.sh
docker exec -it $DOCKER_CONTAINER_NAME opt/logstash/bin/logstash --path.data /tmp/logstash/data -e \
'input {
file {
path => "'$OUTPUT_PATH'"
start_position => "beginning"
sincedb_path => "/dev/null"
mode => "read"
file_completed_action => "delete"
}
}
filter {
csv {
separator => ","
columns => ["foo", "bar", "foo2", "bar2"]
}
}
output {
elasticsearch{
hosts => "localhost:9200"
index => "foo"
document_type => "foo"
}
stdout {}
}'
我尝试并理解的内容:
read
模式和file_completed_action
来删除将停止操作,我尝试了一下,但是没有用。Ctrl + C
才能停止管道。例如:^C[2019-02-21T15:49:07,787][WARN ][logstash.runner ] SIGINT received. Shutting down.
[2019-02-21T15:49:07,899][INFO ][filewatch.observingread ] QUIT - closing all files and shutting down.
[2019-02-21T15:49:09,764][INFO ][logstash.pipeline ] Pipeline has terminated {:pipeline_id=>"main", :thread=>"#<Thread:0x6bdb92ea run>"}
Done
我已阅读到可以执行以下操作,但不知道如何做:
参考:https://discuss.elastic.co/t/stop-logstash-after-processing-the-file/84959
我想要的:
Ctrl + C
。答案 0 :(得分:1)
对于以读取模式输入文件,最近有一种方法可以在读取所有文件后退出该过程,只需设置:
input { file { exit_after_read => true } }