-
ElasticSearch映象
-
Logstash映象
-
Kibana映象
-
Nginx映象(作為容器化應用來生產日誌)
vim /etc/rsyslog.conf
$ModLoad imtcp
$InputTCPServerRun 514
*.* @@localhost:4560
systemctl restart rsyslog
netstat -tnl
docker run -d -p 9200:9200 \
-v ~/elasticsearch/data:/usr/share/elasticsearch/data \
--name elasticsearch elasticsearch
input {
syslog {
type => "rsyslog"
port => 4560
}
}
output {
elasticsearch {
hosts => [ "elasticsearch:9200" ]
}
}
docker run -d -p 4560:4560 \
-v ~/logstash/logstash.conf:/etc/logstash.conf \
--link elasticsearch:elasticsearch \
--name logstash logstash \
logstash -f /etc/logstash.conf
docker run -d -p 5601:5601 \
--link elasticsearch:elasticsearch \
-e ELASTICSEARCH_URL=http://elasticsearch:9200 \
--name kibana kibana
docker run -d -p 90:80 --log-driver syslog --log-opt \
syslog-address=tcp://localhost:514 \
--log-opt tag="nginx" --name nginx nginx
-
瀏覽器開啟localhost:90來開啟Nginx介面,並掃清幾次,讓後臺產生GET請求的日誌
-
開啟Kibana視覺化介面:localhost:5601
localhost:5601
-
收集Nginx應用日誌
收集Nginx應用日誌
-
查詢應用日誌
在查詢框中輸入program=nginx可查詢出特定日誌
查詢應用日誌