注意: Elastic官網更新很是的快,每一個版本的文檔有會有不一樣,具體須要去官網查看最新文檔進行配置調整。php
Beats 平臺集合了多種單一用途數據採集器。這些採集器安裝後可用做輕量型代理,從成百上千或成千上萬臺機器向 Logstash 或 Elasticsearch 發送數據。html
官網網址爲:https://www.elastic.co/en/products/beatsnginx
Beats在6.0和和Logstash的主要分工的,Betas提供定製化的、輕量級的日誌上報功能,並結合kibana自動生成圖標功能,Logstash主要是分析自定義化的日誌上報功能。sql
功能 | 說明 |
---|---|
FileBeat | 包含對Apache、Nginx、Mysql等日誌的上報功能 |
MetricBeat | 監控日誌上報,結合kibana提供報表服務,如系統監控、apache、nginx鏈接狀態、php-fpm、zookeeper、kafka等。 |
PacketBeat | 監控應用程序的網絡數據包狀況,如Redis、ICMP、HTTP、DNS等 |
WinlogBeat | windows的事件日誌,可上報到logstash、elasticsearch,並使用kibana圖表化 |
AutidtBeat | 系統的審計數據 |
HeartBeat | 運行時間監控 支持ICMP、TCP 和 HTTP 進行 ping 檢測,也支持認證方式的檢測 |
FileBeat架構圖docker
咱們實例安裝一個metricBeat,並配置system監控模塊,最後將圖標發送到kibana平臺上實時查看。shell
官網下載地址爲:https://www.elastic.co/downloads/beats/metricbeatapache
我目前在試用的最新版本爲6.0版本,官網最新把ELK的版本號都進行了統一,如今對每一個版本的軟件之間的兼容性也有了很是清晰的說明。vim
咱們試用rpm包方式安裝,能自動建立init.d/並託管給系統service管理,方便咱們後面的維護windows
# wget https://artifacts.elastic.co/downloads/beats/metricbeat/metricbeat-6.0.0-x86_64.rpm # rpm -ivh metricbeat-6.0.0-x86_64.rpm # chkconfig --add metricbeat # chkconfig metricbeat on # vim /etc/metribeat/metribeat.yml
可執行文件目錄: /usr/share/metricbeat
網絡
日誌目錄: /var/log/metricbeat
配置文件目錄:/etc/metricbeat/
編輯配置文件metribeat.yml
,配置文件的格式yaml格式,主要配置兩處,setup.kibana和output.elasticsearch,若是es安裝了x-pack security插件,則須要配置username和password字段。
setup.kibana: # Kibana Host # Scheme and port can be left out and will be set to the default (http and 5601) # In case you specify and additional path, the scheme is required: http://localhost:5601/path # IPv6 addresses should always be defined as: https://[2001:db8::1]:5601 host: "172.31.7.116:5601" username : "kibana" password : "xxx" output.elasticsearch: # Array of hosts to connect to. hosts: ["172.31.7.116:9200", "172.31.0.155:9200"] # Optional protocol and basic auth credentials. protocol: "http" username: "elastic" password: "xxx"
固然metricbeat還支持nginx、apache、docker、kibana等不少模塊,每一個模塊的配置文件在./modules.d/文件夾中,須要把擴展名重命名爲.yml纔會被加載。
# vim /etc/metricbeat/modules.d/system.yml # mv /etc/metricbeat/modules.d/system.yml.idsabled /etc/metricbeat/modules.d/system.yml - module: system period: 10s metricsets: - cpu - load - memory - network - process - process_summary - core - diskio - socket processes: ['.*'] process.include_top_n: by_cpu: 5 # include top 5 processes by CPU by_memory: 5 # include top 5 processes by memory - module: system period: 1m metricsets: - filesystem - fsstat processors: - drop_event.when.regexp: system.filesystem.mount_point: '^/(sys|cgroup|proc|dev|etc|host|lib)($|/)'
若是須要在kibana的儀表板顯示,須要先新建metribeat-*索引,系統自帶了命令能夠自動建立,運行前須要確保kibana是否正常運行,若是是rpm安裝執行如下命令便可,若是是綠色安裝則要增長-c yml配置文件目錄
# metricbeat setup --dashboards
# service metricbeat start
若是啓動失敗,能夠查看/var/log/metricbeat/metricbeat
日誌文件錯誤信息,進行排查緣由。
參考官方文檔
利用metricbeat能夠將應用層的數據上報給監控平臺,發現ELK最新版本的功能是愈來愈強大了,如今都涉及到監控這塊了,雖然沒有zibbix功能強大, 可是配合使用仍是不錯的,kibana平臺的圖表功能也是愈來愈強大了,6.0明顯的感受是配置愈來愈簡單,功能愈來愈強大。