ELK添加監(jiān)控主機

1.獲取filebeat并安裝

53和54主機操作

mkdir /data/soft/ -p ##創(chuàng)建軟件目錄
wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.6.0-x86_64.rpm ##獲取軟件包
rpm -ivh filebeat-6.6.0-x86_64.rpm ##開始安裝

2.修改filebeat配置文件

53和54主機操作

vim /etc/filebeat/filebeat.yml ##修改配置文件
##填寫以下內(nèi)容
filebeat.inputs:
- type: log
  enabled: true
  paths:
    - /var/log/nginx/access.log
  json.keys_under_root: true
  json.overwrite_keys: true

setup.kibana:
  host: "172.16.210.53:5601"

output.elasticsearch:
  hosts: ["172.16.210.53:9200"]
  index: "nginx-%{[beat.version]}-%{+yyyy.MM}"
setup.template.name: "nginx"
setup.template.pattern: "nginx-*"
setup.template.enabled: false
setup.template.overwrite: true

3.安裝nginx

在54和55主機操作

yum install -y nginx ##安裝nginx

4.修改nginx配置文件

53和54主機操作

vim /etc/nginx/nginx.conf  ##修改nginx配置文件
##在http板塊添加json格式的日志
http {
    log_format json '{ "time_local": "$time_local", '
                            '"remote_addr": "$remote_addr", '
                            '"referer": "$http_referer", '
                            '"request": "$request", '
                            '"status": $status, '
                            '"bytes": $body_bytes_sent, '
                            '"agent": "$http_user_agent", '
                            '"x_forwarded": "$http_x_forwarded_for", '
                            '"up_addr": "$upstream_addr",'
                            '"up_host": "$upstream_http_host",'
                            '"up_resp_time": "$upstream_response_time",'
                            '"request_time": "$request_time"'
 ' }';
 ##設(shè)置日志文件調(diào)用json格式
     access_log  /var/log/nginx/access.log  json;

5.啟動nginx和filebeat

53和54主機操作

systemctl start nginx
systemctl start filebeat

6.使用ab工具產(chǎn)生一些訪問日志

在53主機操作

[root@db01 ~]# ab -n 100 -c 100 http://172.16.210.54/db02.html ##訪問54主機
[root@db01 ~]# ab -n 100 -c 100 http://172.16.210.55/db03.html ##訪問55主機

7.打開kibana查看數(shù)據(jù)

image.png

可以添加過濾項,只查看db02的訪問日志

image.png
image.png
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容