logstash
- 下载对应版本的logstash
wget https://artifacts.elastic.co/downloads/logstash/logstash-7.1.1.tar.gz
下载测试数据
下载最MovieLens最小测试数据集:https://grouplens.org/datasets/movielens/
配置文件logstash.conf
input {
file {
path => "/root/movies.csv" //修改为自己的文件配置目录
start_position => "beginning"
sincedb_path => "/dev/null"
}
}
filter {
csv {
separator => ","
columns => ["id","content","genre"]
}
mutate {
split => { "genre" => "|" }
remove_field => ["path", "host","@timestamp","message"]
}
mutate {
split => ["content", "("]
add_field => { "title" => "%{[content][0]}"}
add_field => { "year" => "%{[content][1]}"}
}
mutate {
convert => {
"year" => "integer"
}
strip => ["title"]
remove_field => ["path", "host","@timestamp","message","content"]
}
}
output {
elasticsearch {
hosts => "http://es:9200" //修改为自己的es地址
index => "movies"
document_id => "%{id}"
}
stdout {}
}
- 执行命令sudo bin/logstash -f /YOUR_PATH_of_logstash.conf