logstash7.3.0下载地址:
链接:https://pan.baidu.com/s/1j7sRlgjipxKRhtNvuWRUKw
提取码:9wqv
学习资料:
链接:https://pan.baidu.com/s/1zqNimzuUgU7Gn37J5daG8A
提取码:fjrr
一、下载和安装logstash
直接下载上面连接中的logstash7.3.0,将压缩包下载下来,解压缩就行了
二、input外部插件(text,redis,jdbc等等)
官网参考地址:
https://www.elastic.co/guide/en/logstash/current/input-plugins.html
1.1 input监控外部文件变化,动态获取外部文件数据
text2文件内容:
显示效果:
ceshi.txt文件内容:
1.2 filter(太繁琐)
1.3 output (输出)
例如将软件中的数据放入es中:
input {
file {
path => ["D:/ES/logstash-7.3.0/nginx.log"]
start_position => "beginning"
}
}
filter {
grok {
match => { "message" => "%{IP:clientip}\ \[%{HTTPDATE:timestamp}\]\ %{QS:referrer}\ %{NUMBER:response}\ %{NUMBER:bytes}" }
remove_field => [ "message" ]
}
date {
match => ["timestamp", "dd/MMM/yyyy:HH:mm:ss Z"]
}
mutate {
rename => { "response" => "response_new" }
convert => [ "response","float" ]
gsub => ["referrer","\"",""]
remove_field => ["timestamp"]
split => ["clientip", "."]
}
}
output {
stdout {
codec => "rubydebug"
}
elasticsearch {
host => ["localhost:9200"]
index => "logstash-%{+YYYY.MM.dd}"
}
}