1. 實驗規劃
主機位址 | 安裝服務 |
---|---|
192.168.153.134 | elasticsearch |
192.168.153.135 | logstash |
192.168.153.136 | kibana |
2. ELK安裝
參考部落格連結>> https://blog.csdn.net/m0_46674735/article/details/112004006
3. logstash伺服器的配置
3.1 上傳模闆檔案
上傳nginx_access檔案到下面的目錄
/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-patterns-core-4.1.2/patterns
檢視上傳成功
[[email protected]-135 patterns]# ll nginx_access
-rw-r--r-- 1 root root 311 Jan 26 15:22 nginx_access
3.2 在 /etc/logstash/conf.d/
目錄下編寫nginx.conf 檔案
/etc/logstash/conf.d/
vim /etc/logstash/conf.d/nginx.conf
檔案内容為:
input{
file {
path => "/usr/local/nginx/logs/access.log"
type => "nginx-log"
start_position => "beginning"
}
}
filter {
grok {
match => {"message" => "%{NGINXACCESS}"}
}
}
output{
elasticsearch {
hosts => "192.168.153.134:9200"
index => "nginx-log"
}
}
3.3 開啟logstash服務
systemctl start logstash
4. kibana檢視配置
4.1 添加nginx-log并檢視相比之前會多出很多可用字段

4.2 分析通路nginx的前10的ip
1)
2)
3)
4) 配置顯示通路網站前10的IP
5) 儲存命名
6) 儲存成功
4.3 分析通路nginx網站的pv
1)
2)
3)
4) 顯示PV值
5) 儲存命名
6) 儲存成功
5. 建立儀表闆顯示pv和uv
1)
2)
3) 點選即可添加
4) 儲存儀表闆并命名
5) 儲存成功