ELK最基本的搭建,不然這個無法進行操作,這是網址:
https://blog.csdn.net/fenghumen/article/details/109083538
yum -y install epel-release
yum -y install nginx
systemctl enable nginx
systemctl start nginx
驗證
[root@bogon conf.d]# netstat -lptnu|grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 73887/nginx: master
tcp6 0 0 :::80 :::* LISTEN 73887/nginx: master
yum -y install httpd-tools
ab -n 1000 -c 1000 http://192.168.1.5/index.html
-n:請求數
-c:並行數
注意:並行數不能大於請求數!!
[root@bogon conf.d]# cat nginx.conf
input {
file {
path => "/var/log/nginx/access.log"
type => "nginx-log"
start_position => "beginning"
}
}
output{
elasticsearch {
hosts => "192.168.1.4:9200"
index => "nginx_log-%{+YYYY.MM.dd}"
}
}
[root@bogon logstash]# cat pipelines.yml
- pipeline.id: nginx
path.config: "/etc/logstash/conf.d/nginx.conf"
方法1
tailf /var/log/elasticsearch/wg007.log
方法2
url -X GET http://192.168.1.4:9200/_cat/indices?v
如果index沒有建立成功,需要做:
1.chmod 777 /var/log -R
2.ab命令壓測nginx服務,生成測試資料。
新增filter模組
filter {
grok {
match => {"message" => "%{NGX}"}
}
}
[root@bogon patterns]# pwd
/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-patterns-core-4.1.2/patterns
[root@bogon patterns]# vim nginx
NGX %{IPORHOST:client_ip} (%{USER:ident}|- ) (%{USER:auth}|-) \[%{HTTPDATE:timestamp}\] "(?:%{WORD:verb} (%{NOTSPACE:request}|-)(?: HTTP/%{NUMBER:http_version})?|-)" %{NUMBER:status} (?:%{NUMBER:bytes}|-) "(?:%{URI:referrer}|-)" "%{GREEDYDATA:agent}"
1 新增一個狀態碼統計圖
pie--Terms--status.keyword
2 統計nginx的pv,uv
metric
3 統計存取前10的ip地址
Horizontal Bar 直方圖
8.4 統計網站存取趨勢圖
Line