Logstash安装

原创转载请注明出处:https://www.cnblogs.com/agilestyle/p/11765750.html

 

前置条件

ES和Kibana搭建完毕

 

下载Logstash

 

下载MovieLens

 

解压logstash,cd到logstash的bin目录

1 cd ~/app/logstash-7.4.1/bin

 

拷贝MovieLens的movies.csv到bin目录下

 

新建logstash.conf

 1 input {
 2   file {
 3     path => "/Users/haha/app/logstash-7.4.1/bin/movies.csv"
 4     start_position => "beginning"
 5     sincedb_path => "/dev/null"
 6   }
 7 }
 8 filter {
 9   csv {
10     separator => ","
11     columns => ["id","content","genre"]
12   }
13 
14   mutate {
15     split => { "genre" => "|" }
16     remove_field => ["path", "host","@timestamp","message"]
17   }
18 
19   mutate {
20 
21     split => ["content", "("]
22     add_field => { "title" => "%{[content][0]}"}
23     add_field => { "year" => "%{[content][1]}"}
24   }
25 
26   mutate {
27     convert => {
28       "year" => "integer"
29     }
30     strip => ["title"]
31     remove_field => ["path", "host","@timestamp","message","content"]
32   }
33 
34 }
35 output {
36    elasticsearch {
37      hosts => "http://localhost:9200"
38      index => "movies"
39      document_id => "%{id}"
40    }
41   stdout {}
42 }

 

保存退出后,查看bin目录下文件结构

 

在bin目录下执行启动命令

1 ./logstash -f logstash.conf

当看到如下输出,表示数据导入完毕

 

查看Cerebro 

 

Reference

https://grouplens.org/datasets/movielens/

https://www.elastic.co/downloads/logstash

 

posted @ 2019-10-30 16:34  李白与酒  阅读(437)  评论(0编辑  收藏  举报