1.安装nginx服务
[root@elk92 ~]# apt -y install nginx
2.启动nginx服务
[root@elk92 ~]# systemctl enable --now nginx
3.访问测试
[root@elk92 ~]# curl 10.0.0.92
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to
nginx.org.
Commercial support is available at
nginx.com.
Thank you for using nginx.
[root@elk92 ~]#4.查看日志信息
[root@elk92 ~]# cat /var/log/nginx/access.log
10.0.0.92 - - [11/Mar/2025:18:27:23 +0800] "GET / HTTP/1.1" 200 612 "-" "curl/7.81.0"
[root@elk92 ~]#
5.使用Filebeat采集nginx日志
[root@elk92 ~]# cat /etc/filebeat/config/04-nginx-to-es.yaml
filebeat.inputs:
- type: log
paths:- /var/log/nginx/access.log*
output.elasticsearch:
hosts:
- 10.0.0.91:9200
- 10.0.0.92:9200
- 10.0.0.93:9200
index: oldboyedu-linux95-nginx-%
setup.ilm.enabled: false
setup.template.name: "oldboyedu-linux95"
setup.template.pattern: "oldboyedu-linux95-*"
setup.template.overwrite: true
setup.template.settings:
index.number_of_shards: 5
index.number_of_replicas: 0
[root@elk92 ~]#
6.启动Filebeat实例
[root@elk92 ~]# filebeat -e -c /etc/filebeat/config/04-nginx-to-es.yaml
7.kibana查看数据
略,见视频。
8.发送测试数据
[root@elk93 ~]# for i in seq 10
;do curl http://10.0.0.92;done