1.安装包下载地址
前提:安装jdk8
一般根据es的版本来确定logstash的版本,一般保持一致即可。
Logstash和es版本对应关系:https://www.elastic.co/cn/support/matrix#matrix_compatibility。
Logstash下载地址:https://www.elastic.co/cn/downloads/past-releases/logstash-7-8-0
2.解压并复制配置文件
3.配置配置文件
input {
file {
path => "/opt/app/logs/fast-boot/*.log"
type => "fast-boot"
exclude => "*.0.log"
start_position => "beginning"
}
file {
path => "/opt/app/logs/nginx/audit.log"
type => "nginx"
exclude => "*.0.log"
start_position => "beginning"
}
}
output {
if [type] == "fast-boot" {
elasticsearch {
hosts => ["http://192.168.137.101:9200"]
index => "app-fast-boot"
}
} else if [type] == "nginx" {
elasticsearch {
hosts => ["http://192.168.137.101:9200"]
index => "app-nginx"
}
}
stdout { codec => rubydebug }
}
4.启动项目
nohup bin/logstash -f config/logstash.conf > logstash.out 2>&1 &
5.在采集目录下输入日志
在/opt/app/logs/fast-boot/
目录下创建.log文件
echo "我是测试22:22" >>a.log
6.验证是否正常采集
此时,在logstash节点就能看到a.log文件中的内容了。然后打开kibana,在索引管理里就能看到配置文件中配置的索引了,此时说明logstash已经搭建好了。
7.新建索引样式
这里得先新建索引样式,然后在Discover里就能搜到了。