根據elastic上的說法:javascript
Filebeat is a lightweight, open source shipper for log file data. As the next-generation Logstash Forwarder, Filebeat tails logs and quickly sends this information to Logstash for further parsing and enrichment or to Elasticsearch for centralized storage and analysis.html
Filebeat比Logstash貌似更好,是下一代的日誌收集器,ELK(Elastic + Logstash + Kibana)之後估計要更名成EFK。java
Filebeat使用方法:node
http://www.dahouduan.com/2016/10/17/bigdata-filebeat-elasticsearch-kibana-elk/nginx
在日誌所在服務器上安裝Filebeat 收集日誌docker
rpm --import https://packages.elastic.co/GPG-KEY-elasticsearchapache
建立 vi /etc/yum.repos.d/beat.repo 文件安全
保存如下內容bash
[beats]服務器
name=Elastic Beats Repository
baseurl=https://packages.elastic.co/beats/yum/el/$basearch
enabled=1
gpgkey=https://packages.elastic.co/GPG-KEY-elasticsearch
gpgcheck=1
開始安裝 yum -y install filebeat
開機自啓動 chkconfig --add filebeat
啓動命令 service filebeat start
修改filebeat.yml 配置文件
vi /etc/filebeat/filebeat.yml
重啓服務
service filebeat restart
轉入後臺運行,最後到kibana裏,建立一個索引,注意pattern爲:filebeat-*
2、kibana的登陸認證問題
kibana是nodejs開發的,自己並無任何安全限制,直接瀏覽url就能訪問,若是公網環境很是不安全,能夠經過nginx請求轉發增長認證,方法以下:
tips:kibana沒有重啓命令,要重啓,只能ps -ef|grep node 查找nodejs進程,幹掉重來。
一、參考如下內容,修改配置文件:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
server {
listen 80;
server_name kibana.xxx.com;
location / {
auth_basic
"secret"
;
auth_basic_user_file /data/nginx/db/passwd.db;
proxy_pass http:
//localhost:5601;
proxy_set_header Host $host:5601;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Via
"nginx"
;
}
access_log off;
}
|
上面的配置表示將kibana.xxx.com的請求,轉發到服務器的5601端口,同時使用最基本的用戶名、密碼來認證。
二、配置登陸用戶名,密碼
1
|
htpasswd -c
/data/nginx/db/passwd
.db kibana
|
注意passwd.db的路徑要跟nginx配置中的一致,最後的kibana爲用戶名,能夠隨便改,
輸入完該命令後,系統會提示輸入密碼,搞定後passwd.db中就有加密後的密碼了,有興趣的能夠cat看下。
提示:htpasswd是apache自帶的小工具,若是找不到該命令,嘗試用yum install httpd安裝
三、關掉kibana端口的外網訪問
用nginx轉發後,必定要記得配置iptables之類的防火牆,禁止外部直接訪問5601端口,這樣就只能經過nginx來訪問了。
參考文章:
一、http://elk-docker.readthedocs.org/
二、https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-getting-started.html