How to shutdown logstash after import csv

I keep seeing this on topics, replied by @magnusbaeck

Use the stdin input instead. Logstash will shut down by itself when stdin has been closed and all inputs has been processed. On the flip side, it Logstash dies for whatever reason you don't know how much it has processed

Silly me, But how to use a stdin with file? Can anyone post a sample

input {
file {
path => "I:\dev\softpack\logstash-2.0.0_csv\bin\csv1\STP20160420.csv"
type => "csv"
start_position => "beginning"
}
}
filter {
csv {
columns => ["trait", "trait_department", "trait_category", "trait_name", "store", "store_type"]
separator => ","
}

}
output {
elasticsearch {
action => "index"
index => "logstash-test-stp"
hosts => "localhost:9200"
workers => 1
}
}

Replace all the file parts with a simple stdin {}.

I replaced it, how could stdin know where then csv is?:joy:

You need to pipe it into Logstash, that'll depend on what OS you are on.

It looks like you are on Windows, so use type I:\dev\softpack\logstash-2.0.0_csv\bin\csv1\STP20160420.csv | logstash -f configfile.conf.

Thank your very much, @warkolm . From head to toe!:heart_eyes:

Here is my success command on windows:
logstash -f csv1\csv2es.conf < I:\dev\softpack\noosh_elasticsearch\logstash-2.0.0_csv\bin\csv1\STP20160425.csv

input {
stdin {
#type => "stdin-type"
}
}
filter {
csv {
columns => ["trait", "trait_department", "trait_category", "trait_name", "store", "store_type"]
separator => ","
}

}
output {
elasticsearch {
action => "index"
index => "logstash-test5-stp"
hosts => "localhost:9200"
workers => 1
}
stdout{}
}

explain link for windows pipe:
http://www.lagmonster.org/docs/DOS7/pipes.html#pipe

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.