十年網(wǎng)站開發(fā)經(jīng)驗 + 多家企業(yè)客戶 + 靠譜的建站團隊
量身定制 + 運營維護+專業(yè)推廣+無憂售后,網(wǎng)站問題一站解決
filebeat 6.4.3 采集 nginx日志
創(chuàng)新互聯(lián)專注于中大型企業(yè)的成都網(wǎng)站建設、網(wǎng)站設計和網(wǎng)站改版、網(wǎng)站營銷服務,追求商業(yè)策劃與數(shù)據(jù)分析、創(chuàng)意藝術與技術開發(fā)的融合,累計客戶上千余家,服務滿意度達97%。幫助廣大客戶順利對接上互聯(lián)網(wǎng)浪潮,準確優(yōu)選出符合自己需要的互聯(lián)網(wǎng)運用,我們將一直專注品牌網(wǎng)站設計和互聯(lián)網(wǎng)程序開發(fā),在前進的路上,與客戶一起成長!
將日志配置組合添加至nginx主配置文件;
log_format eslog '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
集群收集nginx日志需要安裝 ingest-user-agent ,ingest-geoip ,安裝完成之后需要重啟es 服務,否則數(shù)據(jù)無法正常錄入es集群。
/usr/share/elasticsearch/bin/elasticsearch-plugin install ingest-user-agent
/usr/share/elasticsearch/bin/elasticsearch-plugin install ingest-geoip
/usr/share/elasticsearch/bin/elasticsearch-plugin list
yum install java-1.8 -y
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
more lostash.repo
[elastic-6.x]
name=Elastic repository for 6.x packages
baseurl=https://artifacts.elastic.co/packages/6.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
yum install filebeat -y
more /etc/filebeat/filebeat.yml
filebeat.config:
prospectors:
path: ${path.config}/prospectors.d/.yml
reload.enabled: false
modules:
path: /etc/filebeat/modules.d/.yml
reload.enabled: false
output.elasticsearch:
hosts: ['10.2.3.30:9200']
setup.kibana:
host: "10.2.3.13:5601"
Access 日志:/data/nginxlog/eslog/es-access.*
Error 日志:/data/nginxlog/eslog/es-error.*
more /etc/filebeat/modules.d/nginx.yml
- module: nginx
# Access logs
access:
enabled: true
# Set custom paths for the log files. If left empty,
# Filebeat will choose the paths depending on your OS.
var.paths: ["/data/nginxlog/eslog/es-access.*"]
# Error logs
error:
enabled: true
# Set custom paths for the log files. If left empty,
# Filebeat will choose the paths depending on your OS.
var.paths: ["/data/nginxlog/eslog/es-error.*"]
systemctl enable filebeat
cd /etc/filebeat
filebeat modules enable nginx
filebeat modules list
此操作會自動導入filebeat模板和nginx dashboard 到es 集群:
Set up the initial environment:
Loaded index template
Loading dashboards (Kibana must be running and reachable)
Loaded dashboards
Loaded machine learning job configurations
./filebeat setup -e
systemctl start filebeat
內(nèi)容如下:
Exiting: Error importing Kibana dashboards: fail to import the dashboards in Kibana: Error importing directory /usr/share/filebeat/kibana: Failed to import index-pattern: Failed to load directory /usr/share/filebeat/kibana/6/index-pattern:
error loading /usr/share/filebeat/kibana/6/index-pattern/filebeat.json: returned 400 to import file: . Response: {"statusCode":400,"error":"Bad Request","message":"Request Timeout after 30000ms"}
2018-10-31T16:35:45.659+0900 INFO kibana/client.go:113 Kibana url: http://10.2.3.13:5601
2018-10-31T16:37:15.664+0900 ERROR instance/beat.go:743 Exiting: Error importing Kibana dashboards: fail to import the dashboards in Kibana: Error importing directory /usr/share/filebeat/kibana: Failed to import index-pattern: Failed to load directory /usr/share/filebeat/kibana/6/index-pattern:
error loading /usr/share/filebeat/kibana/6/index-pattern/filebeat.json: fail to execute the HTTP POST request: Post http://10.2.3.13:5601/api/kibana/dashboards/import?force=true: net/http: request canceled (Client.Timeout exceeded while awaiting headers). Response:
登陸kibana 進入Dev tools 刪除
#DELETE _template/filebeat-6.X.X
#DELETE filebeat-6.4.2-*
cd /etc/filebeat/
filebeat setup
Loaded index template
Loading dashboards (Kibana must be running and reachable)
Loaded dashboards
Loaded machine learning job configurations
systemctl restart filebeat